[pypy-commit] pypy default: Move --help handling earlier, which let it display its results much
arigo
noreply at buildbot.pypy.org
Wed Dec 26 10:35:11 CET 2012
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r59551:c0989487d05d
Date: 2012-12-26 10:34 +0100
http://bitbucket.org/pypy/pypy/changeset/c0989487d05d/
Log: Move --help handling earlier, which let it display its results much
faster and fixes a crash if there is no compiler available. I also
changed it so that a bare --help only displays translator options,
and you need "--help targetpypystandalone" to display PyPy-specific
options.
diff --git a/pypy/translator/goal/translate.py b/pypy/translator/goal/translate.py
--- a/pypy/translator/goal/translate.py
+++ b/pypy/translator/goal/translate.py
@@ -144,6 +144,8 @@
else:
log.ERROR("Could not find target %r" % (arg, ))
sys.exit(1)
+ else:
+ show_help(translateconfig, opt_parser, None, config)
# apply the platform settings
set_platform(config)
@@ -163,6 +165,9 @@
existing_config=config,
translating=True)
+ # show the target-specific help if --help was given
+ show_help(translateconfig, opt_parser, targetspec_dic, config)
+
# apply the optimization level settings
set_opt_level(config, translateconfig.opt)
@@ -174,17 +179,26 @@
# perform checks (if any) on the final config
final_check_config(config)
+ return targetspec_dic, translateconfig, config, args
+
+def show_help(translateconfig, opt_parser, targetspec_dic, config):
if translateconfig.help:
- opt_parser.print_help()
- if 'print_help' in targetspec_dic:
- print "\n\nTarget specific help:\n\n"
+ if targetspec_dic is None:
+ opt_parser.print_help()
+ print "\n\nDefault target: %s" % translateconfig.targetspec
+ print "Run '%s --help %s' for target-specific help" % (
+ sys.argv[0], translateconfig.targetspec)
+ elif 'print_help' in targetspec_dic:
+ print "\n\nTarget specific help for %s:\n\n" % (
+ translateconfig.targetspec,)
targetspec_dic['print_help'](config)
+ else:
+ print "\n\nNo target-specific help available for %s" % (
+ translateconfig.targetspec,)
print "\n\nFor detailed descriptions of the command line options see"
print "http://pypy.readthedocs.org/en/latest/config/commandline.html"
sys.exit(0)
- return targetspec_dic, translateconfig, config, args
-
def log_options(options, header="options in effect"):
# list options (xxx filter, filter for target)
log('%s:' % header)
More information about the pypy-commit
mailing list