Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 21693:dd987b035a0b
fix bug where computed graal.version value is longer than the placeholder value
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Wed, 03 Jun 2015 13:47:47 +0200 |
parents | 8d0c2aabfc2d |
children | 729e6acde6c0 |
comparison
equal
deleted
inserted
replaced
21692:c8418635b575 | 21693:dd987b035a0b |
---|---|
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) |