diff options
Diffstat (limited to 'SCons/Script/SConsOptions.py')
-rw-r--r-- | SCons/Script/SConsOptions.py | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py index e2631fb..8391d62 100644 --- a/SCons/Script/SConsOptions.py +++ b/SCons/Script/SConsOptions.py @@ -40,7 +40,7 @@ SUPPRESS_HELP = optparse.SUPPRESS_HELP diskcheck_all = SCons.Node.FS.diskcheck_types() -experimental_features = {'warp_speed', 'transporter', 'ninja'} +experimental_features = {'warp_speed', 'transporter', 'ninja', 'tm_v2'} def diskcheck_convert(value): @@ -54,7 +54,10 @@ def diskcheck_convert(value): if v == 'all': result = diskcheck_all elif v == 'none': - result = [] + # Don't use an empty list here as that fails the normal check + # to see if an optparse parser of if parser.argname: + # Changed to ['none'] as diskcheck expects a list value + result = ['none'] elif v in diskcheck_all: result.append(v) else: @@ -65,7 +68,7 @@ def diskcheck_convert(value): class SConsValues(optparse.Values): """ Holder class for uniform access to SCons options, regardless - of whether or not they can be set on the command line or in the + of whether they can be set on the command line or in the SConscript files (using the SetOption() function). A SCons option value can originate three different ways: @@ -147,11 +150,12 @@ class SConsValues(optparse.Values): 'warn', # TODO: Remove these once we update the AddOption() API to allow setting - # added flag as setable. - # Requested setable flag in : https://github.com/SCons/scons/issues/3983 + # added flag as settable. + # Requested settable flag in : https://github.com/SCons/scons/issues/3983 # From experimental ninja 'disable_execute_ninja', - 'disable_ninja' + 'disable_ninja', + 'skip_ninja_regen' ] def set_option(self, name, value): @@ -288,14 +292,36 @@ class SConsOptionGroup(optparse.OptionGroup): return result +class SConsBadOptionError(optparse.BadOptionError): + """Exception used to indicate that invalid command line options were specified + + :ivar str opt_str: The offending option specified on command line which is not recognized + :ivar OptionParser parser: The active argument parser + + """ + + def __init__(self, opt_str, parser=None): + self.opt_str = opt_str + self.parser = parser + + def __str__(self): + return _("no such option: %s") % self.opt_str + + class SConsOptionParser(optparse.OptionParser): preserve_unknown_options = False + raise_exception_on_error = False def error(self, msg): - # overridden OptionValueError exception handler - self.print_usage(sys.stderr) - sys.stderr.write("SCons Error: %s\n" % msg) - sys.exit(2) + """ + overridden OptionValueError exception handler + """ + if self.raise_exception_on_error: + raise SConsBadOptionError(msg, self) + else: + self.print_usage(sys.stderr) + sys.stderr.write("SCons Error: %s\n" % msg) + sys.exit(2) def _process_long_opt(self, rargs, values): """ SCons-specific processing of long options. |