Mercurial > hg > graal-compiler
comparison mx/commands.py @ 11392:66251d9f62ab
fail faster with better error message if deprecated and unsupported mx build command line is given
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 22 Aug 2013 11:23:42 +0200 |
parents | 0fbc1e418c88 |
children | a8e618fd8868 |
comparison
equal
deleted
inserted
replaced
11391:f34b01673b6a | 11392:66251d9f62ab |
---|---|
464 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\').') |
465 | 465 |
466 def build(args, vm=None): | 466 def build(args, vm=None): |
467 """build the VM binary | 467 """build the VM binary |
468 | 468 |
469 The global '--vm' and '--vmbuild' options select which VM type and build to build.""" | 469 The global '--vm' and '--vmbuild' options select which VM type and build target to build.""" |
470 | |
471 # Override to fail quickly if extra arguments are given | |
472 # at the end of the command line. This allows for a more | |
473 # helpful error message. | |
474 class AP(ArgumentParser): | |
475 def __init__(self): | |
476 ArgumentParser.__init__(self, prog='mx build') | |
477 def parse_args(self, args): | |
478 result = ArgumentParser.parse_args(self, args) | |
479 if len(result.remainder) != 0: | |
480 firstBuildTarget = result.remainder[0] | |
481 mx.abort('To specify the ' + firstBuildTarget + ' VM build target, you need to use the global "--vmbuild" option. For example:\n' + | |
482 ' mx --vmbuild ' + firstBuildTarget + ' build') | |
483 return result | |
470 | 484 |
471 # Call mx.build to compile the Java sources | 485 # Call mx.build to compile the Java sources |
472 parser=ArgumentParser(prog='mx build') | 486 parser=AP() |
473 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') | 487 parser.add_argument('--export-dir', help='directory to which graal.jar and graal.options will be copied', metavar='<path>') |
474 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') | 488 parser.add_argument('-D', action='append', help='set a HotSpot build variable (run \'mx buildvars\' to list variables)', metavar='name=value') |
475 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) | 489 opts2 = mx.build(['--source', '1.7'] + args, parser=parser) |
490 assert len(opts2.remainder) == 0 | |
476 | 491 |
477 if opts2.export_dir is not None: | 492 if opts2.export_dir is not None: |
478 if not exists(opts2.export_dir): | 493 if not exists(opts2.export_dir): |
479 os.makedirs(opts2.export_dir) | 494 os.makedirs(opts2.export_dir) |
480 else: | 495 else: |
485 if exists(graalOptions): | 500 if exists(graalOptions): |
486 shutil.copy(graalOptions, opts2.export_dir) | 501 shutil.copy(graalOptions, opts2.export_dir) |
487 | 502 |
488 if not _vmSourcesAvailable or not opts2.native: | 503 if not _vmSourcesAvailable or not opts2.native: |
489 return | 504 return |
490 | |
491 if len(opts2.remainder) != 0: | |
492 mx.abort('specify ' + opts2.remainder[0] + ' build with the global option "--vmbuild ' + opts2.remainder[0] + '"') | |
493 | 505 |
494 builds = [_vmbuild] | 506 builds = [_vmbuild] |
495 | 507 |
496 if vm is None: | 508 if vm is None: |
497 vm = _get_vm() | 509 vm = _get_vm() |
1341 mx.add_argument('--workdir', help='runs the VM in the given directory', default=None) | 1353 mx.add_argument('--workdir', help='runs the VM in the given directory', default=None) |
1342 mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None) | 1354 mx.add_argument('--vmdir', help='specify where the directory in which the vms should be', default=None) |
1343 | 1355 |
1344 if (_vmSourcesAvailable): | 1356 if (_vmSourcesAvailable): |
1345 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run') | 1357 mx.add_argument('--vm', action='store', dest='vm', choices=_vmChoices.keys(), help='the VM type to build/run') |
1346 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run') | 1358 mx.add_argument('--vmbuild', action='store', dest='vmbuild', choices=_vmbuildChoices, help='the VM build to build/run (default: ' + _vmbuildChoices[0] +')') |
1347 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') | 1359 mx.add_argument('--ecl', action='store_true', dest='make_eclipse_launch', help='create launch configuration for running VM execution(s) in Eclipse') |
1348 mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>') | 1360 mx.add_argument('--native-dbg', action='store', dest='native_dbg', help='Start the vm inside a debugger', metavar='<debugger>') |
1349 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args') | 1361 mx.add_argument('--gdb', action='store_const', const='/usr/bin/gdb --args', dest='native_dbg', help='alias for --native-dbg /usr/bin/gdb --args') |
1350 | 1362 |
1351 commands.update({ | 1363 commands.update({ |