Mercurial > hg > truffle
comparison mx/mx_graal.py @ 21697:696baf53a985
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 14:15:42 +0200 |
parents | dd987b035a0b |
children | 729e6acde6c0 |
comparison
equal
deleted
inserted
replaced
21696:ca140f8c35be | 21697:696baf53a985 |
---|---|
618 jreJVMCIOptionsDir = join(jreJVMCIDir, 'options') | 618 jreJVMCIOptionsDir = join(jreJVMCIDir, 'options') |
619 _extractJVMCIFiles(_getJdkDeployedJars(jdkDir), jvmciJars, jreJVMCIServicesDir, jreJVMCIOptionsDir) | 619 _extractJVMCIFiles(_getJdkDeployedJars(jdkDir), jvmciJars, jreJVMCIServicesDir, jreJVMCIOptionsDir) |
620 | 620 |
621 def _patchGraalVersionConstant(dist): | 621 def _patchGraalVersionConstant(dist): |
622 """ | 622 """ |
623 Patches the constant "@@graal.version@@" in the constant pool of Graal.class | 623 Patches the constant "@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@" in the constant pool of Graal.class |
624 with the computed Graal version string. | 624 with the computed Graal version string. |
625 """ | 625 """ |
626 zf = zipfile.ZipFile(dist.path, 'r') | 626 zf = zipfile.ZipFile(dist.path, 'r') |
627 graalClassfilePath = 'com/oracle/graal/api/runtime/Graal.class' | 627 graalClassfilePath = 'com/oracle/graal/api/runtime/Graal.class' |
628 graalClassfile = zf.read(graalClassfilePath) | 628 graalClassfile = zf.read(graalClassfilePath) |
629 versionSpec = '{:' + str(len('@@graal.version@@')) + '}' | 629 placeholder = '@@@@@@@@@@@@@@@@graal.version@@@@@@@@@@@@@@@@' |
630 placeholderLen = len(placeholder) | |
631 versionSpec = '{:' + str(placeholderLen) + '}' | |
630 versionStr = versionSpec.format(graal_version()) | 632 versionStr = versionSpec.format(graal_version()) |
631 if '@@graal.version@@' not in graalClassfile: | 633 |
632 assert versionStr in graalClassfile, 'could not find "@@graal.version@@" or "' + versionStr + '" constant in ' + dist.path + '!' + graalClassfilePath | 634 if len(versionStr) > placeholderLen: |
635 # Truncate the version string if necessary | |
636 assert versionStr.startswith('unknown'), versionStr | |
637 versionStr = versionStr[:placeholderLen] | |
638 if placeholder not in graalClassfile: | |
639 assert versionStr in graalClassfile, 'could not find "' + placeholder + '" or "' + versionStr + '" constant in ' + dist.path + '!' + graalClassfilePath | |
633 zf.close() | 640 zf.close() |
634 return False | 641 return False |
635 | 642 |
636 zfOutFd, zfOutPath = tempfile.mkstemp(suffix='', prefix=basename(dist.path) + '.', dir=dirname(dist.path)) | 643 zfOutFd, zfOutPath = tempfile.mkstemp(suffix='', prefix=basename(dist.path) + '.', dir=dirname(dist.path)) |
637 zfOut = zipfile.ZipFile(zfOutPath, 'w') | 644 zfOut = zipfile.ZipFile(zfOutPath, 'w') |
638 for zi in zf.infolist(): | 645 for zi in zf.infolist(): |
639 if zi.filename == graalClassfilePath: | 646 if zi.filename == graalClassfilePath: |
640 data = graalClassfile.replace('@@graal.version@@', versionStr) | 647 data = graalClassfile.replace(placeholder, versionStr) |
641 else: | 648 else: |
642 data = zf.read(zi) | 649 data = zf.read(zi) |
643 zfOut.writestr(zi, data) | 650 zfOut.writestr(zi, data) |
644 zfOut.close() | 651 zfOut.close() |
645 os.close(zfOutFd) | 652 os.close(zfOutFd) |