Mercurial > hg > truffle
comparison mx/mx_graal.py @ 15820:f0127716b881
mx: remove unused packagejar command
author | Bernhard Urban <bernhard.urban@jku.at> |
---|---|
date | Wed, 21 May 2014 15:29:38 +0200 |
parents | 2460aed6c899 |
children | d1822a8fe26f |
comparison
equal
deleted
inserted
replaced
15819:2460aed6c899 | 15820:f0127716b881 |
---|---|
2091 _installed_jdks = opts.installed_jdks | 2091 _installed_jdks = opts.installed_jdks |
2092 global _vm_prefix | 2092 global _vm_prefix |
2093 _vm_prefix = opts.vm_prefix | 2093 _vm_prefix = opts.vm_prefix |
2094 | 2094 |
2095 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) | 2095 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) |
2096 | |
2097 def packagejar(classpath, outputFile, mainClass=None, annotationProcessor=None, stripDebug=False): | |
2098 prefix = '' if mx.get_os() != 'windows' else '\\??\\' # long file name hack | |
2099 print "creating", outputFile | |
2100 filecount, totalsize = 0, 0 | |
2101 with zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED) as zf: | |
2102 manifest = "Manifest-Version: 1.0\n" | |
2103 if mainClass != None: | |
2104 manifest += "Main-Class: %s\n\n" % (mainClass) | |
2105 zf.writestr("META-INF/MANIFEST.MF", manifest) | |
2106 if annotationProcessor != None: | |
2107 zf.writestr("META-INF/services/javax.annotation.processing.Processor", annotationProcessor) | |
2108 for cp in classpath: | |
2109 print "+", cp | |
2110 if cp.endswith(".jar"): | |
2111 with zipfile.ZipFile(cp, 'r') as jar: | |
2112 for arcname in jar.namelist(): | |
2113 if arcname.endswith('/') or arcname == 'META-INF/MANIFEST.MF' or arcname.endswith('.java') or arcname.lower().startswith("license") or arcname in [".project", ".classpath"]: | |
2114 continue | |
2115 zf.writestr(arcname, jar.read(arcname)) | |
2116 else: | |
2117 for root, _, files in os.walk(cp): | |
2118 for f in files: | |
2119 fullname = os.path.join(root, f) | |
2120 arcname = fullname[len(cp) + 1:].replace('\\', '/') | |
2121 if f.endswith(".class"): | |
2122 zf.write(prefix + fullname, arcname) | |
2123 | |
2124 for zi in zf.infolist(): | |
2125 filecount += 1 | |
2126 totalsize += zi.file_size | |
2127 print "%d files (total size: %.2f kB, jar size: %.2f kB)" % (filecount, totalsize / 1e3, os.path.getsize(outputFile) / 1e3) | |
2128 mx.run([mx.exe_suffix(join(mx.java().jdk, 'bin', 'pack200')), '-r'] + (['-G'] if stripDebug else []) + [outputFile]) | |
2129 print "repacked jar size: %.2f kB" % (os.path.getsize(outputFile) / 1e3) |