summaryrefslogtreecommitdiff
path: root/engine/SCons/Script/SConsOptions.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-08-11 12:17:57 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-08-11 12:17:57 +0200
commitc8ea3b672655ddab746a7aea5a50217057b02b9e (patch)
tree01a0e712f4cf32c7140cf1a4ae14db4da4202253 /engine/SCons/Script/SConsOptions.py
parentca7be46fc0013fc037a045b6d4df73776461e821 (diff)
parentf6c9bffb15e04ea412db4df22a3851448221b85a (diff)
Diffstat (limited to 'engine/SCons/Script/SConsOptions.py')
-rw-r--r--engine/SCons/Script/SConsOptions.py69
1 files changed, 25 insertions, 44 deletions
diff --git a/engine/SCons/Script/SConsOptions.py b/engine/SCons/Script/SConsOptions.py
index f9778e6..ae08d41 100644
--- a/engine/SCons/Script/SConsOptions.py
+++ b/engine/SCons/Script/SConsOptions.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2001 - 2017 The SCons Foundation
+# Copyright (c) 2001 - 2019 The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -21,7 +21,7 @@
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
-__revision__ = "src/engine/SCons/Script/SConsOptions.py 74b2c53bc42290e911b334a6b44f187da698a668 2017/11/14 13:16:53 bdbaddog"
+__revision__ = "src/engine/SCons/Script/SConsOptions.py 72ae09dc35ac2626f8ff711d8c4b30b6138e08e3 2019-08-08 14:50:06 bdeegan"
import optparse
import re
@@ -38,6 +38,7 @@ except ImportError:
_ = gettext
import SCons.Node.FS
+import SCons.Platform.virtualenv
import SCons.Warnings
OptionValueError = optparse.OptionValueError
@@ -146,7 +147,7 @@ class SConsValues(optparse.Values):
"""
Sets an option from an SConscript file.
"""
- if not name in self.settable:
+ if name not in self.settable:
raise SCons.Errors.UserError("This option is not settable from a SConscript file: %s"%name)
if name == 'num_jobs':
@@ -166,7 +167,7 @@ class SConsValues(optparse.Values):
value = str(value)
except ValueError:
raise SCons.Errors.UserError("A string is required: %s"%repr(value))
- if not value in SCons.Node.FS.Valid_Duplicates:
+ if value not in SCons.Node.FS.Valid_Duplicates:
raise SCons.Errors.UserError("Not a valid duplication style: %s" % value)
# Set the duplicate style right away so it can affect linking
# of SConscript files.
@@ -225,39 +226,8 @@ class SConsOption(optparse.Option):
fmt = "option %s: nargs='?' is incompatible with short options"
raise SCons.Errors.UserError(fmt % self._short_opts[0])
- try:
- _orig_CONST_ACTIONS = optparse.Option.CONST_ACTIONS
-
- _orig_CHECK_METHODS = optparse.Option.CHECK_METHODS
-
- except AttributeError:
- # optparse.Option had no CONST_ACTIONS before Python 2.5.
-
- _orig_CONST_ACTIONS = ("store_const",)
-
- def _check_const(self):
- if self.action not in self.CONST_ACTIONS and self.const is not None:
- raise OptionError(
- "'const' must not be supplied for action %r" % self.action,
- self)
-
- # optparse.Option collects its list of unbound check functions
- # up front. This sucks because it means we can't just override
- # the _check_const() function like a normal method, we have to
- # actually replace it in the list. This seems to be the most
- # straightforward way to do that.
-
- _orig_CHECK_METHODS = [optparse.Option._check_action,
- optparse.Option._check_type,
- optparse.Option._check_choice,
- optparse.Option._check_dest,
- _check_const,
- optparse.Option._check_nargs,
- optparse.Option._check_callback]
-
- CHECK_METHODS = _orig_CHECK_METHODS + [_check_nargs_optional]
-
- CONST_ACTIONS = _orig_CONST_ACTIONS + optparse.Option.TYPED_ACTIONS
+ CHECK_METHODS = optparse.Option.CHECK_METHODS + [_check_nargs_optional]
+ CONST_ACTIONS = optparse.Option.CONST_ACTIONS + optparse.Option.TYPED_ACTIONS
class SConsOptionGroup(optparse.OptionGroup):
"""
@@ -363,7 +333,7 @@ class SConsOptionParser(optparse.OptionParser):
in self.largs, so that any value overridden on the
command line is immediately available if the user turns
around and does a GetOption() right away.
-
+
We mimic the processing of the single args
in the original OptionParser._process_args(), but here we
allow exact matches for long-opts only (no partial
@@ -374,7 +344,7 @@ class SConsOptionParser(optparse.OptionParser):
command-line arguments that
1. haven't been processed so far (self.largs), but
2. are possibly not added to the list of options yet.
-
+
So, when we only have a value for "--myargument" yet,
a command-line argument of "--myarg=test" would set it.
Responsible for this behaviour is the method
@@ -383,7 +353,7 @@ class SConsOptionParser(optparse.OptionParser):
be unique.
This would lead to further confusion, because we might want
to add another option "--myarg" later on (see issue #2929).
-
+
"""
rargs = []
largs_restore = []
@@ -400,7 +370,7 @@ class SConsOptionParser(optparse.OptionParser):
if "=" in l:
# Split into option and value
lopt = l.split("=", 1)
-
+
if lopt[0] in self._long_opt:
# Argument is already known
rargs.append('='.join(lopt))
@@ -415,7 +385,7 @@ class SConsOptionParser(optparse.OptionParser):
skip = True
else:
rargs.append(l)
-
+
# Parse the filtered list
self.parse_args(rargs, self.values)
# Restore the list of remaining arguments for the
@@ -689,7 +659,7 @@ def Parser(version):
metavar="TYPE")
def opt_duplicate(option, opt, value, parser):
- if not value in SCons.Node.FS.Valid_Duplicates:
+ if value not in SCons.Node.FS.Valid_Duplicates:
raise OptionValueError(opt_invalid('duplication', value,
SCons.Node.FS.Valid_Duplicates))
setattr(parser.values, option.dest, value)
@@ -706,6 +676,12 @@ def Parser(version):
action="callback", callback=opt_duplicate,
help=opt_duplicate_help)
+ if not SCons.Platform.virtualenv.virtualenv_enabled_by_default:
+ op.add_option('--enable-virtualenv',
+ dest="enable_virtualenv",
+ action="store_true",
+ help="Import certain virtualenv variables to SCons")
+
op.add_option('-f', '--file', '--makefile', '--sconstruct',
nargs=1, type="string",
dest="file", default=[],
@@ -733,6 +709,11 @@ def Parser(version):
help="Search DIR for imported Python modules.",
metavar="DIR")
+ op.add_option('--ignore-virtualenv',
+ dest="ignore_virtualenv",
+ action="store_true",
+ help="Do not import virtualenv variables to SCons")
+
op.add_option('--implicit-cache',
dest='implicit_cache', default=False,
action="store_true",
@@ -906,6 +887,7 @@ def Parser(version):
action="append",
help="Search REPOSITORY for source and target files.")
+
# Options from Make and Cons classic that we do not yet support,
# but which we may support someday and whose (potential) meanings
# we don't want to change. These all get a "the -X option is not
@@ -978,7 +960,6 @@ def Parser(version):
action="callback", callback=opt_not_yet,
# help="Warn when an undefined variable is referenced."
help=SUPPRESS_HELP)
-
return op
# Local Variables: