Mercurial > hg > truffle
comparison mx/mx_graal.py @ 16623:addc0564e5b5
split com.oracle.graal.truffle.* projects into a separate graal-truffle.jar and added truffle.jar to the boot class path
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 30 Jul 2014 18:27:06 +0200 |
parents | faaea970b951 |
children | 68deb37eed70 |
comparison
equal
deleted
inserted
replaced
16622:faaea970b951 | 16623:addc0564e5b5 |
---|---|
378 with VM(vm, bld): | 378 with VM(vm, bld): |
379 build([]) | 379 build([]) |
380 return | 380 return |
381 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') | 381 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build" to build the selected VM') |
382 | 382 |
383 def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=True): | 383 def _jdk(build='product', vmToCheck=None, create=False, installJars=True): |
384 """ | 384 """ |
385 Get the JDK into which Graal is installed, creating it first if necessary. | 385 Get the JDK into which Graal is installed, creating it first if necessary. |
386 """ | 386 """ |
387 jdk = join(_jdksDir(), build) | 387 jdk = join(_jdksDir(), build) |
388 if create: | 388 if create: |
455 if not exists(jdk): | 455 if not exists(jdk): |
456 if _installed_jdks: | 456 if _installed_jdks: |
457 mx.log("The selected JDK directory does not (yet) exist: " + jdk) | 457 mx.log("The selected JDK directory does not (yet) exist: " + jdk) |
458 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') | 458 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') |
459 | 459 |
460 if installGraalJar: | 460 if installJars: |
461 _installGraalJarInJdks(mx.distribution('GRAAL')) | 461 _installDistInJdks(mx.distribution('GRAAL')) |
462 _installGraalJarInJdks(mx.distribution('GRAAL_LOADER')) | 462 _installDistInJdks(mx.distribution('GRAAL_LOADER')) |
463 _installDistInJdks(mx.distribution('TRUFFLE')) | |
464 _installDistInJdks(mx.distribution('GRAAL_TRUFFLE')) | |
463 | 465 |
464 if vmToCheck is not None: | 466 if vmToCheck is not None: |
465 jvmCfg = _vmCfgInJdk(jdk) | 467 jvmCfg = _vmCfgInJdk(jdk) |
466 found = False | 468 found = False |
467 with open(jvmCfg) as f: | 469 with open(jvmCfg) as f: |
489 if not exists(hsSrcGenDir): | 491 if not exists(hsSrcGenDir): |
490 os.makedirs(hsSrcGenDir) | 492 os.makedirs(hsSrcGenDir) |
491 return hsSrcGenDir | 493 return hsSrcGenDir |
492 | 494 |
493 | 495 |
494 def _update_graalRuntime_inline_hpp(graalJar): | 496 def _update_graalRuntime_inline_hpp(jars): |
495 p = mx.project('com.oracle.graal.hotspot.sourcegen') | 497 p = mx.project('com.oracle.graal.hotspot.sourcegen') |
496 mainClass = 'com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp' | 498 mainClass = 'com.oracle.graal.hotspot.sourcegen.GenGraalRuntimeInlineHpp' |
497 if exists(join(p.output_dir(), mainClass.replace('.', os.sep) + '.class')): | 499 if exists(join(p.output_dir(), mainClass.replace('.', os.sep) + '.class')): |
498 graalRuntime_inline_hpp = join(_makeHotspotGeneratedSourcesDir(), 'graalRuntime.inline.hpp') | 500 graalRuntime_inline_hpp = join(_makeHotspotGeneratedSourcesDir(), 'graalRuntime.inline.hpp') |
499 tmp = StringIO.StringIO() | 501 tmp = StringIO.StringIO() |
500 mx.run_java(['-cp', '{}{}{}'.format(graalJar, os.pathsep, p.output_dir()), mainClass], out=tmp.write) | 502 mx.run_java(['-cp', '{}{}{}'.format(os.pathsep.join(jars), os.pathsep, p.output_dir()), mainClass], out=tmp.write) |
501 mx.update_file(graalRuntime_inline_hpp, tmp.getvalue()) | 503 mx.update_file(graalRuntime_inline_hpp, tmp.getvalue()) |
502 | 504 |
503 def _checkVMIsNewerThanGeneratedSources(jdk, vm, bld): | 505 def _checkVMIsNewerThanGeneratedSources(jdk, vm, bld): |
504 if isGraalEnabled(vm) and (not _installed_jdks or _installed_jdks == _graal_home): | 506 if isGraalEnabled(vm) and (not _installed_jdks or _installed_jdks == _graal_home): |
505 vmLib = mx.TimeStampFile(join(_vmLibDirInJdk(jdk), vm, mx.add_lib_prefix(mx.add_lib_suffix('jvm')))) | 507 vmLib = mx.TimeStampFile(join(_vmLibDirInJdk(jdk), vm, mx.add_lib_prefix(mx.add_lib_suffix('jvm')))) |
507 genSrc = join(_makeHotspotGeneratedSourcesDir(), name) | 509 genSrc = join(_makeHotspotGeneratedSourcesDir(), name) |
508 if vmLib.isOlderThan(genSrc): | 510 if vmLib.isOlderThan(genSrc): |
509 mx.log('The VM ' + vmLib.path + ' is older than ' + genSrc) | 511 mx.log('The VM ' + vmLib.path + ' is older than ' + genSrc) |
510 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build"') | 512 mx.abort('You need to run "mx --vm ' + vm + ' --vmbuild ' + bld + ' build"') |
511 | 513 |
512 def _installGraalJarInJdks(graalDist): | 514 def _installDistInJdks(dist): |
513 graalJar = graalDist.path | 515 """ |
514 if graalJar.endswith('graal.jar'): | 516 Installs the jar(s) for a given Distribution into all existing Graal JDKs |
515 _update_graalRuntime_inline_hpp(graalJar) | 517 """ |
518 | |
519 distJar = dist.path | |
520 if dist.name == 'GRAAL_TRUFFLE': | |
521 jars = [mx.distribution(d).path for d in dist.distDependencies] + [distJar] | |
522 _update_graalRuntime_inline_hpp(jars) | |
516 jdks = _jdksDir() | 523 jdks = _jdksDir() |
517 | 524 |
518 if exists(jdks): | 525 if exists(jdks): |
519 for e in os.listdir(jdks): | 526 for e in os.listdir(jdks): |
520 jreLibDir = join(jdks, e, 'jre', 'lib') | 527 jreLibDir = join(jdks, e, 'jre', 'lib') |
522 def install(srcJar, dstDir): | 529 def install(srcJar, dstDir): |
523 name = os.path.basename(srcJar) | 530 name = os.path.basename(srcJar) |
524 dstJar = join(dstDir, name) | 531 dstJar = join(dstDir, name) |
525 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': | 532 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': |
526 # Using symlinks is much faster than copying but may | 533 # Using symlinks is much faster than copying but may |
527 # cause issues if graal.jar is being updated while | 534 # cause issues if the jar is being updated while |
528 # the VM is running. | 535 # the VM is running. |
529 if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar: | 536 if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar: |
530 if exists(dstJar): | 537 if exists(dstJar): |
531 os.remove(dstJar) | 538 os.remove(dstJar) |
532 os.symlink(srcJar, dstJar) | 539 os.symlink(srcJar, dstJar) |
536 shutil.copyfile(srcJar, tmp) | 543 shutil.copyfile(srcJar, tmp) |
537 os.close(fd) | 544 os.close(fd) |
538 shutil.move(tmp, dstJar) | 545 shutil.move(tmp, dstJar) |
539 os.chmod(dstJar, JDK_UNIX_PERMISSIONS) | 546 os.chmod(dstJar, JDK_UNIX_PERMISSIONS) |
540 | 547 |
541 install(graalJar, jreLibDir) | 548 install(distJar, jreLibDir) |
542 if graalDist.sourcesPath: | 549 if dist.sourcesPath: |
543 install(graalDist.sourcesPath, join(jdks, e)) | 550 install(dist.sourcesPath, join(jdks, e)) |
544 | 551 |
545 # run a command in the windows SDK Debug Shell | 552 # run a command in the windows SDK Debug Shell |
546 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): | 553 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): |
547 if respondTo is None: | 554 if respondTo is None: |
548 respondTo = {} | 555 respondTo = {} |
603 return ret | 610 return ret |
604 | 611 |
605 def jdkhome(vm=None): | 612 def jdkhome(vm=None): |
606 """return the JDK directory selected for the 'vm' command""" | 613 """return the JDK directory selected for the 'vm' command""" |
607 build = _vmbuild if _vmSourcesAvailable else 'product' | 614 build = _vmbuild if _vmSourcesAvailable else 'product' |
608 return _jdk(build, installGraalJar=False) | 615 return _jdk(build, installJars=False) |
609 | 616 |
610 def print_jdkhome(args, vm=None): | 617 def print_jdkhome(args, vm=None): |
611 """print the JDK directory selected for the 'vm' command""" | 618 """print the JDK directory selected for the 'vm' command""" |
612 print jdkhome(vm) | 619 print jdkhome(vm) |
613 | 620 |
910 cwd = _vm_cwd | 917 cwd = _vm_cwd |
911 elif _vm_cwd is not None and _vm_cwd != cwd: | 918 elif _vm_cwd is not None and _vm_cwd != cwd: |
912 mx.abort("conflicting working directories: do not set --vmcwd for this command") | 919 mx.abort("conflicting working directories: do not set --vmcwd for this command") |
913 | 920 |
914 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' | 921 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' |
915 jdk = _jdk(build, vmToCheck=vm, installGraalJar=False) | 922 jdk = _jdk(build, vmToCheck=vm, installJars=False) |
916 _updateInstalledGraalOptionsFile(jdk) | 923 _updateInstalledGraalOptionsFile(jdk) |
917 _checkVMIsNewerThanGeneratedSources(jdk, vm, build) | 924 _checkVMIsNewerThanGeneratedSources(jdk, vm, build) |
918 mx.expand_project_in_args(args) | 925 mx.expand_project_in_args(args) |
919 if _make_eclipse_launch: | 926 if _make_eclipse_launch: |
920 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) | 927 mx.make_eclipse_launch(args, 'graal-' + build, name=None, deps=mx.project('com.oracle.graal.hotspot').all_deps([], True)) |
2232 global _installed_jdks | 2239 global _installed_jdks |
2233 _installed_jdks = opts.installed_jdks | 2240 _installed_jdks = opts.installed_jdks |
2234 global _vm_prefix | 2241 global _vm_prefix |
2235 _vm_prefix = opts.vm_prefix | 2242 _vm_prefix = opts.vm_prefix |
2236 | 2243 |
2237 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) | 2244 mx.distribution('GRAAL').add_update_listener(_installDistInJdks) |
2238 mx.distribution('GRAAL_LOADER').add_update_listener(_installGraalJarInJdks) | 2245 mx.distribution('GRAAL_LOADER').add_update_listener(_installDistInJdks) |
2246 mx.distribution('TRUFFLE').add_update_listener(_installDistInJdks) | |
2247 mx.distribution('GRAAL_TRUFFLE').add_update_listener(_installDistInJdks) |