Mercurial > hg > graal-jvmci-8
comparison mxtool/mx.py @ 5091:54819cdcca7f
Added -V option to mx for 'very verbose'which prints the environment variables used for an external command.
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 16 Mar 2012 14:48:15 +0100 |
parents | f6503609a12d |
children | 8ea90b7c8586 |
comparison
equal
deleted
inserted
replaced
5090:0a1e5b876667 | 5091:54819cdcca7f |
---|---|
508 def __init__(self): | 508 def __init__(self): |
509 self.java_initialized = False | 509 self.java_initialized = False |
510 ArgumentParser.__init__(self, prog='mx') | 510 ArgumentParser.__init__(self, prog='mx') |
511 | 511 |
512 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') | 512 self.add_argument('-v', action='store_true', dest='verbose', help='enable verbose output') |
513 self.add_argument('-V', action='store_true', dest='very_verbose', help='enable very verbose output') | |
513 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>') | 514 self.add_argument('--dbg', type=int, dest='java_dbg_port', help='make Java processes wait on <port> for a debugger', metavar='<port>') |
514 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"') | 515 self.add_argument('-d', action='store_const', const=8000, dest='java_dbg_port', help='alias for "-dbg 8000"') |
515 self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>') | 516 self.add_argument('--cp-pfx', dest='cp_prefix', help='class path prefix', metavar='<arg>') |
516 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') | 517 self.add_argument('--cp-sfx', dest='cp_suffix', help='class path suffix', metavar='<arg>') |
517 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default=DEFAULT_JAVA_ARGS) | 518 self.add_argument('--J', dest='java_args', help='Java VM arguments (e.g. --J @-dsa)', metavar='@<args>', default=DEFAULT_JAVA_ARGS) |
534 | 535 |
535 # Give the timeout options a default value to avoid the need for hasattr() tests | 536 # Give the timeout options a default value to avoid the need for hasattr() tests |
536 opts.__dict__.setdefault('timeout', 0) | 537 opts.__dict__.setdefault('timeout', 0) |
537 opts.__dict__.setdefault('ptimeout', 0) | 538 opts.__dict__.setdefault('ptimeout', 0) |
538 | 539 |
540 if opts.very_verbose: | |
541 opts.verbose = True | |
542 | |
539 if opts.java_home is None: | 543 if opts.java_home is None: |
540 opts.java_home = os.environ.get('JAVA_HOME') | 544 opts.java_home = os.environ.get('JAVA_HOME') |
541 | 545 |
542 if opts.java_home is None or opts.java_home == '': | 546 if opts.java_home is None or opts.java_home == '': |
543 abort('Could not find Java home. Use --java-home option or ensure JAVA_HOME environment variable is set.') | 547 abort('Could not find Java home. Use --java-home option or ensure JAVA_HOME environment variable is set.') |
638 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args) | 642 assert isinstance(args, types.ListType), "'args' must be a list: " + str(args) |
639 for arg in args: | 643 for arg in args: |
640 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) | 644 assert isinstance(arg, types.StringTypes), 'argument is not a string: ' + str(arg) |
641 | 645 |
642 if _opts.verbose: | 646 if _opts.verbose: |
647 if _opts.very_verbose: | |
648 log('Environment variables:') | |
649 for key in sorted(os.environ.keys()): | |
650 log(' ' + key + '=' + os.environ[key]) | |
643 log(' '.join(args)) | 651 log(' '.join(args)) |
644 | 652 |
645 if timeout is None and _opts.ptimeout != 0: | 653 if timeout is None and _opts.ptimeout != 0: |
646 timeout = _opts.ptimeout | 654 timeout = _opts.ptimeout |
647 | 655 |
695 finally: | 703 finally: |
696 _currentSubprocess = None | 704 _currentSubprocess = None |
697 | 705 |
698 if retcode and nonZeroIsFatal: | 706 if retcode and nonZeroIsFatal: |
699 if _opts.verbose: | 707 if _opts.verbose: |
700 raise subprocess.CalledProcessError(retcode, ' '.join(args)) | 708 if _opts.very_verbose: |
709 raise subprocess.CalledProcessError(retcode, ' '.join(args)) | |
710 else: | |
711 log('[exit code: ' + str(retcode)+ ']') | |
701 abort(retcode) | 712 abort(retcode) |
702 | 713 |
703 return retcode | 714 return retcode |
704 | 715 |
705 def exe_suffix(name): | 716 def exe_suffix(name): |