Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 14763:a6c1c3eb20c4
transition to JDK8
- introduce support for more than one JDK in mx
- update version in annotiationprocessors
- update project definitions (truffle api is not part of the transition)
- fix style errors
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 26 Mar 2014 14:34:08 +0100 |
parents | 65b005b58825 |
children | 5823c399e28f |
comparison
equal
deleted
inserted
replaced
14762:c6f4b780fa88 | 14763:a6c1c3eb20c4 |
---|---|
52 _suites = dict() | 52 _suites = dict() |
53 _annotationProcessors = None | 53 _annotationProcessors = None |
54 _primary_suite_path = None | 54 _primary_suite_path = None |
55 _primary_suite = None | 55 _primary_suite = None |
56 _opts = None | 56 _opts = None |
57 _java = None | 57 _java_homes = None |
58 _warn = False | 58 _warn = False |
59 | 59 |
60 """ | 60 """ |
61 A distribution is a jar or zip file containing the output from one or more Java projects. | 61 A distribution is a jar or zip file containing the output from one or more Java projects. |
62 """ | 62 """ |
114 self.checkstyleProj = name | 114 self.checkstyleProj = name |
115 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance is not None else None | 115 self.javaCompliance = JavaCompliance(javaCompliance) if javaCompliance is not None else None |
116 self.native = False | 116 self.native = False |
117 self.workingSets = workingSets | 117 self.workingSets = workingSets |
118 self.dir = d | 118 self.dir = d |
119 | |
120 # Verify that a JDK exists for this project if its compliance level is | |
121 # less than the compliance level of the default JDK | |
122 jdk = java(self.javaCompliance) | |
123 if jdk is None and self.javaCompliance < java().javaCompliance: | |
124 abort('Cannot find ' + str(self.javaCompliance) + ' JDK required by ' + name + '. ' + | |
125 'Specify it with --extra-java-homes option or EXTRA_JAVA_HOMES environment variable.') | |
119 | 126 |
120 # Create directories for projects that don't yet exist | 127 # Create directories for projects that don't yet exist |
121 if not exists(d): | 128 if not exists(d): |
122 os.mkdir(d) | 129 os.mkdir(d) |
123 for s in self.source_dirs(): | 130 for s in self.source_dirs(): |
1034 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') | 1041 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') |
1035 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>') | 1042 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>') |
1036 self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[]) | 1043 self.add_argument('--Jp', action='append', dest='java_args_pfx', help='prefix Java VM arguments (e.g. --Jp @-dsa)', metavar='@<args>', default=[]) |
1037 self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[]) | 1044 self.add_argument('--Ja', action='append', dest='java_args_sfx', help='suffix Java VM arguments (e.g. --Ja @-dsa)', metavar='@<args>', default=[]) |
1038 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) | 1045 self.add_argument('--user-home', help='users home directory', metavar='<path>', default=os.path.expanduser('~')) |
1039 self.add_argument('--java-home', help='bootstrap JDK installation directory (must be JDK 6 or later)', metavar='<path>') | 1046 self.add_argument('--java-home', help='primary JDK directory (must be JDK 7 or later)', metavar='<path>') |
1047 self.add_argument('--extra-java-homes', help='secondary JDK directories separated by "' + os.pathsep + '"', metavar='<path>') | |
1040 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[]) | 1048 self.add_argument('--ignore-project', action='append', dest='ignored_projects', help='name of project to ignore', metavar='<name>', default=[]) |
1041 self.add_argument('--kill-with-sigquit', action='store_true', dest='killwithsigquit', help='send sigquit first before killing child processes') | 1049 self.add_argument('--kill-with-sigquit', action='store_true', dest='killwithsigquit', help='send sigquit first before killing child processes') |
1042 if get_os() != 'windows': | 1050 if get_os() != 'windows': |
1043 # Time outs are (currently) implemented with Unix specific functionality | 1051 # Time outs are (currently) implemented with Unix specific functionality |
1044 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>') | 1052 self.add_argument('--timeout', help='timeout (in seconds) for command', type=int, default=0, metavar='<secs>') |
1059 if opts.very_verbose: | 1067 if opts.very_verbose: |
1060 opts.verbose = True | 1068 opts.verbose = True |
1061 | 1069 |
1062 if opts.java_home is None: | 1070 if opts.java_home is None: |
1063 opts.java_home = os.environ.get('JAVA_HOME') | 1071 opts.java_home = os.environ.get('JAVA_HOME') |
1072 if opts.extra_java_homes is None: | |
1073 opts.extra_java_homes = os.environ.get('EXTRA_JAVA_HOMES') | |
1064 | 1074 |
1065 if opts.java_home is None or opts.java_home == '': | 1075 if opts.java_home is None or opts.java_home == '': |
1066 opts.java_home = _handle_missing_java_home() | 1076 opts.java_home = _handle_missing_java_home() |
1067 | 1077 |
1068 if opts.user_home is None or opts.user_home == '': | 1078 if opts.user_home is None or opts.user_home == '': |
1087 if doc is None: | 1097 if doc is None: |
1088 doc = '' | 1098 doc = '' |
1089 msg += ' {0:<20} {1}\n'.format(cmd, doc.split('\n', 1)[0]) | 1099 msg += ' {0:<20} {1}\n'.format(cmd, doc.split('\n', 1)[0]) |
1090 return msg + '\n' | 1100 return msg + '\n' |
1091 | 1101 |
1092 def java(): | 1102 def java(requiredCompliance=None): |
1093 """ | 1103 """ |
1094 Get a JavaConfig object containing Java commands launch details. | 1104 Get a JavaConfig object containing Java commands launch details. |
1095 """ | 1105 If requiredCompliance is None, the compliance level specified by --java-home/JAVA_HOME |
1096 assert _java is not None | 1106 is returned. Otherwise, the JavaConfig exactly matching requiredCompliance is returned |
1097 return _java | 1107 or None if there is no exact match. |
1108 """ | |
1109 assert _java_homes | |
1110 if not requiredCompliance: | |
1111 return _java_homes[0] | |
1112 for java in _java_homes: | |
1113 if java.javaCompliance == requiredCompliance: | |
1114 return java | |
1115 return None | |
1116 | |
1098 | 1117 |
1099 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, addDefaultArgs=True): | 1118 def run_java(args, nonZeroIsFatal=True, out=None, err=None, cwd=None, addDefaultArgs=True): |
1100 return run(java().format_cmd(args, addDefaultArgs), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) | 1119 return run(java().format_cmd(args, addDefaultArgs), nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd) |
1101 | 1120 |
1102 def _kill_process_group(pid, sig): | 1121 def _kill_process_group(pid, sig): |
1348 | 1367 |
1349 """ | 1368 """ |
1350 A JavaConfig object encapsulates info on how Java commands are run. | 1369 A JavaConfig object encapsulates info on how Java commands are run. |
1351 """ | 1370 """ |
1352 class JavaConfig: | 1371 class JavaConfig: |
1353 def __init__(self, opts): | 1372 def __init__(self, java_home, java_dbg_port): |
1354 self.jdk = opts.java_home | 1373 self.jdk = java_home |
1355 self.debug_port = opts.java_dbg_port | 1374 self.debug_port = java_dbg_port |
1356 self.jar = exe_suffix(join(self.jdk, 'bin', 'jar')) | 1375 self.jar = exe_suffix(join(self.jdk, 'bin', 'jar')) |
1357 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) | 1376 self.java = exe_suffix(join(self.jdk, 'bin', 'java')) |
1358 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) | 1377 self.javac = exe_suffix(join(self.jdk, 'bin', 'javac')) |
1359 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap')) | 1378 self.javap = exe_suffix(join(self.jdk, 'bin', 'javap')) |
1360 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc')) | 1379 self.javadoc = exe_suffix(join(self.jdk, 'bin', 'javadoc')) |
1361 self._bootclasspath = None | 1380 self._bootclasspath = None |
1362 | 1381 |
1363 if not exists(self.java): | 1382 if not exists(self.java): |
1364 abort('Java launcher derived from JAVA_HOME does not exist: ' + self.java) | 1383 abort('Java launcher does not exist: ' + self.java) |
1365 | 1384 |
1366 def delAtAndSplit(s): | 1385 def delAtAndSplit(s): |
1367 return shlex.split(s.lstrip('@')) | 1386 return shlex.split(s.lstrip('@')) |
1368 | 1387 |
1369 self.java_args = delAtAndSplit(_opts.java_args) if _opts.java_args else [] | 1388 self.java_args = delAtAndSplit(_opts.java_args) if _opts.java_args else [] |
1386 self.version = VersionSpec(output[2].strip('"')) | 1405 self.version = VersionSpec(output[2].strip('"')) |
1387 self.javaCompliance = JavaCompliance(self.version.versionString) | 1406 self.javaCompliance = JavaCompliance(self.version.versionString) |
1388 | 1407 |
1389 if self.debug_port is not None: | 1408 if self.debug_port is not None: |
1390 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] | 1409 self.java_args += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(self.debug_port)] |
1410 | |
1411 def __hash__(self): | |
1412 return hash(self.jdk) | |
1413 | |
1414 def __cmp__(self, other): | |
1415 if isinstance(other, JavaConfig): | |
1416 return cmp(self.javaCompliance, other.javaCompliance) | |
1417 raise TypeError() | |
1391 | 1418 |
1392 def format_cmd(self, args, addDefaultArgs): | 1419 def format_cmd(self, args, addDefaultArgs): |
1393 if addDefaultArgs: | 1420 if addDefaultArgs: |
1394 return [self.java] + self.processArgs(args) | 1421 return [self.java] + self.processArgs(args) |
1395 else: | 1422 else: |
1622 | 1649 |
1623 suppliedParser = parser is not None | 1650 suppliedParser = parser is not None |
1624 if not suppliedParser: | 1651 if not suppliedParser: |
1625 parser = ArgumentParser(prog='mx build') | 1652 parser = ArgumentParser(prog='mx build') |
1626 | 1653 |
1627 javaCompliance = java().javaCompliance | |
1628 | |
1629 defaultEcjPath = get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) | 1654 defaultEcjPath = get_env('JDT', join(_primary_suite.mxDir, 'ecj.jar')) |
1630 | 1655 |
1631 parser = parser if parser is not None else ArgumentParser(prog='mx build') | 1656 parser = parser if parser is not None else ArgumentParser(prog='mx build') |
1632 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') | 1657 parser.add_argument('-f', action='store_true', dest='force', help='force build (disables timestamp checking)') |
1633 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') | 1658 parser.add_argument('-c', action='store_true', dest='clean', help='removes existing build output') |
1634 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one', default=str(javaCompliance)) | 1659 parser.add_argument('--source', dest='compliance', help='Java compliance level for projects without an explicit one') |
1635 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') | 1660 parser.add_argument('--Wapi', action='store_true', dest='warnAPI', help='show warnings about using internal APIs') |
1636 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') | 1661 parser.add_argument('--projects', action='store', help='comma separated projects to build (omit to build all projects)') |
1637 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') | 1662 parser.add_argument('--only', action='store', help='comma separated projects to build, without checking their dependencies (omit to build all projects)') |
1638 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') | 1663 parser.add_argument('--no-java', action='store_false', dest='java', help='do not build Java projects') |
1639 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') | 1664 parser.add_argument('--no-native', action='store_false', dest='native', help='do not build native projects') |
1708 continue | 1733 continue |
1709 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | 1734 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
1710 continue | 1735 continue |
1711 | 1736 |
1712 # skip building this Java project if its Java compliance level is "higher" than the configured JDK | 1737 # skip building this Java project if its Java compliance level is "higher" than the configured JDK |
1713 if javaCompliance < p.javaCompliance: | 1738 requiredCompliance = p.javaCompliance if p.javaCompliance else JavaCompliance(args.compliance) if args.compliance else None |
1714 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) | 1739 jdk = java(requiredCompliance) |
1740 if not jdk: | |
1741 log('Excluding {0} from build (Java compliance level {1} required)'.format(p.name, requiredCompliance)) | |
1715 continue | 1742 continue |
1743 compliance = str(jdk.javaCompliance) | |
1716 | 1744 |
1717 outputDir = prepareOutputDirs(p, args.clean) | 1745 outputDir = prepareOutputDirs(p, args.clean) |
1718 | 1746 |
1719 cp = classpath(p.name, includeSelf=True) | 1747 cp = classpath(p.name, includeSelf=True) |
1720 sourceDirs = p.source_dirs() | 1748 sourceDirs = p.source_dirs() |
1815 else: | 1843 else: |
1816 processorArgs += ['-proc:none'] | 1844 processorArgs += ['-proc:none'] |
1817 | 1845 |
1818 toBeDeleted = [argfileName] | 1846 toBeDeleted = [argfileName] |
1819 try: | 1847 try: |
1820 compliance = str(p.javaCompliance) if p.javaCompliance is not None else args.compliance | |
1821 if jdtJar is None: | 1848 if jdtJar is None: |
1822 log('Compiling Java sources for {0} with javac...'.format(p.name)) | 1849 log('Compiling Java sources for {0} with javac...'.format(p.name)) |
1823 | 1850 javacCmd = [jdk.javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir] |
1824 | 1851 if jdk.debug_port is not None: |
1825 javacCmd = [java().javac, '-g', '-J-Xmx1g', '-source', compliance, '-target', compliance, '-classpath', cp, '-d', outputDir] | 1852 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
1826 if java().debug_port is not None: | |
1827 javacCmd += ['-J-Xdebug', '-J-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | |
1828 javacCmd += processorArgs | 1853 javacCmd += processorArgs |
1829 javacCmd += ['@' + argfile.name] | 1854 javacCmd += ['@' + argfile.name] |
1830 | 1855 |
1831 if not args.warnAPI: | 1856 if not args.warnAPI: |
1832 javacCmd.append('-XDignore.symbol.file') | 1857 javacCmd.append('-XDignore.symbol.file') |
1833 run(javacCmd) | 1858 run(javacCmd) |
1834 else: | 1859 else: |
1835 log('Compiling Java sources for {0} with JDT...'.format(p.name)) | 1860 log('Compiling Java sources for {0} with JDT...'.format(p.name)) |
1836 | 1861 |
1837 jdtArgs = [java().java, '-Xmx1g'] | 1862 jdtArgs = [jdk.java, '-Xmx1g'] |
1838 if java().debug_port is not None: | 1863 if jdk.debug_port is not None: |
1839 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] | 1864 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(jdk.debug_port)] |
1840 | 1865 |
1841 jdtArgs += ['-jar', jdtJar, | 1866 jdtArgs += ['-jar', jdtJar, |
1842 '-' + compliance, | 1867 '-' + compliance, |
1843 '-cp', cp, '-g', '-enableJavadoc', | 1868 '-cp', cp, '-g', '-enableJavadoc', |
1844 '-d', outputDir] | 1869 '-d', outputDir] |
1910 projects = sorted_deps() | 1935 projects = sorted_deps() |
1911 if args.projects is not None: | 1936 if args.projects is not None: |
1912 projects = [project(name) for name in args.projects.split(',')] | 1937 projects = [project(name) for name in args.projects.split(',')] |
1913 | 1938 |
1914 class Batch: | 1939 class Batch: |
1915 def __init__(self, settingsFile): | 1940 def __init__(self, settingsFile, javaCompliance): |
1916 self.path = settingsFile | 1941 self.path = settingsFile |
1942 self.javaCompliance = javaCompliance | |
1917 self.javafiles = list() | 1943 self.javafiles = list() |
1918 | 1944 |
1919 def settings(self): | 1945 def settings(self): |
1920 with open(self.path) as fp: | 1946 with open(self.path) as fp: |
1921 return fp.read() | 1947 return fp.read() + java(self.javaCompliance).java |
1922 | 1948 |
1923 class FileInfo: | 1949 class FileInfo: |
1924 def __init__(self, path): | 1950 def __init__(self, path): |
1925 self.path = path | 1951 self.path = path |
1926 with open(path) as fp: | 1952 with open(path) as fp: |
1941 for p in projects: | 1967 for p in projects: |
1942 if p.native: | 1968 if p.native: |
1943 continue | 1969 continue |
1944 sourceDirs = p.source_dirs() | 1970 sourceDirs = p.source_dirs() |
1945 | 1971 |
1946 batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs')) | 1972 batch = Batch(join(p.dir, '.settings', 'org.eclipse.jdt.core.prefs'), p.javaCompliance) |
1947 | 1973 |
1948 if not exists(batch.path): | 1974 if not exists(batch.path): |
1949 if _opts.verbose: | 1975 if _opts.verbose: |
1950 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) | 1976 log('[no Eclipse Code Formatter preferences at {0} - skipping]'.format(batch.path)) |
1951 continue | 1977 continue |
1960 | 1986 |
1961 res = batches.setdefault(batch.settings(), batch) | 1987 res = batches.setdefault(batch.settings(), batch) |
1962 if res is not batch: | 1988 if res is not batch: |
1963 res.javafiles = res.javafiles + batch.javafiles | 1989 res.javafiles = res.javafiles + batch.javafiles |
1964 | 1990 |
1991 print "we have: " + str(len(batches)) + " batches" | |
1965 for batch in batches.itervalues(): | 1992 for batch in batches.itervalues(): |
1966 run([args.eclipse_exe, '-nosplash', '-application', 'org.eclipse.jdt.core.JavaCodeFormatter', '-config', batch.path] + [f.path for f in batch.javafiles]) | 1993 run([args.eclipse_exe, |
1994 '-nosplash', | |
1995 '-application', | |
1996 'org.eclipse.jdt.core.JavaCodeFormatter', | |
1997 '-vm', java(batch.javaCompliance).java, | |
1998 '-config', batch.path] | |
1999 + [f.path for f in batch.javafiles]) | |
1967 for fi in batch.javafiles: | 2000 for fi in batch.javafiles: |
1968 if fi.update(): | 2001 if fi.update(): |
1969 modified.append(fi) | 2002 modified.append(fi) |
1970 | 2003 |
1971 log('{0} files were modified'.format(len(modified))) | 2004 log('{0} files were modified'.format(len(modified))) |
2113 overwriteCheck(zf, arcname, lpath + '!' + arcname) | 2146 overwriteCheck(zf, arcname, lpath + '!' + arcname) |
2114 zf.writestr(arcname, lp.read(arcname)) | 2147 zf.writestr(arcname, lp.read(arcname)) |
2115 else: | 2148 else: |
2116 p = dep | 2149 p = dep |
2117 # skip a Java project if its Java compliance level is "higher" than the configured JDK | 2150 # skip a Java project if its Java compliance level is "higher" than the configured JDK |
2118 if java().javaCompliance < p.javaCompliance: | 2151 jdk = java(p.javaCompliance) |
2152 if not jdk: | |
2119 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path)) | 2153 log('Excluding {0} from {2} (Java compliance level {1} required)'.format(p.name, p.javaCompliance, d.path)) |
2120 continue | 2154 continue |
2121 | 2155 |
2122 logv('[' + d.path + ': adding project ' + p.name + ']') | 2156 logv('[' + d.path + ': adding project ' + p.name + ']') |
2123 outputDir = p.output_dir() | 2157 outputDir = p.output_dir() |
2294 | 2328 |
2295 if not exists(dotCheckstyle): | 2329 if not exists(dotCheckstyle): |
2296 abort('ERROR: .checkstyle for Project {0} is missing'.format(p.name)) | 2330 abort('ERROR: .checkstyle for Project {0} is missing'.format(p.name)) |
2297 | 2331 |
2298 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK | 2332 # skip checking this Java project if its Java compliance level is "higher" than the configured JDK |
2299 if java().javaCompliance < p.javaCompliance: | 2333 jdk = java(p.javaCompliance) |
2334 if not jdk: | |
2300 log('Excluding {0} from checking (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) | 2335 log('Excluding {0} from checking (Java compliance level {1} required)'.format(p.name, p.javaCompliance)) |
2301 continue | 2336 continue |
2302 | 2337 |
2303 for sourceDir in sourceDirs: | 2338 for sourceDir in sourceDirs: |
2304 javafilelist = [] | 2339 javafilelist = [] |
2718 | 2753 |
2719 for p in suite.projects: | 2754 for p in suite.projects: |
2720 if p.native: | 2755 if p.native: |
2721 continue | 2756 continue |
2722 | 2757 |
2758 if not java(p.javaCompliance): | |
2759 log('Excluding {0} (JDK with compliance level {1} not available)'.format(p.name, p.javaCompliance)) | |
2760 continue | |
2761 | |
2723 if not exists(p.dir): | 2762 if not exists(p.dir): |
2724 os.makedirs(p.dir) | 2763 os.makedirs(p.dir) |
2725 | 2764 |
2726 out = XMLDoc() | 2765 out = XMLDoc() |
2727 out.open('classpath') | 2766 out.open('classpath') |
2962 launchOut = XMLDoc() | 3001 launchOut = XMLDoc() |
2963 consoleOn = 'true' if logToConsole else 'false' | 3002 consoleOn = 'true' if logToConsole else 'false' |
2964 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) | 3003 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) |
2965 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn}) | 3004 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn}) |
2966 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) | 3005 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) |
2967 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk}) | 3006 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java(p.javaCompliance).jdk}) |
2968 launchOut.close('mapAttribute') | 3007 launchOut.close('mapAttribute') |
2969 | 3008 |
2970 if refresh: | 3009 if refresh: |
2971 if refreshFile is None: | 3010 if refreshFile is None: |
2972 refreshScope = '${project}' | 3011 refreshScope = '${project}' |
3209 return | 3248 return |
3210 | 3249 |
3211 updated = False | 3250 updated = False |
3212 files = [] | 3251 files = [] |
3213 libFiles = [] | 3252 libFiles = [] |
3253 jdks = set() | |
3214 for p in suite.projects: | 3254 for p in suite.projects: |
3215 if p.native: | 3255 if p.native: |
3216 continue | 3256 continue |
3217 | 3257 |
3218 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project | 3258 if exists(join(p.dir, 'plugin.xml')): # eclipse plugin project |
3219 continue | 3259 continue |
3220 | 3260 |
3221 if not exists(join(p.dir, 'nbproject')): | 3261 if not exists(join(p.dir, 'nbproject')): |
3222 os.makedirs(join(p.dir, 'nbproject')) | 3262 os.makedirs(join(p.dir, 'nbproject')) |
3263 | |
3264 jdk = java(p.javaCompliance) | |
3265 | |
3266 if not jdk: | |
3267 log('Excluding {0} (JDK with compliance level {1} not available)'.format(p.name, p.javaCompliance)) | |
3268 continue | |
3269 | |
3270 jdks.add(jdk) | |
3223 | 3271 |
3224 out = XMLDoc() | 3272 out = XMLDoc() |
3225 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) | 3273 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) |
3226 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.') | 3274 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.') |
3227 out.element('import', {'file' : 'nbproject/build-impl.xml'}) | 3275 out.element('import', {'file' : 'nbproject/build-impl.xml'}) |
3228 out.open('target', {'name' : '-post-compile'}) | 3276 out.open('target', {'name' : '-post-compile'}) |
3229 out.open('exec', {'executable' : sys.executable}) | 3277 out.open('exec', {'executable' : sys.executable}) |
3230 out.element('env', {'key' : 'JAVA_HOME', 'value' : java().jdk}) | 3278 out.element('env', {'key' : 'JAVA_HOME', 'value' : jdk.jdk}) |
3231 out.element('arg', {'value' : os.path.abspath(__file__)}) | 3279 out.element('arg', {'value' : os.path.abspath(__file__)}) |
3232 out.element('arg', {'value' : 'archive'}) | 3280 out.element('arg', {'value' : 'archive'}) |
3233 out.element('arg', {'value' : '@GRAAL'}) | 3281 out.element('arg', {'value' : '@GRAAL'}) |
3234 out.close('exec') | 3282 out.close('exec') |
3235 out.close('target') | 3283 out.close('target') |
3280 out.close('project') | 3328 out.close('project') |
3281 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated | 3329 updated = update_file(join(p.dir, 'nbproject', 'project.xml'), out.xml(indent=' ', newl='\n')) or updated |
3282 files.append(join(p.dir, 'nbproject', 'project.xml')) | 3330 files.append(join(p.dir, 'nbproject', 'project.xml')) |
3283 | 3331 |
3284 out = StringIO.StringIO() | 3332 out = StringIO.StringIO() |
3285 jdkPlatform = 'JDK_' + str(java().version) | 3333 jdkPlatform = 'JDK_' + str(jdk.version) |
3286 | 3334 |
3287 annotationProcessorEnabled = "false" | 3335 annotationProcessorEnabled = "false" |
3288 annotationProcessorReferences = "" | 3336 annotationProcessorReferences = "" |
3289 annotationProcessorSrcFolder = "" | 3337 annotationProcessorSrcFolder = "" |
3290 if len(p.annotation_processors()) > 0: | 3338 if len(p.annotation_processors()) > 0: |
3343 javadoc.windowtitle= | 3391 javadoc.windowtitle= |
3344 main.class= | 3392 main.class= |
3345 manifest.file=manifest.mf | 3393 manifest.file=manifest.mf |
3346 meta.inf.dir=${src.dir}/META-INF | 3394 meta.inf.dir=${src.dir}/META-INF |
3347 mkdist.disabled=false | 3395 mkdist.disabled=false |
3348 platforms.""" + jdkPlatform + """.home=""" + java().jdk + """ | 3396 platforms.""" + jdkPlatform + """.home=""" + jdk.jdk + """ |
3349 platform.active=""" + jdkPlatform + """ | 3397 platform.active=""" + jdkPlatform + """ |
3350 run.classpath=\\ | 3398 run.classpath=\\ |
3351 ${javac.classpath}:\\ | 3399 ${javac.classpath}:\\ |
3352 ${build.classes.dir} | 3400 ${build.classes.dir} |
3353 # Space-separated list of JVM arguments used when running the project | 3401 # Space-separated list of JVM arguments used when running the project |
3423 out.close() | 3471 out.close() |
3424 files.append(join(p.dir, 'nbproject', 'project.properties')) | 3472 files.append(join(p.dir, 'nbproject', 'project.properties')) |
3425 | 3473 |
3426 if updated: | 3474 if updated: |
3427 log('If using NetBeans:') | 3475 log('If using NetBeans:') |
3428 log(' 1. Ensure that a platform named "JDK_' + str(java().version) + '" is defined (Tools -> Java Platforms)') | 3476 log(' 1. Ensure that the following platform(s) are defined (Tools -> Java Platforms):') |
3477 for jdk in jdks: | |
3478 log(' JDK_' + str(jdk.version)) | |
3429 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') | 3479 log(' 2. Open/create a Project Group for the directory containing the projects (File -> Project Group -> New Group... -> Folder of Projects)') |
3430 | 3480 |
3431 _zip_files(files, suite.dir, configZip.path) | 3481 _zip_files(files, suite.dir, configZip.path) |
3432 _zip_files(libFiles, suite.dir, configLibsZip) | 3482 _zip_files(libFiles, suite.dir, configLibsZip) |
3433 | 3483 |
3594 windowTitle = [] | 3644 windowTitle = [] |
3595 if stdDoclet: | 3645 if stdDoclet: |
3596 windowTitle = ['-windowtitle', p.name + ' javadoc'] | 3646 windowTitle = ['-windowtitle', p.name + ' javadoc'] |
3597 try: | 3647 try: |
3598 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) | 3648 log('Generating {2} for {0} in {1}'.format(p.name, out, docDir)) |
3599 run([java().javadoc, memory, | 3649 run([java(p.javaCompliance).javadoc, memory, |
3600 '-XDignore.symbol.file', | 3650 '-XDignore.symbol.file', |
3601 '-classpath', cp, | 3651 '-classpath', cp, |
3602 '-quiet', | 3652 '-quiet', |
3603 '-d', out, | 3653 '-d', out, |
3604 '-overview', overviewFile, | 3654 '-overview', overviewFile, |
3623 for p in projects: | 3673 for p in projects: |
3624 find_packages(p.source_dirs(), pkgs) | 3674 find_packages(p.source_dirs(), pkgs) |
3625 sp += p.source_dirs() | 3675 sp += p.source_dirs() |
3626 names.append(p.name) | 3676 names.append(p.name) |
3627 | 3677 |
3628 links = ['-link', 'http://docs.oracle.com/javase/' + str(_java.javaCompliance.value) + '/docs/api/'] | 3678 links = ['-link', 'http://docs.oracle.com/javase/' + str(java().javaCompliance.value) + '/docs/api/'] |
3629 out = join(_primary_suite.dir, docDir) | 3679 out = join(_primary_suite.dir, docDir) |
3630 if args.base is not None: | 3680 if args.base is not None: |
3631 out = join(args.base, docDir) | 3681 out = join(args.base, docDir) |
3632 cp = classpath() | 3682 cp = classpath() |
3633 sp = os.pathsep.join(sp) | 3683 sp = os.pathsep.join(sp) |
4103 else: | 4153 else: |
4104 abort('no primary suite found') | 4154 abort('no primary suite found') |
4105 | 4155 |
4106 opts, commandAndArgs = _argParser._parse_cmd_line() | 4156 opts, commandAndArgs = _argParser._parse_cmd_line() |
4107 | 4157 |
4108 global _opts, _java | 4158 global _opts, _java_homes |
4109 _opts = opts | 4159 _opts = opts |
4110 _java = JavaConfig(opts) | 4160 defaultJdk = JavaConfig(opts.java_home, opts.java_dbg_port) |
4161 _java_homes = [defaultJdk] | |
4162 if opts.extra_java_homes: | |
4163 for java_home in opts.extra_java_homes.split(os.pathsep): | |
4164 extraJdk = JavaConfig(java_home, opts.java_dbg_port) | |
4165 if extraJdk > defaultJdk: | |
4166 abort('Secondary JDK ' + extraJdk.jdk + ' has higher compliance level than default JDK ' + defaultJdk.jdk) | |
4167 _java_homes.append(extraJdk) | |
4111 | 4168 |
4112 for s in suites(): | 4169 for s in suites(): |
4113 s._post_init(opts) | 4170 s._post_init(opts) |
4114 | 4171 |
4115 if len(commandAndArgs) == 0: | 4172 if len(commandAndArgs) == 0: |