From 7b771f467c73e80692b7c2b8667ea433ab73b721 Mon Sep 17 00:00:00 2001 From: Simon Tegelid Date: Sun, 27 May 2018 13:33:36 +0200 Subject: Do not reuse tempfiles Actions lists with more than one action using ${TEMPFILE("TEMP FILE CONTENT")} should not use the same tempfile for different "TEMP FILE CONTENT". Therefore we cannot store the cmd_list in niether the target nor the source attributes since those are common for all actions. Reusing the same tempfile causes the same command to be invoked for all actions in the list. However, not resusing tempfiles will create unneeded tempfiles on strfunction invocation. This is better than producing incorrect results, but leaves the tempfile in a bad state. --- CHANGES.txt | 4 +++ SCons/Platform/PlatformTests.py | 2 +- SCons/Platform/__init__.py | 15 ---------- test/TEMPFILE-actionlist.py | 64 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 16 deletions(-) create mode 100644 test/TEMPFILE-actionlist.py diff --git a/CHANGES.txt b/CHANGES.txt index fc1d857..f5e7233 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -51,6 +51,10 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Suppress missing SConscript deprecation warning if `must_exist=False` is used. + From Simon Tegelid + - Fix using TEMPFILE in multiple actions in an action list. + + RELEASE 4.0.1 - Mon, 16 Jul 2020 16:06:40 -0700 diff --git a/SCons/Platform/PlatformTests.py b/SCons/Platform/PlatformTests.py index 4186119..dbcf5c6 100644 --- a/SCons/Platform/PlatformTests.py +++ b/SCons/Platform/PlatformTests.py @@ -192,7 +192,6 @@ class TempFileMungeTestCase(unittest.TestCase): SCons.Action.print_actions = old_actions assert file_content != env['TEMPFILEARGJOINBYTE'].join(['test','command','line']) - def test_tempfilecreation_once(self): # Init class with cmd, such that the fully expanded # string reads "a test command line". @@ -227,6 +226,7 @@ class TempFileMungeTestCase(unittest.TestCase): assert cmd == getattr(target[0].attributes, 'tempfile_cmdlist', None) + class PlatformEscapeTestCase(unittest.TestCase): def test_posix_escape(self): """ Check that paths with parens are escaped properly diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index 5d3541b..e6bf2ae 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -189,14 +189,6 @@ class TempFileMunge: if length <= maxline: return self.cmd - # Check if we already created the temporary file for this target - # It should have been previously done by Action.strfunction() call - node = target[0] if SCons.Util.is_List(target) else target - cmdlist = getattr(node.attributes, 'tempfile_cmdlist', None) \ - if node is not None else None - if cmdlist is not None: - return cmdlist - # Default to the .lnk suffix for the benefit of the Phar Lap # linkloc linker, which likes to append an .lnk suffix if # none is given. @@ -260,14 +252,7 @@ class TempFileMunge: str(cmd[0]) + " " + " ".join(args)) self._print_cmd_str(target, source, env, cmdstr) - # Store the temporary file command list into the target Node.attributes - # to avoid creating two temporary files one for print and one for execute. cmdlist = [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ] - if node is not None: - try : - setattr(node.attributes, 'tempfile_cmdlist', cmdlist) - except AttributeError: - pass return cmdlist def _print_cmd_str(self, target, source, env, cmdstr): diff --git a/test/TEMPFILE-actionlist.py b/test/TEMPFILE-actionlist.py new file mode 100644 index 0000000..b8d7d33 --- /dev/null +++ b/test/TEMPFILE-actionlist.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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__" + +""" +Verify that using $TEMPFILE in multiple actions in a +list invokes each command in the list. +""" + +import os +import stat + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """ +env = Environment(BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', + '${TEMPFILE("yyy.py -o$TARGET tempfile")}'], + MAXLINELENGTH=1) +env.Command('file.output', 'file.input', '$BUILDCOM') +""") + +test.write('file.input', "file.input\n") + +test.run(arguments='-n -Q .', + stdout="""\ +Using tempfile \\S+ for command line: +xxx.py -otempfile file.input +xxx.py @\\S+ +Using tempfile \\S+ for command line: +yyy.py -ofile.output tempfile +yyy.py @\\S+ +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: -- cgit v0.12 From 23a49c37b765f0fab398b5bf34304fcd0df3116f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 12:39:19 -0700 Subject: A little clean up of the test --- test/TEMPFILE-actionlist.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/test/TEMPFILE-actionlist.py b/test/TEMPFILE-actionlist.py index b8d7d33..b4b13b0 100644 --- a/test/TEMPFILE-actionlist.py +++ b/test/TEMPFILE-actionlist.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -# __COPYRIGHT__ -# # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including @@ -22,19 +20,15 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - """ Verify that using $TEMPFILE in multiple actions in a list invokes each command in the list. """ -import os -import stat - import TestSCons test = TestSCons.TestSCons(match=TestSCons.match_re) +test.verbose_set(True) test.write('SConstruct', """ env = Environment(BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', -- cgit v0.12 From 49d40b718a86fc0cb0fdaa7e76b282b6c09735c2 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 12:43:05 -0700 Subject: move TEMPFILE tests to their own dir, and create fixture dir and put TEMPFILE-actionlist's SConsctruct in fixture dir --- test/TEMPFILE-actionlist.py | 58 ----------- test/TEMPFILE/TEMPFILE-actionlist.py | 52 ++++++++++ test/TEMPFILE/TEMPFILEPREFIX.py | 110 +++++++++++++++++++++ test/TEMPFILE/TEMPFILESUFFIX.py | 110 +++++++++++++++++++++ .../fixture/SConstruct-tempfile-actionlist | 4 + 5 files changed, 276 insertions(+), 58 deletions(-) delete mode 100644 test/TEMPFILE-actionlist.py create mode 100644 test/TEMPFILE/TEMPFILE-actionlist.py create mode 100644 test/TEMPFILE/TEMPFILEPREFIX.py create mode 100644 test/TEMPFILE/TEMPFILESUFFIX.py create mode 100644 test/TEMPFILE/fixture/SConstruct-tempfile-actionlist diff --git a/test/TEMPFILE-actionlist.py b/test/TEMPFILE-actionlist.py deleted file mode 100644 index b4b13b0..0000000 --- a/test/TEMPFILE-actionlist.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# 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. -# - -""" -Verify that using $TEMPFILE in multiple actions in a -list invokes each command in the list. -""" - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) -test.verbose_set(True) - -test.write('SConstruct', """ -env = Environment(BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', - '${TEMPFILE("yyy.py -o$TARGET tempfile")}'], - MAXLINELENGTH=1) -env.Command('file.output', 'file.input', '$BUILDCOM') -""") - -test.write('file.input', "file.input\n") - -test.run(arguments='-n -Q .', - stdout="""\ -Using tempfile \\S+ for command line: -xxx.py -otempfile file.input -xxx.py @\\S+ -Using tempfile \\S+ for command line: -yyy.py -ofile.output tempfile -yyy.py @\\S+ -""") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEMPFILE/TEMPFILE-actionlist.py b/test/TEMPFILE/TEMPFILE-actionlist.py new file mode 100644 index 0000000..0c89f26 --- /dev/null +++ b/test/TEMPFILE/TEMPFILE-actionlist.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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. +# + +""" +Verify that using $TEMPFILE in multiple actions in a +list invokes each command in the list. +""" + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) +test.verbose_set(True) +test.file_fixture('fixture/SConstruct-tempfile-actionlist', 'SConstruct') + +test.write('file.input', "file.input\n") + +test.run(arguments='-n -Q .', + stdout="""\ +Using tempfile \\S+ for command line: +xxx.py -otempfile file.input +xxx.py @\\S+ +Using tempfile \\S+ for command line: +yyy.py -ofile.output tempfile +yyy.py @\\S+ +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEMPFILE/TEMPFILEPREFIX.py b/test/TEMPFILE/TEMPFILEPREFIX.py new file mode 100644 index 0000000..ac2ae46 --- /dev/null +++ b/test/TEMPFILE/TEMPFILEPREFIX.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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. + +""" +Verify that setting the $TEMPFILEPREFIX variable will cause +it to appear at the front of name of the generated tempfile +used for long command lines. +""" + +import os +import stat + +import TestSCons + +test = TestSCons.TestSCons(match = TestSCons.match_re) + +test.write('SConstruct', """ +import os +env = Environment( + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILEPREFIX = '-via', +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.write('foo.in', "foo.in\n") + +test.run(arguments = '-n -Q .', + stdout = """\ +Using tempfile \\S+ for command line: +xxx.py foo.out foo.in +xxx.py -via\\S+ +""") + +test.write('SConstruct', """ +import os + +def print_cmd_line(s, targets, sources, env): + pass + +env = Environment( + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILEPREFIX = '-via', + PRINT_CMD_LINE_FUNC=print_cmd_line +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """""") + +test.write('SConstruct', """ +import os +from SCons.Platform import TempFileMunge + +class TestTempFileMunge(TempFileMunge): + + def __init__(self, cmd, cmdstr = None): + super(TestTempFileMunge, self).__init__(cmd, cmdstr) + + def _print_cmd_str(self, target, source, env, cmdstr): + super(TestTempFileMunge, self)._print_cmd_str(target, source, None, cmdstr) + +env = Environment( + TEMPFILE = TestTempFileMunge, + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILEPREFIX = '-via', + +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """\ +Using tempfile \\S+ for command line: +xxx.py foo.out foo.in +xxx.py -via\\S+ +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEMPFILE/TEMPFILESUFFIX.py b/test/TEMPFILE/TEMPFILESUFFIX.py new file mode 100644 index 0000000..a19317d --- /dev/null +++ b/test/TEMPFILE/TEMPFILESUFFIX.py @@ -0,0 +1,110 @@ +#!/usr/bin/env python +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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. + +""" +Verify that setting the $TEMPFILESUFFIX variable will cause +it to appear at the end of name of the generated tempfile +used for long command lines. +""" + +import os +import stat + +import TestSCons + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.write('SConstruct', """ +import os +env = Environment( + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILESUFFIX = '.foo', +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.write('foo.in', "foo.in\n") + +test.run(arguments = '-n -Q .', + stdout = """\ +Using tempfile \\S+ for command line: +xxx.py foo.out foo.in +xxx.py \\S+ +""") + +test.write('SConstruct', """ +import os + +def print_cmd_line(s, targets, sources, env): + pass + +env = Environment( + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILESUFFIX = '.foo', + PRINT_CMD_LINE_FUNC=print_cmd_line +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """""") + +test.write('SConstruct', """ +import os +from SCons.Platform import TempFileMunge + +class TestTempFileMunge(TempFileMunge): + + def __init__(self, cmd, cmdstr = None): + super(TestTempFileMunge, self).__init__(cmd, cmdstr) + + def _print_cmd_str(self, target, source, env, cmdstr): + super(TestTempFileMunge, self)._print_cmd_str(target, source, None, cmdstr) + +env = Environment( + TEMPFILE = TestTempFileMunge, + BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH = 16, + TEMPFILESUFFIX = '.foo', + +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') +""") + +test.run(arguments = '-n -Q .', + stdout = """\ +Using tempfile \\S+ for command line: +xxx.py foo.out foo.in +xxx.py \\S+ +""") + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist b/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist new file mode 100644 index 0000000..78aee7b --- /dev/null +++ b/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist @@ -0,0 +1,4 @@ +env = Environment(BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', + '${TEMPFILE("yyy.py -o$TARGET tempfile")}'], + MAXLINELENGTH=1) +env.Command('file.output', 'file.input', '$BUILDCOM') -- cgit v0.12 From aa6a710954b216e89c3e58d73d06319bfce4c785 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 12:43:48 -0700 Subject: clean up test so it doesn't load any unnecessary tools --- test/TEMPFILE/fixture/SConstruct-tempfile-actionlist | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist b/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist index 78aee7b..07b6345 100644 --- a/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist +++ b/test/TEMPFILE/fixture/SConstruct-tempfile-actionlist @@ -1,4 +1,6 @@ -env = Environment(BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', +DefaultEnvironment(tools=[]) +env = Environment(tools=[], + BUILDCOM=['${TEMPFILE("xxx.py -otempfile $SOURCE")}', '${TEMPFILE("yyy.py -o$TARGET tempfile")}'], MAXLINELENGTH=1) env.Command('file.output', 'file.input', '$BUILDCOM') -- cgit v0.12 From fabb4024fa66679dd232a4cef532a74571406347 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 17:22:11 -0700 Subject: Fix issue a different way than PR 3553 or 3140. Store cmdlist in dict target.attributes.tempfile_cmdlist[self.cmd] where self.cmd is the string in ${TEMPFILE('MY STRING')} --- SCons/Platform/PlatformTests.py | 1 + SCons/Platform/__init__.py | 20 ++++ test/TEMPFILE/TEMPFILEDIR.py | 74 +++++++++++++++ test/TEMPFILE/fixture/SConstruct.tempfiledir | 17 ++++ test/TempFileMunge/TEMPFILEDIR.py | 74 --------------- test/TempFileMunge/TEMPFILEPREFIX.py | 110 ---------------------- test/TempFileMunge/TEMPFILESUFFIX.py | 110 ---------------------- test/TempFileMunge/fixture/SConstruct.tempfiledir | 17 ---- 8 files changed, 112 insertions(+), 311 deletions(-) create mode 100644 test/TEMPFILE/TEMPFILEDIR.py create mode 100644 test/TEMPFILE/fixture/SConstruct.tempfiledir delete mode 100644 test/TempFileMunge/TEMPFILEDIR.py delete mode 100644 test/TempFileMunge/TEMPFILEPREFIX.py delete mode 100644 test/TempFileMunge/TEMPFILESUFFIX.py delete mode 100644 test/TempFileMunge/fixture/SConstruct.tempfiledir diff --git a/SCons/Platform/PlatformTests.py b/SCons/Platform/PlatformTests.py index dbcf5c6..6184b0b 100644 --- a/SCons/Platform/PlatformTests.py +++ b/SCons/Platform/PlatformTests.py @@ -218,6 +218,7 @@ class TempFileMungeTestCase(unittest.TestCase): def __init__(self): self.attributes = self.Attrs() + target = [Node()] cmd = t(target, None, env, 0) # ...and restoring its setting. diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index e6bf2ae..79eada7 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -189,6 +189,15 @@ class TempFileMunge: if length <= maxline: return self.cmd + # Check if we already created the temporary file for this target + # It should have been previously done by Action.strfunction() call + node = target[0] if SCons.Util.is_List(target) else target + cmdlist = None + if node and hasattr(node.attributes, 'tempfile_cmdlist'): + cmdlist = node.attributes.tempfile_cmdlist.get(self.cmd, None) + if cmdlist is not None: + return cmdlist + # Default to the .lnk suffix for the benefit of the Phar Lap # linkloc linker, which likes to append an .lnk suffix if # none is given. @@ -253,6 +262,17 @@ class TempFileMunge: self._print_cmd_str(target, source, env, cmdstr) cmdlist = [ cmd[0], prefix + native_tmp + '\n' + rm, native_tmp ] + + # Store the temporary file command list into the target Node.attributes + # to avoid creating two temporary files one for print and one for execute. + if node is not None: + try: + # Storing in tempfile_cmdlist by self.cmd provided when intializing + # $TEMPFILE{} fixes issue raised in PR #3140 and #3553 + self.attributes.tempfile_cmdlist[self.cmd] = cmdlist + except AttributeError: + pass + return cmdlist def _print_cmd_str(self, target, source, env, cmdstr): diff --git a/test/TEMPFILE/TEMPFILEDIR.py b/test/TEMPFILE/TEMPFILEDIR.py new file mode 100644 index 0000000..b528be3 --- /dev/null +++ b/test/TEMPFILE/TEMPFILEDIR.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# 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. + +""" +Verify that setting the $TEMPFILEDIR variable will cause +the generated tempfile used for long command lines to be created in specified directory. +And if not specified in one of TMPDIR, TEMP or TMP (based on os' normal usage of such) +""" +from re import escape +import tempfile +import TestSCons +from TestCmd import IS_WINDOWS + +test = TestSCons.TestSCons(match=TestSCons.match_re) + +test.file_fixture('fixture/SConstruct.tempfiledir', 'SConstruct') + +expected_output = r"""Using tempfile __WORKDIR__/my_temp_files/\S+ for command line: +xxx.py foo.out foo.in +xxx.py @__WORKDIR__/my_temp_files/\S+ +Using tempfile __TEMPDIR__/\S+ for command line: +xxx.py global_foo.out foo.in +xxx.py @__TEMPDIR__/\S+ +""" + +if IS_WINDOWS: + expected_output = expected_output.replace('/','\\\\') +wd_escaped = escape(test.workdir) +td_escaped = escape(tempfile.gettempdir()) +expected_output =expected_output.replace("__WORKDIR__", wd_escaped) +expected_output = expected_output.replace("__TEMPDIR__", td_escaped) + +test.write('foo.in', "foo.in\n") + +test.run(arguments='-n -Q .', + stdout=expected_output) +# """\ +# Using tempfile \\S+ for command line: +# xxx.py foo.out foo.in +# xxx.py \\S+ +# """) +# +# try: +# tempfile = test.stdout().splitlines()[0].split()[2] +# except IndexError: +# test.fail_test("Unexpected output couldn't find tempfile") +# +# dirname = os.path.basename(os.path.dirname(tempfile)) +# test.fail_test('my_temp_files' != dirname, message="Temp file not created in \"my_temp_files\" directory") +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TEMPFILE/fixture/SConstruct.tempfiledir b/test/TEMPFILE/fixture/SConstruct.tempfiledir new file mode 100644 index 0000000..ea26c27 --- /dev/null +++ b/test/TEMPFILE/fixture/SConstruct.tempfiledir @@ -0,0 +1,17 @@ +import os + +my_temp_dir = os.path.join(os.getcwd(), 'my_temp_files') + +env = Environment( + BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH=16, + TEMPFILEDIR=my_temp_dir, +) +env.AppendENVPath('PATH', os.curdir) +env.Command('foo.out', 'foo.in', '$BUILDCOM') + +plain_env = Environment( + BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}', + MAXLINELENGTH=16, +) +plain_env.Command('global_foo.out', 'foo.in', '$BUILDCOM') diff --git a/test/TempFileMunge/TEMPFILEDIR.py b/test/TempFileMunge/TEMPFILEDIR.py deleted file mode 100644 index b528be3..0000000 --- a/test/TempFileMunge/TEMPFILEDIR.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# 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. - -""" -Verify that setting the $TEMPFILEDIR variable will cause -the generated tempfile used for long command lines to be created in specified directory. -And if not specified in one of TMPDIR, TEMP or TMP (based on os' normal usage of such) -""" -from re import escape -import tempfile -import TestSCons -from TestCmd import IS_WINDOWS - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.file_fixture('fixture/SConstruct.tempfiledir', 'SConstruct') - -expected_output = r"""Using tempfile __WORKDIR__/my_temp_files/\S+ for command line: -xxx.py foo.out foo.in -xxx.py @__WORKDIR__/my_temp_files/\S+ -Using tempfile __TEMPDIR__/\S+ for command line: -xxx.py global_foo.out foo.in -xxx.py @__TEMPDIR__/\S+ -""" - -if IS_WINDOWS: - expected_output = expected_output.replace('/','\\\\') -wd_escaped = escape(test.workdir) -td_escaped = escape(tempfile.gettempdir()) -expected_output =expected_output.replace("__WORKDIR__", wd_escaped) -expected_output = expected_output.replace("__TEMPDIR__", td_escaped) - -test.write('foo.in', "foo.in\n") - -test.run(arguments='-n -Q .', - stdout=expected_output) -# """\ -# Using tempfile \\S+ for command line: -# xxx.py foo.out foo.in -# xxx.py \\S+ -# """) -# -# try: -# tempfile = test.stdout().splitlines()[0].split()[2] -# except IndexError: -# test.fail_test("Unexpected output couldn't find tempfile") -# -# dirname = os.path.basename(os.path.dirname(tempfile)) -# test.fail_test('my_temp_files' != dirname, message="Temp file not created in \"my_temp_files\" directory") -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TempFileMunge/TEMPFILEPREFIX.py b/test/TempFileMunge/TEMPFILEPREFIX.py deleted file mode 100644 index ac2ae46..0000000 --- a/test/TempFileMunge/TEMPFILEPREFIX.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# 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. - -""" -Verify that setting the $TEMPFILEPREFIX variable will cause -it to appear at the front of name of the generated tempfile -used for long command lines. -""" - -import os -import stat - -import TestSCons - -test = TestSCons.TestSCons(match = TestSCons.match_re) - -test.write('SConstruct', """ -import os -env = Environment( - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILEPREFIX = '-via', -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.write('foo.in', "foo.in\n") - -test.run(arguments = '-n -Q .', - stdout = """\ -Using tempfile \\S+ for command line: -xxx.py foo.out foo.in -xxx.py -via\\S+ -""") - -test.write('SConstruct', """ -import os - -def print_cmd_line(s, targets, sources, env): - pass - -env = Environment( - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILEPREFIX = '-via', - PRINT_CMD_LINE_FUNC=print_cmd_line -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.run(arguments = '-n -Q .', - stdout = """""") - -test.write('SConstruct', """ -import os -from SCons.Platform import TempFileMunge - -class TestTempFileMunge(TempFileMunge): - - def __init__(self, cmd, cmdstr = None): - super(TestTempFileMunge, self).__init__(cmd, cmdstr) - - def _print_cmd_str(self, target, source, env, cmdstr): - super(TestTempFileMunge, self)._print_cmd_str(target, source, None, cmdstr) - -env = Environment( - TEMPFILE = TestTempFileMunge, - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILEPREFIX = '-via', - -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.run(arguments = '-n -Q .', - stdout = """\ -Using tempfile \\S+ for command line: -xxx.py foo.out foo.in -xxx.py -via\\S+ -""") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TempFileMunge/TEMPFILESUFFIX.py b/test/TempFileMunge/TEMPFILESUFFIX.py deleted file mode 100644 index a19317d..0000000 --- a/test/TempFileMunge/TEMPFILESUFFIX.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/env python -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files (the -# "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to -# permit persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY -# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE -# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -# 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. - -""" -Verify that setting the $TEMPFILESUFFIX variable will cause -it to appear at the end of name of the generated tempfile -used for long command lines. -""" - -import os -import stat - -import TestSCons - -test = TestSCons.TestSCons(match=TestSCons.match_re) - -test.write('SConstruct', """ -import os -env = Environment( - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILESUFFIX = '.foo', -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.write('foo.in', "foo.in\n") - -test.run(arguments = '-n -Q .', - stdout = """\ -Using tempfile \\S+ for command line: -xxx.py foo.out foo.in -xxx.py \\S+ -""") - -test.write('SConstruct', """ -import os - -def print_cmd_line(s, targets, sources, env): - pass - -env = Environment( - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILESUFFIX = '.foo', - PRINT_CMD_LINE_FUNC=print_cmd_line -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.run(arguments = '-n -Q .', - stdout = """""") - -test.write('SConstruct', """ -import os -from SCons.Platform import TempFileMunge - -class TestTempFileMunge(TempFileMunge): - - def __init__(self, cmd, cmdstr = None): - super(TestTempFileMunge, self).__init__(cmd, cmdstr) - - def _print_cmd_str(self, target, source, env, cmdstr): - super(TestTempFileMunge, self)._print_cmd_str(target, source, None, cmdstr) - -env = Environment( - TEMPFILE = TestTempFileMunge, - BUILDCOM = '${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH = 16, - TEMPFILESUFFIX = '.foo', - -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') -""") - -test.run(arguments = '-n -Q .', - stdout = """\ -Using tempfile \\S+ for command line: -xxx.py foo.out foo.in -xxx.py \\S+ -""") - -test.pass_test() - -# Local Variables: -# tab-width:4 -# indent-tabs-mode:nil -# End: -# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/TempFileMunge/fixture/SConstruct.tempfiledir b/test/TempFileMunge/fixture/SConstruct.tempfiledir deleted file mode 100644 index ea26c27..0000000 --- a/test/TempFileMunge/fixture/SConstruct.tempfiledir +++ /dev/null @@ -1,17 +0,0 @@ -import os - -my_temp_dir = os.path.join(os.getcwd(), 'my_temp_files') - -env = Environment( - BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH=16, - TEMPFILEDIR=my_temp_dir, -) -env.AppendENVPath('PATH', os.curdir) -env.Command('foo.out', 'foo.in', '$BUILDCOM') - -plain_env = Environment( - BUILDCOM='${TEMPFILE("xxx.py $TARGET $SOURCES")}', - MAXLINELENGTH=16, -) -plain_env.Command('global_foo.out', 'foo.in', '$BUILDCOM') -- cgit v0.12 From dba99ff405537697b956764b65146c1068807cf8 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 18:43:33 -0700 Subject: Fix unit test, and logic which was slightly off --- SCons/Platform/PlatformTests.py | 16 +++++++++------- SCons/Platform/__init__.py | 4 ++-- test/TEMPFILE/TEMPFILE-actionlist.py | 1 - 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/SCons/Platform/PlatformTests.py b/SCons/Platform/PlatformTests.py index 6184b0b..8fedf7a 100644 --- a/SCons/Platform/PlatformTests.py +++ b/SCons/Platform/PlatformTests.py @@ -193,12 +193,14 @@ class TempFileMungeTestCase(unittest.TestCase): assert file_content != env['TEMPFILEARGJOINBYTE'].join(['test','command','line']) def test_tempfilecreation_once(self): - # Init class with cmd, such that the fully expanded - # string reads "a test command line". - # Note, how we're using a command string here that is - # actually longer than the substituted one. This is to ensure - # that the TempFileMunge class internally really takes the - # length of the expanded string into account. + """ + Init class with cmd, such that the fully expanded + string reads "a test command line". + Note, how we're using a command string here that is + actually longer than the substituted one. This is to ensure + that the TempFileMunge class internally really takes the + length of the expanded string into account. + """ defined_cmd = "a $VERY $OVERSIMPLIFIED line" t = SCons.Platform.TempFileMunge(defined_cmd) env = SCons.Environment.SubstitutionEnvironment(tools=[]) @@ -224,7 +226,7 @@ class TempFileMungeTestCase(unittest.TestCase): # ...and restoring its setting. SCons.Action.print_actions = old_actions assert cmd != defined_cmd, cmd - assert cmd == getattr(target[0].attributes, 'tempfile_cmdlist', None) + assert cmd == target[0].attributes.tempfile_cmdlist[defined_cmd] diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index 79eada7..f59fab3 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -269,9 +269,9 @@ class TempFileMunge: try: # Storing in tempfile_cmdlist by self.cmd provided when intializing # $TEMPFILE{} fixes issue raised in PR #3140 and #3553 - self.attributes.tempfile_cmdlist[self.cmd] = cmdlist + node.attributes.tempfile_cmdlist[self.cmd] = cmdlist except AttributeError: - pass + node.attributes.tempfile_cmdlist = {self.cmd:cmdlist} return cmdlist diff --git a/test/TEMPFILE/TEMPFILE-actionlist.py b/test/TEMPFILE/TEMPFILE-actionlist.py index 0c89f26..5e5390b 100644 --- a/test/TEMPFILE/TEMPFILE-actionlist.py +++ b/test/TEMPFILE/TEMPFILE-actionlist.py @@ -28,7 +28,6 @@ list invokes each command in the list. import TestSCons test = TestSCons.TestSCons(match=TestSCons.match_re) -test.verbose_set(True) test.file_fixture('fixture/SConstruct-tempfile-actionlist', 'SConstruct') test.write('file.input', "file.input\n") -- cgit v0.12 From 71a886da33883a4c87e1fd9a78d4ac51d3036a4a Mon Sep 17 00:00:00 2001 From: William Deegan Date: Sun, 20 Sep 2020 21:52:44 -0700 Subject: Fix the case where the argument to TEMPFILE is a list, by creating a tuple to hold it and using that as the key for tempfile_cmdlist --- SCons/Platform/__init__.py | 12 +++++++++--- test/long-lines/signature.py | 4 ---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index f59fab3..bf8a4c8 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -193,8 +193,14 @@ class TempFileMunge: # It should have been previously done by Action.strfunction() call node = target[0] if SCons.Util.is_List(target) else target cmdlist = None + + if isinstance(self.cmd, list): + cmdlist_key = tuple(self.cmd) + else: + cmdlist_key = self.cmd + if node and hasattr(node.attributes, 'tempfile_cmdlist'): - cmdlist = node.attributes.tempfile_cmdlist.get(self.cmd, None) + cmdlist = node.attributes.tempfile_cmdlist.get(cmdlist_key, None) if cmdlist is not None: return cmdlist @@ -269,9 +275,9 @@ class TempFileMunge: try: # Storing in tempfile_cmdlist by self.cmd provided when intializing # $TEMPFILE{} fixes issue raised in PR #3140 and #3553 - node.attributes.tempfile_cmdlist[self.cmd] = cmdlist + node.attributes.tempfile_cmdlist[cmdlist_key] = cmdlist except AttributeError: - node.attributes.tempfile_cmdlist = {self.cmd:cmdlist} + node.attributes.tempfile_cmdlist = {cmdlist_key:cmdlist} return cmdlist diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index 082a13b..c1c1c79 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -# __COPYRIGHT__ -# # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the # "Software"), to deal in the Software without restriction, including @@ -22,8 +20,6 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" - """ Verify that use of long command lines correctly excludes arguments surrounded by $( $) from the signature calculation. -- cgit v0.12 From 508b2d0384f7ff0c6dc66a547d93d5c89bc8dd38 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 21 Sep 2020 09:58:50 -0700 Subject: correct copyright statement per mwichmann's feedback --- CHANGES.txt | 13 +++++++------ SCons/Platform/PlatformTests.py | 2 +- SCons/Platform/__init__.py | 3 +-- runtest.py | 2 +- test/TEMPFILE/TEMPFILE-actionlist.py | 2 ++ test/long-lines/signature.py | 2 ++ 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f5e7233..7f9a455 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -8,9 +8,6 @@ NOTE: The 4.0.0 Release of SCons dropped Python 2.7 Support RELEASE VERSION/DATE TO BE FILLED IN LATER - From Michał Górny: - - Fix dvipdf test failure due to passing incorrect flag to dvipdf. - From Joseph Brill: - Internal MSVC and test updates: Rework the msvc installed versions cache so that it is not exposed externally and update external references accordingly. @@ -21,10 +18,17 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - Fix yacc tool, not respecting YACC set at time of tool initialization. - Refactor SCons.Tool to move all common shared and loadable module linking logic to SCons.Tool.linkCommon + From Michał Górny: + - Fix dvipdf test failure due to passing incorrect flag to dvipdf. + From Adam Gross: - Fix minor bug affecting SCons.Node.FS.File.get_csig()'s usage of the MD5 chunksize. User-facing behavior does not change with this fix (GH Issue #3726). + From Joachim Kuebart: + - Suppress missing SConscript deprecation warning if `must_exist=False` + is used. + From Rocco Matano: - Fix Zip tool to respect ZIPCOMSTR. Previously all zip builder calls would yield something like zip(["test.zip"], ["zip_scons.py"]) and ignore ZIPCOMSTR if ZIPCOM and ZIPCOMSTR @@ -47,9 +51,6 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - passing a dict to merge where the values are strings failed (issue #2961). - Include previously-excluded SideEffect section in User Guide. - From Joachim Kuebart: - - Suppress missing SConscript deprecation warning if `must_exist=False` - is used. From Simon Tegelid - Fix using TEMPFILE in multiple actions in an action list. diff --git a/SCons/Platform/PlatformTests.py b/SCons/Platform/PlatformTests.py index 8fedf7a..8c357df 100644 --- a/SCons/Platform/PlatformTests.py +++ b/SCons/Platform/PlatformTests.py @@ -1,5 +1,5 @@ # -# __COPYRIGHT__ +# 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 diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index bf8a4c8..a68eb53 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -20,7 +20,7 @@ their own platform definition. """ # -# __COPYRIGHT__ +# 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 @@ -41,7 +41,6 @@ their own platform definition. # 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__" import SCons.compat diff --git a/runtest.py b/runtest.py index a36ba85..7ca347b 100755 --- a/runtest.py +++ b/runtest.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# __COPYRIGHT__ +# Copyright The SCons Foundation # # runtest.py - wrapper script for running SCons tests # diff --git a/test/TEMPFILE/TEMPFILE-actionlist.py b/test/TEMPFILE/TEMPFILE-actionlist.py index 5e5390b..d66b217 100644 --- a/test/TEMPFILE/TEMPFILE-actionlist.py +++ b/test/TEMPFILE/TEMPFILE-actionlist.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # +# 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 # "Software"), to deal in the Software without restriction, including diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index c1c1c79..7f9ba43 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -1,5 +1,7 @@ #!/usr/bin/env python # +# 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 # "Software"), to deal in the Software without restriction, including -- cgit v0.12 From f4e72bff6d6f1819ddf9031ed239441ea2420615 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 21 Sep 2020 10:00:24 -0700 Subject: use clearer syntax and switch to using SCons.Util.is_List() --- SCons/Platform/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SCons/Platform/__init__.py b/SCons/Platform/__init__.py index a68eb53..c15799c 100644 --- a/SCons/Platform/__init__.py +++ b/SCons/Platform/__init__.py @@ -190,10 +190,14 @@ class TempFileMunge: # Check if we already created the temporary file for this target # It should have been previously done by Action.strfunction() call - node = target[0] if SCons.Util.is_List(target) else target + if SCons.Util.is_List(target): + node = target[0] + else: + node = target + cmdlist = None - if isinstance(self.cmd, list): + if SCons.Util.is_List(self.cmd): cmdlist_key = tuple(self.cmd) else: cmdlist_key = self.cmd -- cgit v0.12 From bb08b0b25fb19c329f85c20448ddfb8b6c318f71 Mon Sep 17 00:00:00 2001 From: William Deegan Date: Mon, 21 Sep 2020 16:40:02 -0700 Subject: [ci skip] Updated CHANGES.txt to be more descriptive --- CHANGES.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 7f9a455..3e51767 100755 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -51,9 +51,14 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER - passing a dict to merge where the values are strings failed (issue #2961). - Include previously-excluded SideEffect section in User Guide. - From Simon Tegelid - - Fix using TEMPFILE in multiple actions in an action list. + - Fix using TEMPFILE in multiple actions in an action list. Previously a builder, or command + with an action list like this: + ['${TEMPFILE("xxx.py -otempfile $SOURCE")}', '${TEMPFILE("yyy.py -o$TARGET tempfile")}'] + Could yield a single tempfile with the first TEMPFILE's contents, used by both steps + in the action list. + + -- cgit v0.12