diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-04-12 00:31:45 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2021-04-12 00:31:45 (GMT) |
commit | 1b6f61fc02e796fa754b728b797b1c1f6a360f03 (patch) | |
tree | c008d75d32d9c360f3c637cf6a349c9a5508237f /SCons/Script | |
parent | cef62d1719abb82f32a50d0c51aed03ca7f5cce0 (diff) | |
download | SCons-1b6f61fc02e796fa754b728b797b1c1f6a360f03.zip SCons-1b6f61fc02e796fa754b728b797b1c1f6a360f03.tar.gz SCons-1b6f61fc02e796fa754b728b797b1c1f6a360f03.tar.bz2 |
better handle all/none and multiple options, expanded tests to cover such
Diffstat (limited to 'SCons/Script')
-rw-r--r-- | SCons/Script/SConsOptions.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/SCons/Script/SConsOptions.py b/SCons/Script/SConsOptions.py index c61f910..4e56c68 100644 --- a/SCons/Script/SConsOptions.py +++ b/SCons/Script/SConsOptions.py @@ -39,7 +39,7 @@ SUPPRESS_HELP = optparse.SUPPRESS_HELP diskcheck_all = SCons.Node.FS.diskcheck_types() -experimental_options = ['all', 'none'] +experimental_features = {'warp_speed', 'transporter'} def diskcheck_convert(value): @@ -708,11 +708,36 @@ def Parser(version): action="store_true", help="Import certain virtualenv variables to SCons") + def experimental_callback(option, opt, value, parser): + experimental = getattr(parser.values, option.dest) + + if ',' in value: + value = value.split(',') + else: + value = [value, ] + + for v in value: + if v == 'none': + experimental = set() + elif v == 'all': + experimental = experimental_features + elif v not in experimental_features: + raise OptionValueError("option --experimental: invalid choice: '%s' (choose from 'all','none',%s)" % ( + v, ','.join(["'%s'" % e for e in sorted(experimental_features)]))) + else: + experimental |= {v} + + setattr(parser.values, option.dest, experimental) + + + op.add_option('--experimental', dest='experimental', - action='append', - default=[], - choices=experimental_options, + action='callback', + default={}, # empty set + type='str', + # choices=experimental_options+experimental_features, + callback =experimental_callback, help='Enable experimental features') op.add_option('-f', '--file', '--makefile', '--sconstruct', |