Mercurial > hg > graal-compiler
comparison mxtool/mx.py @ 5699:e9f7d16194a8
added --base argument to javadoc command
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 27 Jun 2012 01:02:43 +0200 |
parents | 9911227e6dd3 |
children | d0a6e25de770 |
comparison
equal
deleted
inserted
replaced
5697:62f1b4b8de5c | 5699:e9f7d16194a8 |
---|---|
221 for n,d in distances.iteritems(): | 221 for n,d in distances.iteritems(): |
222 assert d > 0 or n == self.name | 222 assert d > 0 or n == self.name |
223 if d == 1: | 223 if d == 1: |
224 result.add(n) | 224 result.add(n) |
225 | 225 |
226 | |
227 if len(result) == len(self.deps) and frozenset(self.deps) == result: | 226 if len(result) == len(self.deps) and frozenset(self.deps) == result: |
228 return self.deps | 227 return self.deps |
229 return result; | 228 return result; |
230 | 229 |
230 def max_depth(self): | |
231 """ | |
232 Get the maximum canonical distance between this project and its most distant dependency. | |
233 """ | |
234 distances = dict() | |
235 self._compute_max_dep_distances(self.name, distances, 0) | |
236 return max(distances.values()) | |
231 | 237 |
232 def source_dirs(self): | 238 def source_dirs(self): |
233 """ | 239 """ |
234 Get the directories in which the sources of this project are found. | 240 Get the directories in which the sources of this project are found. |
235 """ | 241 """ |
1496 print 'node [shape=rect];' | 1502 print 'node [shape=rect];' |
1497 for p in projects(): | 1503 for p in projects(): |
1498 for dep in p.canonical_deps(): | 1504 for dep in p.canonical_deps(): |
1499 print '"' + p.name + '"->"' + dep + '"' | 1505 print '"' + p.name + '"->"' + dep + '"' |
1500 print '}' | 1506 print '}' |
1501 | |
1502 | 1507 |
1503 def _source_locator_memento(deps): | 1508 def _source_locator_memento(deps): |
1504 slm = XMLDoc() | 1509 slm = XMLDoc() |
1505 slm.open('sourceLookupDirector') | 1510 slm.open('sourceLookupDirector') |
1506 slm.open('sourceContainers', {'duplicates' : 'false'}) | 1511 slm.open('sourceContainers', {'duplicates' : 'false'}) |
1952 | 1957 |
1953 def javadoc(args): | 1958 def javadoc(args): |
1954 """generate javadoc for some/all Java projects""" | 1959 """generate javadoc for some/all Java projects""" |
1955 | 1960 |
1956 parser = ArgumentParser(prog='mx javadoc') | 1961 parser = ArgumentParser(prog='mx javadoc') |
1962 parser.add_argument('-d', '--base', action='store', help='base directory for output') | |
1957 parser.add_argument('--unified', action='store_true', help='put javadoc in a single directory instead of one per project') | 1963 parser.add_argument('--unified', action='store_true', help='put javadoc in a single directory instead of one per project') |
1958 parser.add_argument('--force', action='store_true', help='(re)generate javadoc even if package-list file exists') | 1964 parser.add_argument('--force', action='store_true', help='(re)generate javadoc even if package-list file exists') |
1959 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)') | 1965 parser.add_argument('--projects', action='store', help='comma separated projects to process (omit to process all projects)') |
1960 parser.add_argument('--argfile', action='store', help='name of file containing extra javadoc options') | 1966 parser.add_argument('--argfile', action='store', help='name of file containing extra javadoc options') |
1967 parser.add_argument('--arg', action='append', dest='extra_args', help='extra Javadoc arguments (e.g. --arg @-use)', metavar='@<arg>', default=[]) | |
1961 parser.add_argument('-m', '--memory', action='store', help='-Xmx value to pass to underlying JVM') | 1968 parser.add_argument('-m', '--memory', action='store', help='-Xmx value to pass to underlying JVM') |
1962 parser.add_argument('--wiki', action='store_true', help='generate Confluence Wiki format for package-info.java files') | 1969 parser.add_argument('--wiki', action='store_true', help='generate Confluence Wiki format for package-info.java files') |
1963 parser.add_argument('--packages', action='store', help='comma separated packages to process (omit to process all packages)') | 1970 parser.add_argument('--packages', action='store', help='comma separated packages to process (omit to process all packages)') |
1964 | 1971 |
1965 args = parser.parse_args(args) | 1972 args = parser.parse_args(args) |
1988 project_list = ','.join(p.name for p in sorted_deps()) | 1995 project_list = ','.join(p.name for p in sorted_deps()) |
1989 docletArgs = ['-docletpath', dp, '-doclet', 'com.oracle.max.tools.javadoc.wiki.WikiDoclet', '-projects', project_list] | 1996 docletArgs = ['-docletpath', dp, '-doclet', 'com.oracle.max.tools.javadoc.wiki.WikiDoclet', '-projects', project_list] |
1990 else: | 1997 else: |
1991 docDir = 'javadoc' | 1998 docDir = 'javadoc' |
1992 | 1999 |
2000 def outDir(p): | |
2001 if args.base is None: | |
2002 return join(p.dir, docDir) | |
2003 return join(args.base, p.name, docDir) | |
2004 | |
1993 def check_package_list(p): | 2005 def check_package_list(p): |
1994 if args.wiki: | 2006 if args.wiki: |
1995 return True | 2007 return True |
1996 else: | 2008 else: |
1997 return not exists(join(p.dir, docDir, 'package-list')) | 2009 return not exists(join(outDir(p), 'package-list')) |
1998 | 2010 |
1999 def assess_candidate(p, projects): | 2011 def assess_candidate(p, projects): |
2000 if p in projects: | 2012 if p in projects: |
2001 return False | 2013 return False |
2002 if args.force or args.unified or check_package_list(p): | 2014 if args.force or args.unified or check_package_list(p): |
2022 pkg = root[len(sourceDir) + 1:].replace('/','.') | 2034 pkg = root[len(sourceDir) + 1:].replace('/','.') |
2023 if (len(packages) == 0) | (pkg in packages): | 2035 if (len(packages) == 0) | (pkg in packages): |
2024 pkgs.add(pkg) | 2036 pkgs.add(pkg) |
2025 return pkgs | 2037 return pkgs |
2026 | 2038 |
2027 extraArgs = [] | 2039 extraArgs = [a.lstrip('@') for a in args.extra_args] |
2028 if args.argfile is not None: | 2040 if args.argfile is not None: |
2029 extraArgs += ['@' + args.argfile] | 2041 extraArgs += ['@' + args.argfile] |
2030 memory = '2g' | 2042 memory = '2g' |
2031 if args.memory is not None: | 2043 if args.memory is not None: |
2032 memory = args.memory | 2044 memory = args.memory |
2035 if not args.unified: | 2047 if not args.unified: |
2036 for p in projects: | 2048 for p in projects: |
2037 pkgs = find_packages(p.source_dirs(), set()) | 2049 pkgs = find_packages(p.source_dirs(), set()) |
2038 deps = p.all_deps([], includeLibs=False, includeSelf=False) | 2050 deps = p.all_deps([], includeLibs=False, includeSelf=False) |
2039 links = ['-link', 'http://docs.oracle.com/javase/' + str(p.javaCompliance.value) + '/docs/api/'] | 2051 links = ['-link', 'http://docs.oracle.com/javase/' + str(p.javaCompliance.value) + '/docs/api/'] |
2040 out = join(p.dir, docDir) | 2052 out = outDir(p) |
2041 for d in deps: | 2053 for d in deps: |
2042 depOut = join(d.dir, docDir) | 2054 depOut = outDir(d) |
2043 links.append('-link') | 2055 links.append('-link') |
2044 links.append(os.path.relpath(depOut, out)) | 2056 links.append(os.path.relpath(depOut, out)) |
2045 cp = classpath(p.name, includeSelf=True) | 2057 cp = classpath(p.name, includeSelf=True) |
2046 sp = os.pathsep.join(p.source_dirs()) | 2058 sp = os.pathsep.join(p.source_dirs()) |
2047 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) | 2059 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) |
2056 sp += p.source_dirs() | 2068 sp += p.source_dirs() |
2057 names.append(p.name) | 2069 names.append(p.name) |
2058 | 2070 |
2059 links = ['-link', 'http://docs.oracle.com/javase/' + str(_java.javaCompliance.value) + '/docs/api/'] | 2071 links = ['-link', 'http://docs.oracle.com/javase/' + str(_java.javaCompliance.value) + '/docs/api/'] |
2060 out = join(_mainSuite.dir, docDir) | 2072 out = join(_mainSuite.dir, docDir) |
2073 if args.base is not None: | |
2074 out = join(args.base, docDir) | |
2061 cp = classpath() | 2075 cp = classpath() |
2062 sp = os.pathsep.join(sp) | 2076 sp = os.pathsep.join(sp) |
2063 log('Generating {2} for {0} in {1}'.format(', '.join(names), out, docDir)) | 2077 log('Generating {2} for {0} in {1}'.format(', '.join(names), out, docDir)) |
2064 run([java().javadoc, memory, '-classpath', cp, '-quiet', '-d', out, '-sourcepath', sp] + docletArgs + links + extraArgs + list(pkgs)) | 2078 run([java().javadoc, memory, '-classpath', cp, '-quiet', '-d', out, '-sourcepath', sp] + docletArgs + links + extraArgs + list(pkgs)) |
2065 log('Generated {2} for {0} in {1}'.format(', '.join(names), out, docDir)) | 2079 log('Generated {2} for {0} in {1}'.format(', '.join(names), out, docDir)) |
2130 'projects': [show_projects, ''], | 2144 'projects': [show_projects, ''], |
2131 } | 2145 } |
2132 | 2146 |
2133 _argParser = ArgParser() | 2147 _argParser = ArgParser() |
2134 | 2148 |
2149 def _findPrimarySuite(): | |
2150 # try current working directory first | |
2151 mxDir = join(os.getcwd(), 'mx') | |
2152 if exists(mxDir) and isdir(mxDir): | |
2153 return dirname(mxDir) | |
2154 | |
2155 # now search path of my executable | |
2156 me = sys.argv[0] | |
2157 parent = dirname(me) | |
2158 while parent: | |
2159 mxDir = join(parent, 'mx') | |
2160 if exists(mxDir) and isdir(mxDir): | |
2161 return parent | |
2162 parent = dirname(parent) | |
2163 return None | |
2164 | |
2135 def main(): | 2165 def main(): |
2136 cwdMxDir = join(os.getcwd(), 'mx') | 2166 primarySuiteDir = _findPrimarySuite() |
2137 if exists(cwdMxDir) and isdir(cwdMxDir): | 2167 if primarySuiteDir: |
2138 global _mainSuite | 2168 global _mainSuite |
2139 _mainSuite = _loadSuite(os.getcwd(), True) | 2169 _mainSuite = _loadSuite(primarySuiteDir, True) |
2140 | 2170 |
2141 opts, commandAndArgs = _argParser._parse_cmd_line() | 2171 opts, commandAndArgs = _argParser._parse_cmd_line() |
2142 | 2172 |
2143 global _opts, _java | 2173 global _opts, _java |
2144 _opts = opts | 2174 _opts = opts |