comparison mx/commands.py @ 11371:74414b248381

mx: added --vmbuild global option, removed --product, --fastdebug, --debug options as well as suffix of build command
author Doug Simon <doug.simon@oracle.com>
date Tue, 20 Aug 2013 12:09:45 +0200
parents c64d90e962ed
children 76c45fb64191
comparison
equal deleted inserted replaced
11370:ece2cee9f85f 11371:74414b248381
58 58
59 """ The VM builds that will be run by the 'vm' command - default is first in list """ 59 """ The VM builds that will be run by the 'vm' command - default is first in list """
60 _vmbuildChoices = ['product', 'fastdebug', 'debug', 'optimized'] 60 _vmbuildChoices = ['product', 'fastdebug', 'debug', 'optimized']
61 61
62 """ The VM build that will be run by the 'vm' command. 62 """ The VM build that will be run by the 'vm' command.
63 This can be set via the global '--product', '--fastdebug' and '--debug' options. 63 This can be set via the global '--vmbuild' option.
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
159 args = parser.parse_args(args) 159 args = parser.parse_args(args)
160 160
161 tmp = tempfile.mkdtemp(prefix='tmp', dir=_graal_home) 161 tmp = tempfile.mkdtemp(prefix='tmp', dir=_graal_home)
162 if args.vmbuild: 162 if args.vmbuild:
163 # Make sure the product VM binary is up to date 163 # Make sure the product VM binary is up to date
164 build(['product']) 164 with VM(vmbuild='product'):
165 build([])
165 166
166 mx.log('Copying Java sources and mx files...') 167 mx.log('Copying Java sources and mx files...')
167 mx.run(('hg archive -I graal -I mx -I mxtool -I mx.sh ' + tmp).split()) 168 mx.run(('hg archive -I graal -I mx -I mxtool -I mx.sh ' + tmp).split())
168 169
169 # Copy the GraalVM JDK 170 # Copy the GraalVM JDK
277 def _handle_missing_VM(bld, vm): 278 def _handle_missing_VM(bld, vm):
278 mx.log('The ' + bld + ' ' + vm + ' VM has not been created') 279 mx.log('The ' + bld + ' ' + vm + ' VM has not been created')
279 if sys.stdout.isatty(): 280 if sys.stdout.isatty():
280 answer = raw_input('Build it now? [Yn]: ') 281 answer = raw_input('Build it now? [Yn]: ')
281 if not answer.lower().startswith('n'): 282 if not answer.lower().startswith('n'):
282 build([bld], vm=vm) 283 with VM(vm, bld):
284 build([])
283 return 285 return
284 mx.abort('You need to run "mx --vm ' + vm + ' build ' + bld + '" to build the selected VM') 286 mx.abort('You need to run "mx --vm ' + vm + ' build ' + bld + '" to build the selected VM')
285 287
286 def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=True): 288 def _jdk(build='product', vmToCheck=None, create=False, installGraalJar=True):
287 """ 289 """
462 mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').') 464 mx.log('Note that these variables can be given persistent values in the file ' + join(_graal_home, 'mx', 'env') + ' (see \'mx about\').')
463 465
464 def build(args, vm=None): 466 def build(args, vm=None):
465 """build the VM binary 467 """build the VM binary
466 468
467 The global '--vm' option selects which VM to build. This command also 469 The global '--vm' and '--vmbuild' options select which VM type and build to build."""
468 compiles the Graal classes irrespective of what VM is being built.
469 The optional last argument specifies what build level is to be used
470 for the VM binary."""
471 470
472 # Call mx.build to compile the Java sources 471 # Call mx.build to compile the Java sources
473 parser=ArgumentParser(prog='mx build') 472 parser=ArgumentParser(prog='mx build')
474 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') 473 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>')
475 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') 474 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value')
487 shutil.copy(graalOptions, opts2.export_dir) 486 shutil.copy(graalOptions, opts2.export_dir)
488 487
489 if not _vmSourcesAvailable or not opts2.native: 488 if not _vmSourcesAvailable or not opts2.native:
490 return 489 return
491 490
492 builds = opts2.remainder 491 if len(opts2.remainder) != 0:
493 if len(builds) == 0: 492 mx.abort('specify ' + opts2.remainder[0] + ' build with the global option "--vmbuild ' + opts2.remainder[0] + '"')
494 builds = ['product'] 493
494 builds = [_vmbuild]
495 495
496 if vm is None: 496 if vm is None:
497 vm = _get_vm() 497 vm = _get_vm()
498 498
499 if vm == 'original': 499 if vm == 'original':
878 logFile = join(v + '-' + vmbuild + '.log') 878 logFile = join(v + '-' + vmbuild + '.log')
879 log = open(join(_graal_home, logFile), 'wb') 879 log = open(join(_graal_home, logFile), 'wb')
880 start = time.time() 880 start = time.time()
881 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')') 881 mx.log('BEGIN: ' + v + '-' + vmbuild + '\t(see: ' + logFile + ')')
882 # Run as subprocess so that output can be directed to a file 882 # Run as subprocess so that output can be directed to a file
883 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, 'build', vmbuild], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT) 883 subprocess.check_call([sys.executable, '-u', join('mxtool', 'mx.py'), '--vm', v, '--vmbuild', vmbuild, 'build'], cwd=_graal_home, stdout=log, stderr=subprocess.STDOUT)
884 duration = datetime.timedelta(seconds=time.time() - start) 884 duration = datetime.timedelta(seconds=time.time() - start)
885 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']') 885 mx.log('END: ' + v + '-' + vmbuild + '\t[' + str(duration) + ']')
886 else: 886 else:
887 with VM(v): 887 with VM(v, vmbuild):
888 build([vmbuild]) 888 build([])
889 if not args.no_check: 889 if not args.no_check:
890 vmargs = ['-version'] 890 vmargs = ['-version']
891 if v == 'graal': 891 if v == 'graal':
892 vmargs.insert(0, '-XX:-BootstrapGraal') 892 vmargs.insert(0, '-XX:-BootstrapGraal')
893 vm(vmargs, vm=v, vmbuild=vmbuild) 893 vm(vmargs, vm=v, vmbuild=vmbuild)
1298 '--title', 'Graal OpenJDK Project Documentation', 1298 '--title', 'Graal OpenJDK Project Documentation',
1299 '--dot-output-base', 'projects'] + args) 1299 '--dot-output-base', 'projects'] + args)
1300 1300
1301 def mx_init(): 1301 def mx_init():
1302 commands = { 1302 commands = {
1303 'build': [build, '[-options]'], 1303 'build': [build, ''],
1304 'buildvars': [buildvars, ''], 1304 'buildvars': [buildvars, ''],
1305 'buildvms': [buildvms, '[-options]'], 1305 'buildvms': [buildvms, '[-options]'],
1306 'clean': [clean, ''], 1306 'clean': [clean, ''],
1307 'hsdis': [hsdis, '[att]'], 1307 'hsdis': [hsdis, '[att]'],
1308 'hcfdis': [hcfdis, ''], 1308 'hcfdis': [hcfdis, ''],
1331 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append']) 1331 mx.add_argument('--jacoco', help='instruments com.oracle.* classes using JaCoCo', default='off', choices=['off', 'on', 'append'])
1332 mx.add_argument('--workdir', help='runs the VM in the given directory', default=None) 1332 mx.add_argument('--workdir', help='runs the VM in the given directory', default=None)
1333 mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None) 1333 mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None)
1334 1334
1335 if (_vmSourcesAvailable): 1335 if (_vmSourcesAvailable):
1336 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM to build/run') 1336 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run')
1337 for c in _vmbuildChoices: 1337 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run')
1338 mx.add_argument('--' + c, action='store_const', dest='vmbuild', const=c, help='select the ' + c + ' build of the VM')
1339 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') 1338 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse')
1340 mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>') 1339 mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>')
1341 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args') 1340 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args')
1342 1341
1343 commands.update({ 1342 commands.update({
1344 'export': [export, '[-options] [zipfile]'], 1343 'export': [export, '[-options] [zipfile]'],
1345 'build': [build, '[-options] [' + '|'.join(_vmbuildChoices) + ']...']
1346 }) 1344 })
1347 1345
1348 mx.commands.update(commands) 1346 mx.commands.update(commands)
1349 1347
1350 def mx_post_parse_cmd_line(opts):# 1348 def mx_post_parse_cmd_line(opts):#