comparison mx/mx_graal.py @ 16327:5f01f7c48d40

Merge with 5cdcb94a7cf7d9782107cc582f3e4b50000d5d1f
author Stefan Anzinger <stefan.anzinger@gmail.com>
date Mon, 30 Jun 2014 12:02:19 +0200
parents e497100e1fbf bf0e3ff4b2c4
children d91fecb90fc0
comparison
equal deleted inserted replaced
16326:51f392557124 16327:5f01f7c48d40
166 os.unlink(name) 166 os.unlink(name)
167 167
168 rmIfExists(join(_graal_home, 'build')) 168 rmIfExists(join(_graal_home, 'build'))
169 rmIfExists(join(_graal_home, 'build-nograal')) 169 rmIfExists(join(_graal_home, 'build-nograal'))
170 rmIfExists(_jdksDir()) 170 rmIfExists(_jdksDir())
171 rmIfExists(mx.distribution('GRAAL').path)
172 171
173 def export(args): 172 def export(args):
174 """create archives of builds split by vmbuild and vm""" 173 """create archives of builds split by vmbuild and vm"""
175 174
176 parser = ArgumentParser(prog='mx export') 175 parser = ArgumentParser(prog='mx export')
504 if exists(jdks): 503 if exists(jdks):
505 for e in os.listdir(jdks): 504 for e in os.listdir(jdks):
506 jreLibDir = join(jdks, e, 'jre', 'lib') 505 jreLibDir = join(jdks, e, 'jre', 'lib')
507 if exists(jreLibDir): 506 if exists(jreLibDir):
508 def install(srcJar, dstDir): 507 def install(srcJar, dstDir):
509 # do a copy and then a move to get atomic updating (on Unix)
510 name = os.path.basename(srcJar) 508 name = os.path.basename(srcJar)
511 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir)
512 shutil.copyfile(srcJar, tmp)
513 os.close(fd)
514 dstJar = join(dstDir, name) 509 dstJar = join(dstDir, name)
515 shutil.move(tmp, dstJar) 510 if mx.get_env('SYMLINK_GRAAL_JAR', None) == 'true':
516 os.chmod(dstJar, JDK_UNIX_PERMISSIONS) 511 # Using symlinks is much faster than copying but may
512 # cause issues if graal.jar is being updated while
513 # the VM is running.
514 if not os.path.islink(dstJar) or not os.path.realpath(dstJar) == srcJar:
515 if exists(dstJar):
516 os.remove(dstJar)
517 os.symlink(srcJar, dstJar)
518 else:
519 # do a copy and then a move to get atomic updating (on Unix)
520 fd, tmp = tempfile.mkstemp(suffix='', prefix=name, dir=dstDir)
521 shutil.copyfile(srcJar, tmp)
522 os.close(fd)
523 shutil.move(tmp, dstJar)
524 os.chmod(dstJar, JDK_UNIX_PERMISSIONS)
517 525
518 install(graalJar, jreLibDir) 526 install(graalJar, jreLibDir)
519 if graalDist.sourcesPath: 527 if graalDist.sourcesPath:
520 install(graalDist.sourcesPath, join(jdks, e)) 528 install(graalDist.sourcesPath, join(jdks, e))
521 529
800 808
801 # Clear these 2 variables as having them set can cause very confusing build problems 809 # Clear these 2 variables as having them set can cause very confusing build problems
802 env.pop('LD_LIBRARY_PATH', None) 810 env.pop('LD_LIBRARY_PATH', None)
803 env.pop('CLASSPATH', None) 811 env.pop('CLASSPATH', None)
804 812
805 if mx._opts.verbose: 813 # Issue an env prefix that can be used to run the make on the command line
806 # Issue an env prefix that can be used to run the make on the command line 814 if not mx._opts.verbose:
807 envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]]) 815 mx.log('--------------- make command line ----------------------')
808 if len(envPrefix): 816
809 mx.log('env ' + envPrefix + ' \\') 817 envPrefix = ' '.join([key + '=' + env[key] for key in env.iterkeys() if not os.environ.has_key(key) or env[key] != os.environ[key]])
818 if len(envPrefix):
819 mx.log('env ' + envPrefix + ' \\')
810 820
811 runCmd.append(build + buildSuffix) 821 runCmd.append(build + buildSuffix)
822
823 if not mx._opts.verbose:
824 mx.log(' '.join(runCmd))
825 mx.log('--------------------------------------------------------')
812 mx.run(runCmd, err=filterXusage, env=env) 826 mx.run(runCmd, err=filterXusage, env=env)
813 827
814 jvmCfg = _vmCfgInJdk(jdk) 828 jvmCfg = _vmCfgInJdk(jdk)
815 if not exists(jvmCfg): 829 if not exists(jvmCfg):
816 mx.abort(jvmCfg + ' does not exist') 830 mx.abort(jvmCfg + ' does not exist')
1796 1810
1797 args = parser.parse_args(args) 1811 args = parser.parse_args(args)
1798 1812
1799 path = join(_graal_home, 'lib', 'hcfdis-1.jar') 1813 path = join(_graal_home, 'lib', 'hcfdis-1.jar')
1800 if not exists(path): 1814 if not exists(path):
1801 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-1.jar']) 1815 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hcfdis-2.jar'])
1802 mx.run_java(['-jar', path] + args.files) 1816 mx.run_java(['-jar', path] + args.files)
1803 1817
1804 if args.map is not None: 1818 if args.map is not None:
1805 addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)') 1819 addressRE = re.compile(r'0[xX]([A-Fa-f0-9]+)')
1806 with open(args.map) as fp: 1820 with open(args.map) as fp:
1851 vmArgs, slArgs = _extract_VM_args(args) 1865 vmArgs, slArgs = _extract_VM_args(args)
1852 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl"), "com.oracle.truffle.sl.SLMain"] + slArgs) 1866 vm(vmArgs + ['-cp', mx.classpath("com.oracle.truffle.sl"), "com.oracle.truffle.sl.SLMain"] + slArgs)
1853 1867
1854 def isGraalEnabled(vm): 1868 def isGraalEnabled(vm):
1855 return vm != 'original' and not vm.endswith('nograal') 1869 return vm != 'original' and not vm.endswith('nograal')
1870
1871 def jol(args):
1872 """Java Object Layout"""
1873 jolurl = "http://lafo.ssw.uni-linz.ac.at/truffle/jol/jol-internals.jar"
1874 joljar = "lib/jol-internals.jar"
1875 if not exists(joljar):
1876 mx.download(joljar, [jolurl])
1877
1878 candidates = mx.findclass(args, logToConsole=False, matcher=lambda s, classname: s == classname or classname.endswith('.' + s) or classname.endswith('$' + s))
1879 if len(candidates) > 10:
1880 print "Found %d candidates. Please be more precise." % (len(candidates))
1881 return
1882
1883 vm(['-javaagent:' + joljar, '-cp', os.pathsep.join([mx.classpath(), joljar]), "org.openjdk.jol.MainObjectInternals"] + candidates)
1856 1884
1857 def site(args): 1885 def site(args):
1858 """create a website containing javadoc and the project dependency graph""" 1886 """create a website containing javadoc and the project dependency graph"""
1859 1887
1860 return mx.site(['--name', 'Graal', 1888 return mx.site(['--name', 'Graal',
2078 'vm': [vm, '[-options] class [args...]'], 2106 'vm': [vm, '[-options] class [args...]'],
2079 'vmg': [vmg, '[-options] class [args...]'], 2107 'vmg': [vmg, '[-options] class [args...]'],
2080 'vmfg': [vmfg, '[-options] class [args...]'], 2108 'vmfg': [vmfg, '[-options] class [args...]'],
2081 'deoptalot' : [deoptalot, '[n]'], 2109 'deoptalot' : [deoptalot, '[n]'],
2082 'longtests' : [longtests, ''], 2110 'longtests' : [longtests, ''],
2083 'sl' : [sl, '[SL args|@VM options]'] 2111 'sl' : [sl, '[SL args|@VM options]'],
2112 'jol' : [jol, ''],
2084 } 2113 }
2085 2114
2086 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append']) 2115 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])
2087 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>') 2116 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>')
2088 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' + 2117 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' +