comparison mx/commands.py @ 11407:821ed0a436f2

Merge.
author Doug Simon <doug.simon@oracle.com>
date Fri, 23 Aug 2013 17:18:47 +0200
parents e45b540b0ef2 2d228d304247
children c355f6b32fa6
comparison
equal deleted inserted replaced
11406:1688781c0238 11407:821ed0a436f2
64 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """ 64 It can also be temporarily set by using of a VM context manager object in a 'with' statement. """
65 _vmbuild = _vmbuildChoices[0] 65 _vmbuild = _vmbuildChoices[0]
66 66
67 _jacoco = 'off' 67 _jacoco = 'off'
68 68
69 _workdir = None 69 """ The current working directory to switch to before running the VM. """
70 70 _vm_cwd = None
71 _vmdir = None 71
72 72 """ The base directory in which the JDKs cloned from $JAVA_HOME exist. """
73 _native_dbg = None 73 _installed_jdks = None
74
75 """ Prefix for running the VM. """
76 _vm_prefix = None
74 77
75 _make_eclipse_launch = False 78 _make_eclipse_launch = False
76 79
77 _minVersion = mx.JavaVersion('1.7.0_04') 80 _minVersion = mx.JavaVersion('1.7.0_04')
78 81
271 if platform.system() == 'Windows': 274 if platform.system() == 'Windows':
272 return join(jdk, 'jre', 'lib', _arch(), 'jvm.cfg') 275 return join(jdk, 'jre', 'lib', _arch(), 'jvm.cfg')
273 return join(_vmLibDirInJdk(jdk), 'jvm.cfg') 276 return join(_vmLibDirInJdk(jdk), 'jvm.cfg')
274 277
275 def _jdksDir(): 278 def _jdksDir():
276 return os.path.abspath(join(_vmdir if _vmdir else _graal_home, 'jdk' + str(mx.java().version))) 279 return os.path.abspath(join(_installed_jdks if _installed_jdks else _graal_home, 'jdk' + str(mx.java().version)))
277 280
278 def _handle_missing_VM(bld, vm): 281 def _handle_missing_VM(bld, vm):
279 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') 282 mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
280 if sys.stdout.isatty(): 283 if sys.stdout.isatty():
281 answer = raw_input('Build it now? [Yn]: ') 284 answer = raw_input('Build it now? [Yn]: ')
342 hsdis([], copyToDir=_vmLibDirInJdk(jdk)) 345 hsdis([], copyToDir=_vmLibDirInJdk(jdk))
343 except SystemExit: 346 except SystemExit:
344 pass 347 pass
345 else: 348 else:
346 if not exists(jdk): 349 if not exists(jdk):
347 if _vmdir and mx._opts.verbose: 350 if _installed_jdks and mx._opts.verbose:
348 mx.log("Cound not find jdk dir at " + jdk) 351 mx.log("Could not find JDK directory at " + jdk)
349 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal') 352 _handle_missing_VM(build, vmToCheck if vmToCheck else 'graal')
350 353
351 if installGraalJar: 354 if installGraalJar:
352 _installGraalJarInJdks(mx.distribution('GRAAL')) 355 _installGraalJarInJdks(mx.distribution('GRAAL'))
353 356
674 677
675 if vm is None: 678 if vm is None:
676 vm = _get_vm() 679 vm = _get_vm()
677 680
678 if cwd is None: 681 if cwd is None:
679 cwd = _workdir 682 cwd = _vm_cwd
680 elif _workdir is not None: 683 elif _vm_cwd != cwd:
681 mx.abort("conflicting working directories: do not set --workdir for this command") 684 mx.abort("conflicting working directories: do not set --vmcwd for this command")
682 685
683 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product' 686 build = vmbuild if vmbuild is not None else _vmbuild if _vmSourcesAvailable else 'product'
684 jdk = _jdk(build, vmToCheck=vm, installGraalJar=False) 687 jdk = _jdk(build, vmToCheck=vm, installGraalJar=False)
685 mx.expand_project_in_args(args) 688 mx.expand_project_in_args(args)
686 if _make_eclipse_launch: 689 if _make_eclipse_launch:
708 args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args 711 args = ['-javaagent:' + jacocoagent.get_path(True) + '=' + ','.join([k + '=' + v for k, v in agentOptions.items()])] + args
709 if '-d64' not in args: 712 if '-d64' not in args:
710 args = ['-d64'] + args 713 args = ['-d64'] + args
711 714
712 exe = join(jdk, 'bin', mx.exe_suffix('java')) 715 exe = join(jdk, 'bin', mx.exe_suffix('java'))
713 dbg = _native_dbg.split() if _native_dbg is not None else [] 716 pfx = _vm_prefix.split() if _vm_prefix is not None else []
714 717
715 if '-version' in args: 718 if '-version' in args:
716 ignoredArgs = args[args.index('-version')+1:] 719 ignoredArgs = args[args.index('-version')+1:]
717 if len(ignoredArgs) > 0: 720 if len(ignoredArgs) > 0:
718 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs)) 721 mx.log("Warning: The following options will be ignored by the vm because they come after the '-version' argument: " + ' '.join(ignoredArgs))
719 722
720 return mx.run(dbg + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout) 723 return mx.run(pfx + [exe, '-' + vm] + args, nonZeroIsFatal=nonZeroIsFatal, out=out, err=err, cwd=cwd, timeout=timeout)
721 724
722 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False): 725 def _find_classes_with_annotations(p, pkgRoot, annotations, includeInnerClasses=False):
723 """ 726 """
724 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation' 727 Scan the sources of project 'p' for Java source files containing a line starting with 'annotation'
725 (ignoring preceding whitespace) and return the fully qualified class name for each Java 728 (ignoring preceding whitespace) and return the fully qualified class name for each Java
1234 This is needed to support HotSpot's assembly dumping features. 1237 This is needed to support HotSpot's assembly dumping features.
1235 By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax.""" 1238 By default it downloads the Intel syntax version, use the 'att' argument to install AT&T syntax."""
1236 flavor = 'intel' 1239 flavor = 'intel'
1237 if 'att' in args: 1240 if 'att' in args:
1238 flavor = 'att' 1241 flavor = 'att'
1239 lib = mx.lib_suffix('hsdis-' + _arch()) 1242 lib = mx.add_lib_suffix('hsdis-' + _arch())
1240 path = join(_graal_home, 'lib', lib) 1243 path = join(_graal_home, 'lib', lib)
1241 if not exists(path): 1244 if not exists(path):
1242 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavor + "/" + lib]) 1245 mx.download(path, ['http://lafo.ssw.uni-linz.ac.at/hsdis/' + flavor + "/" + lib])
1243 if copyToDir is not None and exists(copyToDir): 1246 if copyToDir is not None and exists(copyToDir):
1244 shutil.copy(path, copyToDir) 1247 shutil.copy(path, copyToDir)
1350 'deoptalot' : [deoptalot, '[n]'], 1353 'deoptalot' : [deoptalot, '[n]'],
1351 'longtests' : [longtests, ''] 1354 'longtests' : [longtests, '']
1352 } 1355 }
1353 1356
1354 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append']) 1357 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])
1355 mx.add_argument('--workdir', help='runs the VM in the given directory', default=None) 1358 mx.add_argument('--vmcwd', dest='vm_cwd', help='current directory will be changed to <path> before the VM is executed', default=None, metavar='<path>')
1356 mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None) 1359 mx.add_argument('--installed-jdks', help='the base directory in which the JDKs cloned from $JAVA_HOME exist. ' +
1360 'The VM selected by --vm and --vmbuild options is under this directory (i.e., ' +
1361 join('<path>', '<vmbuild>', 'jre', 'lib', '<vm>', mx.add_lib_prefix(mx.add_lib_suffix('jvm'))) + ')', default=None, metavar='<path>')
1357 1362
1358 if (_vmSourcesAvailable): 1363 if (_vmSourcesAvailable):
1359 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run') 1364 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run')
1360 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] +')') 1365 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] +')')
1361 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') 1366 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
1362 mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>') 1367 mx.add_argument('--vmprefix', action='store', dest='vm_prefix', help='prefix for running the VM (e.g. "/usr/bin/gdb --args")', metavar='<prefix>')
1363 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args') 1368 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='vm_prefix', help='alias for --vmprefix "/usr/bin/gdb --args"')
1364 1369
1365 commands.update({ 1370 commands.update({
1366 'export': [export, '[-options] [zipfile]'], 1371 'export': [export, '[-options] [zipfile]'],
1367 }) 1372 })
1368 1373
1382 _vmbuild = opts.vmbuild 1387 _vmbuild = opts.vmbuild
1383 global _make_eclipse_launch 1388 global _make_eclipse_launch
1384 _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False) 1389 _make_eclipse_launch = getattr(opts, 'make_eclipse_launch', False)
1385 global _jacoco 1390 global _jacoco
1386 _jacoco = opts.jacoco 1391 _jacoco = opts.jacoco
1387 global _workdir 1392 global _vm_cwd
1388 _workdir = opts.workdir 1393 _vm_cwd = opts.vm_cwd
1389 global _vmdir 1394 global _installed_jdks
1390 _vmdir = opts.vmdir 1395 _installed_jdks = opts.installed_jdks
1391 global _native_dbg 1396 global _vm_prefix
1392 _native_dbg = opts.native_dbg 1397 _vm_prefix = opts.vm_prefix
1393 1398
1394 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks) 1399 mx.distribution('GRAAL').add_update_listener(_installGraalJarInJdks)