diff options
author | Mats Wichmann <mats@linux.com> | 2021-03-25 09:12:35 (GMT) |
---|---|---|
committer | Mats Wichmann <mats@linux.com> | 2021-03-25 09:12:35 (GMT) |
commit | c00b8401e4003a611a261c91eb07ef091acb692a (patch) | |
tree | d1f31d27d7cff7e1ff62f28e5fd49cecea4240bb | |
parent | a25f3ec81a3382b833393aff27b0d9eca1f70b1f (diff) | |
download | SCons-c00b8401e4003a611a261c91eb07ef091acb692a.zip SCons-c00b8401e4003a611a261c91eb07ef091acb692a.tar.gz SCons-c00b8401e4003a611a261c91eb07ef091acb692a.tar.bz2 |
Skip empty cmdline args as targets
Previously, quoted empty arguments like '', '""', "''" were
added to targets, which had some side effects - a blank would
eventually turn into a Node for the top directory, meaning
Default calls were ignored since a target is specified and
thus the whole tree will be built.
Fixes #2986
Signed-off-by: Mats Wichmann <mats@linux.com>
-rwxr-xr-x | CHANGES.txt | 1 | ||||
-rw-r--r-- | SCons/Script/Main.py | 12 | ||||
-rw-r--r-- | test/TARGETS.py | 22 |
3 files changed, 27 insertions, 8 deletions
diff --git a/CHANGES.txt b/CHANGES.txt index 03d563d..6d79f67 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -34,6 +34,7 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER which is the Python recommended way for timing short durations. - Drop remaining definitions of dict-like has_key methods, since Python 3 doesn't have a dictionary has_key (maintenance) + - Ignore empty cmdline arguments when computing targets (issue 2986) RELEASE 4.1.0 - Tues, 19 Jan 2021 15:04:42 -0700 diff --git a/SCons/Script/Main.py b/SCons/Script/Main.py index c1bb016..80124be 100644 --- a/SCons/Script/Main.py +++ b/SCons/Script/Main.py @@ -984,13 +984,17 @@ def _main(parser): if options.interactive: SCons.Node.interactive = True - # That should cover (most of) the options. Next, set up the variables - # that hold command-line arguments, so the SConscript files that we - # read and execute have access to them. + # That should cover (most of) the options. + # Next, set up the variables that hold command-line arguments, + # so the SConscript files that we read and execute have access to them. + # TODO: for options defined via AddOption which take space-separated + # option-args, the option-args will collect into targets here, + # because we don't yet know to do any different. targets = [] xmit_args = [] for a in parser.largs: - if a[:1] == '-': + # Skip so-far unrecognized options, and empty string args + if a.startswith('-') or a in ('', '""', "''"): continue if '=' in a: xmit_args.append(a) diff --git a/test/TARGETS.py b/test/TARGETS.py index 0ffc3b6..3cc2f0f 100644 --- a/test/TARGETS.py +++ b/test/TARGETS.py @@ -1,6 +1,8 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# MIT License +# +# Copyright The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -20,9 +22,6 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -# - -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ Test use of the COMMAND_LINE_TARGETS and DEFAULT_TARGETS variables. @@ -137,6 +136,21 @@ test.run(arguments = 'command_line_target', stdout = expect) +# blanks in cmdline should not be treated as targets (issue 2986) +test.write( + file='SConstruct', + content="""\ +tgt_foo = Textfile(target="foo", source="foostuff") +tgt_bar = Textfile(target="bar", source="bartuff") +Default(tgt_foo) +""", +) +test.run(arguments=["-Q", "-n", "''"], stdout="Creating 'foo.txt'\n") +test.run(arguments=["-Q", "-n", ""], stdout="Creating 'foo.txt'\n") +test.run(arguments=["-Q", "-n", '""'], stdout="Creating 'foo.txt'\n") + + + test.pass_test() # Local Variables: |