comparison mx/mx_graal.py @ 21031:e1c063565b3c

Graal Services: use services files in jre/lib/graal/services
author Gilles Duboscq <gilles.m.duboscq@oracle.com>
date Wed, 15 Apr 2015 18:21:00 +0200
parents 5e78d067ebbe
children 9507c925abe9
comparison
equal deleted inserted replaced
21030:c8166c23047d 21031:e1c063565b3c
85 85
86 # max version (first _unsupported_ version) 86 # max version (first _unsupported_ version)
87 _untilVersion = None 87 _untilVersion = None
88 88
89 class JDKDeployedDist: 89 class JDKDeployedDist:
90 def __init__(self, name, isExtension): 90 def __init__(self, name, isExtension = False, isGraalClassLoader = False):
91 self.name = name 91 self.name = name
92 self.isExtension = isExtension 92 self.isExtension = isExtension
93 self.isGraalClassLoader = isGraalClassLoader
93 94
94 _jdkDeployedDists = [ 95 _jdkDeployedDists = [
95 JDKDeployedDist('TRUFFLE', isExtension=False), 96 JDKDeployedDist('TRUFFLE'),
96 JDKDeployedDist('GRAAL_LOADER', isExtension=False), 97 JDKDeployedDist('GRAAL_LOADER'),
97 JDKDeployedDist('GRAAL', isExtension=False), 98 JDKDeployedDist('GRAAL', isGraalClassLoader=True),
98 JDKDeployedDist('GRAAL_TRUFFLE', isExtension=False) 99 JDKDeployedDist('GRAAL_TRUFFLE', isGraalClassLoader=True)
99 ] 100 ]
100 101
101 JDK_UNIX_PERMISSIONS_DIR = 0755 102 JDK_UNIX_PERMISSIONS_DIR = 0755
102 JDK_UNIX_PERMISSIONS_FILE = 0644 103 JDK_UNIX_PERMISSIONS_FILE = 0644
103 JDK_UNIX_PERMISSIONS_EXEC = 0755 104 JDK_UNIX_PERMISSIONS_EXEC = 0755
481 482
482 if installJars: 483 if installJars:
483 for jdkDist in _jdkDeployedDists: 484 for jdkDist in _jdkDeployedDists:
484 dist = mx.distribution(jdkDist.name) 485 dist = mx.distribution(jdkDist.name)
485 if exists(dist.path): 486 if exists(dist.path):
486 _installDistInJdks(dist, jdkDist.isExtension) 487 _installDistInJdks(jdkDist)
487 488
488 if vmToCheck is not None: 489 if vmToCheck is not None:
489 jvmCfg = _vmCfgInJdk(jdk) 490 jvmCfg = _vmCfgInJdk(jdk)
490 found = False 491 found = False
491 with open(jvmCfg) as f: 492 with open(jvmCfg) as f:
591 shutil.copyfile(src, tmp) 592 shutil.copyfile(src, tmp)
592 os.close(fd) 593 os.close(fd)
593 shutil.move(tmp, dstLib) 594 shutil.move(tmp, dstLib)
594 os.chmod(dstLib, permissions) 595 os.chmod(dstLib, permissions)
595 596
596 def _installDistInJdksExt(dist): 597 def _installDistInJdks(deployableDist):
597 _installDistInJdks(dist, True)
598
599 def _installDistInJdks(dist, ext=False):
600 """ 598 """
601 Installs the jar(s) for a given Distribution into all existing Graal JDKs 599 Installs the jar(s) for a given Distribution into all existing Graal JDKs
602 """ 600 """
601
602 dist = mx.distribution(deployableDist.name)
603 603
604 if dist.name == 'GRAAL_TRUFFLE': 604 if dist.name == 'GRAAL_TRUFFLE':
605 # The content in graalRuntime.inline.hpp is generated from Graal 605 # The content in graalRuntime.inline.hpp is generated from Graal
606 # classes that implement com.oracle.graal.api.runtime.Service 606 # classes that implement com.oracle.graal.api.runtime.Service
607 # or contain com.oracle.graal.options.Option annotated fields. 607 # or contain com.oracle.graal.options.Option annotated fields.
612 jdks = _jdksDir() 612 jdks = _jdksDir()
613 613
614 if exists(jdks): 614 if exists(jdks):
615 for e in os.listdir(jdks): 615 for e in os.listdir(jdks):
616 jreLibDir = join(jdks, e, 'jre', 'lib') 616 jreLibDir = join(jdks, e, 'jre', 'lib')
617 if ext: 617 if deployableDist.isExtension:
618 jreLibDir = join(jreLibDir, 'ext') 618 jreLibDir = join(jreLibDir, 'ext')
619 if exists(jreLibDir): 619 if exists(jreLibDir):
620 _copyToJdk(dist.path, jreLibDir) 620 _copyToJdk(dist.path, jreLibDir)
621 if dist.sourcesPath: 621 if dist.sourcesPath:
622 _copyToJdk(dist.sourcesPath, join(jdks, e)) 622 _copyToJdk(dist.sourcesPath, join(jdks, e))
623 if deployableDist.isGraalClassLoader:
624 assert not deployableDist.isExtension
625 # deploy services files
626 jreGraalServicesDir = join(jreLibDir, 'graal', 'services')
627 if not exists(jreGraalServicesDir):
628 os.makedirs(jreGraalServicesDir)
629 with zipfile.ZipFile(dist.path) as zf:
630 for member in zf.namelist():
631 if not member.startswith('META-INF/services'):
632 continue
633 serviceName = basename(member)
634 # we don't handle directories
635 assert serviceName
636 target = join(jreGraalServicesDir, serviceName)
637 with zf.open(member) as serviceFile, open(target, "w+") as targetFile:
638 shutil.copyfileobj(serviceFile, targetFile)
623 639
624 # run a command in the windows SDK Debug Shell 640 # run a command in the windows SDK Debug Shell
625 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None): 641 def _runInDebugShell(cmd, workingDir, logFile=None, findInOutput=None, respondTo=None):
626 if respondTo is None: 642 if respondTo is None:
627 respondTo = {} 643 respondTo = {}
2554 _installed_jdks = opts.installed_jdks 2570 _installed_jdks = opts.installed_jdks
2555 global _vm_prefix 2571 global _vm_prefix
2556 _vm_prefix = opts.vm_prefix 2572 _vm_prefix = opts.vm_prefix
2557 2573
2558 for jdkDist in _jdkDeployedDists: 2574 for jdkDist in _jdkDeployedDists:
2559 if jdkDist.isExtension: 2575 def _close(jdkDeployable):
2560 mx.distribution(jdkDist.name).add_update_listener(_installDistInJdksExt) 2576 def _install(dist):
2561 else: 2577 mx.log("install " + dist.name)
2562 mx.distribution(jdkDist.name).add_update_listener(_installDistInJdks) 2578 assert dist.name == jdkDeployable.name, dist.name + "!=" + jdkDeployable.name
2579 _installDistInJdks(jdkDeployable)
2580 return _install
2581 mx.distribution(jdkDist.name).add_update_listener(_close(jdkDist))