comparison mx/mx_graal.py @ 18711:88c280297bd2

put GeneratedSourcesSha1 into com.oracle.graal.hotspot.sourcegen package
author Doug Simon <doug.simon@oracle.com>
date Thu, 18 Dec 2014 13:10:23 +1000
parents ae5033a78f1d
children b56e88144e0a
comparison
equal deleted inserted replaced
18710:4836c2abc884 18711:88c280297bd2
546 print >> tmp, 'const char* GraalRuntime::_generated_sources_sha1 = "' + sha1 + '";' 546 print >> tmp, 'const char* GraalRuntime::_generated_sources_sha1 = "' + sha1 + '";'
547 547
548 mx.update_file(graalRuntime_inline_hpp, tmp.getvalue()) 548 mx.update_file(graalRuntime_inline_hpp, tmp.getvalue())
549 549
550 # Store SHA1 in generated Java class and append class to specified jar 550 # Store SHA1 in generated Java class and append class to specified jar
551 javaPackageName = 'com.oracle.graal.hotspot.sourcegen'
552 javaClassName = javaPackageName + '.GeneratedSourcesSha1'
551 javaSource = join(_graal_home, 'GeneratedSourcesSha1.java') 553 javaSource = join(_graal_home, 'GeneratedSourcesSha1.java')
552 javaClass = join(_graal_home, 'GeneratedSourcesSha1.class') 554 javaClass = join(_graal_home, javaClassName.replace('.', os.path.sep) + '.class')
553 with open(javaSource, 'w') as fp: 555 with open(javaSource, 'w') as fp:
556 print >> fp, 'package ' + javaPackageName + ';'
554 print >> fp, 'class GeneratedSourcesSha1 { private static final String value = "' + sha1 + '"; }' 557 print >> fp, 'class GeneratedSourcesSha1 { private static final String value = "' + sha1 + '"; }'
555 subprocess.check_call([mx.java().javac, '-d', mx._cygpathU2W(_graal_home), mx._cygpathU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE) 558 subprocess.check_call([mx.java().javac, '-d', mx._cygpathU2W(_graal_home), mx._cygpathU2W(javaSource)], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
556 zf = zipfile.ZipFile(dist.path, 'a') 559 zf = zipfile.ZipFile(dist.path, 'a')
557 with open(javaClass, 'rb') as fp: 560 with open(javaClass, 'rb') as fp:
558 zf.writestr(os.path.basename(javaClass), fp.read()) 561 zf.writestr(javaClassName.replace('.', '/') + '.class', fp.read())
559 zf.close() 562 zf.close()
560 os.unlink(javaSource) 563 os.unlink(javaSource)
561 os.unlink(javaClass) 564 os.unlink(javaClass)
565 javaClassParent = os.path.dirname(javaClass)
566 while len(os.listdir(javaClassParent)) == 0:
567 os.rmdir(javaClassParent)
568 javaClassParent = os.path.dirname(javaClassParent)
562 569
563 def _copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE): 570 def _copyToJdk(src, dst, permissions=JDK_UNIX_PERMISSIONS_FILE):
564 name = os.path.basename(src) 571 name = os.path.basename(src)
565 dstLib = join(dst, name) 572 dstLib = join(dst, name)
566 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true': 573 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true':