Mercurial > hg > truffle
comparison mx/mx_graal.py @ 16902:0583d157992a
formalized the set of distribution jars that are installed into the JDK to ensure both mx and the HotSpot make system do the necessary deployment
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 23 Aug 2014 00:50:44 +0200 |
parents | 6adb14d2320c |
children | b03a16cc5245 |
comparison
equal
deleted
inserted
replaced
16901:451468f7340b | 16902:0583d157992a |
---|---|
81 | 81 |
82 _make_eclipse_launch = False | 82 _make_eclipse_launch = False |
83 | 83 |
84 _minVersion = mx.VersionSpec('1.8') | 84 _minVersion = mx.VersionSpec('1.8') |
85 | 85 |
86 class JDKDeployedDist: | |
87 def __init__(self, name, isExtension): | |
88 self.name = name | |
89 self.isExtension = isExtension | |
90 | |
91 _jdkDeployedDists = [ | |
92 JDKDeployedDist('TRUFFLE', isExtension=False), | |
93 JDKDeployedDist('GRAAL_LOADER', isExtension=False), | |
94 JDKDeployedDist('GRAAL', isExtension=False), | |
95 JDKDeployedDist('GRAAL_TRUFFLE', isExtension=False) | |
96 ] | |
97 | |
86 JDK_UNIX_PERMISSIONS_DIR = 0755 | 98 JDK_UNIX_PERMISSIONS_DIR = 0755 |
87 JDK_UNIX_PERMISSIONS_FILE = 0644 | 99 JDK_UNIX_PERMISSIONS_FILE = 0644 |
88 JDK_UNIX_PERMISSIONS_EXEC = 0755 | 100 JDK_UNIX_PERMISSIONS_EXEC = 0755 |
89 | 101 |
90 def isVMSupported(vm): | 102 def isVMSupported(vm): |
457 if _installed_jdks: | 469 if _installed_jdks: |
458 mx.log("The selected JDK directory does not (yet) exist: " + jdk) | 470 mx.log("The selected JDK directory does not (yet) exist: " + jdk) |
459 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') | 471 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') |
460 | 472 |
461 if installJars: | 473 if installJars: |
462 def _installDistInJdksIfExists(dist): | 474 for jdkDist in _jdkDeployedDists: |
475 dist = mx.distribution(jdkDist.name) | |
463 if exists(dist.path): | 476 if exists(dist.path): |
464 _installDistInJdks(dist) | 477 _installDistInJdks(dist, jdkDist.isExtension) |
465 | |
466 _installDistInJdksIfExists(mx.distribution('GRAAL')) | |
467 _installDistInJdksIfExists(mx.distribution('GRAAL_LOADER')) | |
468 _installDistInJdksIfExists(mx.distribution('TRUFFLE')) | |
469 _installDistInJdksIfExists(mx.distribution('GRAAL_TRUFFLE')) | |
470 | 478 |
471 if vmToCheck is not None: | 479 if vmToCheck is not None: |
472 jvmCfg = _vmCfgInJdk(jdk) | 480 jvmCfg = _vmCfgInJdk(jdk) |
473 found = False | 481 found = False |
474 with open(jvmCfg) as f: | 482 with open(jvmCfg) as f: |
566 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dst) | 574 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dst) |
567 shutil.copyfile(src, tmp) | 575 shutil.copyfile(src, tmp) |
568 os.close(fd) | 576 os.close(fd) |
569 shutil.move(tmp, dstLib) | 577 shutil.move(tmp, dstLib) |
570 os.chmod(dstLib, permissions) | 578 os.chmod(dstLib, permissions) |
579 | |
580 def _installDistInJdksExt(dist): | |
581 _installDistInJdks(dist, True) | |
571 | 582 |
572 def _installDistInJdks(dist, ext=False): | 583 def _installDistInJdks(dist, ext=False): |
573 """ | 584 """ |
574 Installs the jar(s) for a given Distribution into all existing Graal JDKs | 585 Installs the jar(s) for a given Distribution into all existing Graal JDKs |
575 """ | 586 """ |
738 if not exists(opts2.export_dir): | 749 if not exists(opts2.export_dir): |
739 os.makedirs(opts2.export_dir) | 750 os.makedirs(opts2.export_dir) |
740 else: | 751 else: |
741 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir) | 752 assert os.path.isdir(opts2.export_dir), '{} is not a directory'.format(opts2.export_dir) |
742 | 753 |
743 shutil.copy(mx.distribution('GRAAL').path, opts2.export_dir) | 754 defsPath = join(_graal_home, 'make', 'defs.make') |
744 shutil.copy(mx.distribution('GRAAL_LOADER').path, opts2.export_dir) | 755 with open(defsPath) as fp: |
756 defs = fp.read() | |
757 for jdkDist in _jdkDeployedDists: | |
758 dist = mx.distribution(jdkDist.name) | |
759 defLine = 'EXPORT_LIST += $(EXPORT_JRE_LIB_DIR)/' + basename(dist.path) | |
760 if defLine not in defs: | |
761 mx.abort('Missing following line in ' + defsPath + '\n' + defLine) | |
762 shutil.copy(dist.path, opts2.export_dir) | |
745 graalOptions = join(_graal_home, 'graal.options') | 763 graalOptions = join(_graal_home, 'graal.options') |
746 if exists(graalOptions): | 764 if exists(graalOptions): |
747 shutil.copy(graalOptions, opts2.export_dir) | 765 shutil.copy(graalOptions, opts2.export_dir) |
748 | 766 |
749 if not _vmSourcesAvailable or not opts2.native: | 767 if not _vmSourcesAvailable or not opts2.native: |
1130 # Remove entries from class path that are in graal.jar and | 1148 # Remove entries from class path that are in graal.jar and |
1131 # run the VM in a mode where application/test classes can | 1149 # run the VM in a mode where application/test classes can |
1132 # access core Graal classes. | 1150 # access core Graal classes. |
1133 cp = prefixCp + coreCp + os.pathsep + projectsCp | 1151 cp = prefixCp + coreCp + os.pathsep + projectsCp |
1134 if isGraalEnabled(_get_vm()): | 1152 if isGraalEnabled(_get_vm()): |
1135 graalDist = mx.distribution('GRAAL') | 1153 excluded = set() |
1136 graalJarCp = set([d.output_dir() for d in graalDist.sorted_deps()]) | 1154 for jdkDist in _jdkDeployedDists: |
1137 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in graalJarCp]) | 1155 dist = mx.distribution(jdkDist.name) |
1156 excluded.update([d.output_dir() for d in dist.sorted_deps()]) | |
1157 cp = os.pathsep.join([e for e in cp.split(os.pathsep) if e not in excluded]) | |
1138 vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs | 1158 vmArgs = ['-XX:-UseGraalClassLoader'] + vmArgs |
1139 | 1159 |
1140 if len(testclasses) == 1: | 1160 if len(testclasses) == 1: |
1141 # Execute Junit directly when one test is being run. This simplifies | 1161 # Execute Junit directly when one test is being run. This simplifies |
1142 # replaying the VM execution in a native debugger (e.g., gdb). | 1162 # replaying the VM execution in a native debugger (e.g., gdb). |
2168 findbugsResults = join(_graal_home, 'findbugs.results') | 2188 findbugsResults = join(_graal_home, 'findbugs.results') |
2169 | 2189 |
2170 cmd = ['-jar', findbugsJar, '-textui', '-low', '-maxRank', '15'] | 2190 cmd = ['-jar', findbugsJar, '-textui', '-low', '-maxRank', '15'] |
2171 if sys.stdout.isatty(): | 2191 if sys.stdout.isatty(): |
2172 cmd.append('-progress') | 2192 cmd.append('-progress') |
2173 cmd = cmd + ['-auxclasspath', mx.classpath(['GRAAL'] + [p.name for p in nonTestProjects]), '-output', findbugsResults, '-exitcode'] + args + outputDirs | 2193 cmd = cmd + ['-auxclasspath', mx.classpath([d.name for d in _jdkDeployedDists] + [p.name for p in nonTestProjects]), '-output', findbugsResults, '-exitcode'] + args + outputDirs |
2174 exitcode = mx.run_java(cmd, nonZeroIsFatal=False) | 2194 exitcode = mx.run_java(cmd, nonZeroIsFatal=False) |
2175 if exitcode != 0: | 2195 if exitcode != 0: |
2176 with open(findbugsResults) as fp: | 2196 with open(findbugsResults) as fp: |
2177 mx.log(fp.read()) | 2197 mx.log(fp.read()) |
2178 os.unlink(findbugsResults) | 2198 os.unlink(findbugsResults) |
2284 global _installed_jdks | 2304 global _installed_jdks |
2285 _installed_jdks = opts.installed_jdks | 2305 _installed_jdks = opts.installed_jdks |
2286 global _vm_prefix | 2306 global _vm_prefix |
2287 _vm_prefix = opts.vm_prefix | 2307 _vm_prefix = opts.vm_prefix |
2288 | 2308 |
2289 mx.distribution('GRAAL').add_update_listener(_installDistInJdks) | 2309 for jdkDist in _jdkDeployedDists: |
2290 mx.distribution('GRAAL_LOADER').add_update_listener(_installDistInJdks) | 2310 if jdkDist.isExtension: |
2291 mx.distribution('TRUFFLE').add_update_listener(_installDistInJdks) | 2311 mx.distribution(jdkDist.name).add_update_listener(_installDistInJdksExt) |
2292 mx.distribution('GRAAL_TRUFFLE').add_update_listener(_installDistInJdks) | 2312 else: |
2313 mx.distribution(jdkDist.name).add_update_listener(_installDistInJdks) |