Mercurial > hg > graal-compiler
comparison mx/mx_graal.py @ 15873:6dcf8ab4ad86
HotSpotOptions.inline.hpp generator writes to System.out to make generator errors more visible (they will show up when compiling the generated source)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Sat, 24 May 2014 00:46:33 +0200 |
parents | fe608a56e3f7 |
children | db776f9bea7c |
comparison
equal
deleted
inserted
replaced
15872:b7fc7cdb9005 | 15873:6dcf8ab4ad86 |
---|---|
489 mainClass = 'com.oracle.graal.hotspot.HotSpotOptionsLoader' | 489 mainClass = 'com.oracle.graal.hotspot.HotSpotOptionsLoader' |
490 assert exists(join(p.source_dirs()[0], mainClass.replace('.', os.sep) + '.java')) | 490 assert exists(join(p.source_dirs()[0], mainClass.replace('.', os.sep) + '.java')) |
491 hsSrcGenDir = join(p.source_gen_dir(), 'hotspot') | 491 hsSrcGenDir = join(p.source_gen_dir(), 'hotspot') |
492 if not exists(hsSrcGenDir): | 492 if not exists(hsSrcGenDir): |
493 os.makedirs(hsSrcGenDir) | 493 os.makedirs(hsSrcGenDir) |
494 path = join(hsSrcGenDir, 'HotSpotOptions.inline.hpp') | 494 tmp = StringIO.StringIO() |
495 fd, tmp = tempfile.mkstemp(suffix='', prefix='HotSpotOptions.inline.hpp', dir=hsSrcGenDir) | 495 retcode = mx.run_java(['-cp', graalJar, mainClass], out=tmp.write, nonZeroIsFatal=False) |
496 os.close(fd) | 496 if retcode != 0: |
497 try: | 497 # Suppress the error if it's because the utility class isn't compiled yet |
498 retcode = mx.run_java(['-cp', graalJar, mainClass, tmp], nonZeroIsFatal=False) | 498 with zipfile.ZipFile(graalJar, 'r') as zf: |
499 if retcode != 0: | 499 mainClassFile = mainClass.replace('.', '/') + '.class' |
500 # Suppress the error if it's because the utility class isn't compiled yet | 500 if mainClassFile not in zf.namelist(): |
501 with zipfile.ZipFile(graalJar, 'r') as zf: | 501 return |
502 mainClassFile = mainClass.replace('.', '/') + '.class' | 502 mx.abort(retcode) |
503 if mainClassFile not in zf.namelist(): | 503 mx.update_file(join(hsSrcGenDir, 'HotSpotOptions.inline.hpp'), tmp.getvalue()) |
504 return | |
505 mx.abort(retcode) | |
506 with open(tmp) as fp: | |
507 content = fp.read() | |
508 mx.update_file(path, content) | |
509 finally: | |
510 os.remove(tmp) | |
511 | 504 |
512 def _installGraalJarInJdks(graalDist): | 505 def _installGraalJarInJdks(graalDist): |
513 graalJar = graalDist.path | 506 graalJar = graalDist.path |
514 _update_HotSpotOptions_inline_hpp(graalJar) | 507 _update_HotSpotOptions_inline_hpp(graalJar) |
515 jdks = _jdksDir() | 508 jdks = _jdksDir() |