From e650cc43946737b9d950049ae9964064ea4bf33f Mon Sep 17 00:00:00 2001 From: William Deegan Date: Tue, 10 Apr 2018 19:27:45 -0700 Subject: Fix for issue 3013 (and duplicate 3018). From bitbucket PR: https://bitbucket.org/scons/scons/pull-requests/303 --- src/CHANGES.txt | 3 ++ src/engine/SCons/Taskmaster.py | 9 ++++ test/SideEffect/Issues/3013/files/SConscript | 5 +++ test/SideEffect/Issues/3013/files/SConstruct | 21 ++++++++++ test/SideEffect/Issues/3013/files/test.cpp | 2 + .../Issues/3013/sideffect_with_variantdir.py | 49 ++++++++++++++++++++++ 6 files changed, 89 insertions(+) create mode 100644 test/SideEffect/Issues/3013/files/SConscript create mode 100644 test/SideEffect/Issues/3013/files/SConstruct create mode 100644 test/SideEffect/Issues/3013/files/test.cpp create mode 100644 test/SideEffect/Issues/3013/sideffect_with_variantdir.py diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 64c0893..d084feb 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -7,6 +7,9 @@ RELEASE 3.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE + From Bernard Blackham: + - Fixed handling of side-effects in task master (fixes #3013). + From Daniel Moody: - Set the pickling protocal back to highest which was causing issues with variant dir tests. This will cause issues if reading sconsigns diff --git a/src/engine/SCons/Taskmaster.py b/src/engine/SCons/Taskmaster.py index 17507a6..1522ca2 100644 --- a/src/engine/SCons/Taskmaster.py +++ b/src/engine/SCons/Taskmaster.py @@ -470,14 +470,23 @@ class Task(object): pending_children.discard(t) for p in t.waiting_parents: parents[p] = parents.get(p, 0) + 1 + t.waiting_parents = set() for t in targets: if t.side_effects is not None: for s in t.side_effects: if s.get_state() == NODE_EXECUTING: s.set_state(NODE_NO_STATE) + + # The side-effects may have been transferred to + # NODE_NO_STATE by executed_with{,out}_callbacks, but was + # not taken out of the waiting parents/pending children + # data structures. Check for that now. + if s.get_state() == NODE_NO_STATE and s.waiting_parents: + pending_children.discard(s) for p in s.waiting_parents: parents[p] = parents.get(p, 0) + 1 + s.waiting_parents = set() for p in s.waiting_s_e: if p.ref_count == 0: self.tm.candidates.append(p) diff --git a/test/SideEffect/Issues/3013/files/SConscript b/test/SideEffect/Issues/3013/files/SConscript new file mode 100644 index 0000000..27da7bb --- /dev/null +++ b/test/SideEffect/Issues/3013/files/SConscript @@ -0,0 +1,5 @@ +Import('env') + +primary = env.make_file('output', 'test.cpp') +this_causes_problems = env.SideEffect('output_side_effect', 'output') + diff --git a/test/SideEffect/Issues/3013/files/SConstruct b/test/SideEffect/Issues/3013/files/SConstruct new file mode 100644 index 0000000..d01a4b7 --- /dev/null +++ b/test/SideEffect/Issues/3013/files/SConstruct @@ -0,0 +1,21 @@ +env = Environment() + +def make_file(target, source, env): + with open(str(target[0]), 'w') as f: + f.write('gobldygook') + with open(str(target[0]) + '_side_effect', 'w') as side_effect: + side_effect.write('anything') + +env.Append( + BUILDERS={'make_file': Builder(action=Action(make_file))} +) + +env.objdir = 'build' + +SConscript( + 'SConscript', + variant_dir=env.objdir, + exports={'env':env}, + duplicate=0 +) + diff --git a/test/SideEffect/Issues/3013/files/test.cpp b/test/SideEffect/Issues/3013/files/test.cpp new file mode 100644 index 0000000..27424b0 --- /dev/null +++ b/test/SideEffect/Issues/3013/files/test.cpp @@ -0,0 +1,2 @@ +void some_function() {} + diff --git a/test/SideEffect/Issues/3013/sideffect_with_variantdir.py b/test/SideEffect/Issues/3013/sideffect_with_variantdir.py new file mode 100644 index 0000000..9ca3eca --- /dev/null +++ b/test/SideEffect/Issues/3013/sideffect_with_variantdir.py @@ -0,0 +1,49 @@ +#!/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__" + +""" +Test materials for Github Issue 3013 submitted by Stefan Ross: +https://github.com/SCons/scons/issues/3013 +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.dir_fixture('files') + +test.run( + arguments = '-j2' +) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: + -- cgit v0.12