From d8e77652af734d2d0b410737c069339aa9db42bf Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 12 Feb 2002 17:08:33 +0000 Subject: [PATCH] Filter out a file's ignore list from all of its dependencies, direct or indirect. git-svn-id: http://scons.tigris.org/svn/scons/trunk@255 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/CHANGES.txt | 3 +++ src/engine/SCons/Node/NodeTests.py | 28 ++++++++++++++++++++++++++-- src/engine/SCons/Node/__init__.py | 13 +++++++++---- src/engine/SCons/Script/__init__.py | 2 +- src/engine/SCons/Sig/SigTests.py | 12 ++++++++++++ src/engine/SCons/Sig/__init__.py | 3 ++- 6 files changed, 53 insertions(+), 8 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ae2f4877..d5a07354 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -56,6 +56,9 @@ RELEASE 0.05 - - Document the overlooked LIBPATH construction variable. (Bug reported by Eicke Godehardt.) + - Fix so that Ignore() ignores indirect, implicit dependencies + (included files), not just direct dependencies. + From Anthony Roach: - Make the scons script return an error code on failures. diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 4e518603..b999b52a 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -423,8 +423,8 @@ class NodeTestCase(unittest.TestCase): assert node.scanned[ds] == 1, node.scanned def test_children(self): - """Test fetching the "children" of a Node. - """ + """Test fetching the non-ignored "children" of a Node. + """ node = SCons.Node.Node() one = SCons.Node.Node() two = SCons.Node.Node() @@ -435,7 +435,31 @@ class NodeTestCase(unittest.TestCase): node.add_source([one, two, three]) node.add_dependency([four, five, six]) + node.add_ignore([two, five]) kids = node.children() + assert len(kids) == 4 + assert one in kids + assert not two in kids + assert three in kids + assert four in kids + assert not five in kids + assert six in kids + + def test_all_children(self): + """Test fetching all the "children" of a Node. + """ + node = SCons.Node.Node() + one = SCons.Node.Node() + two = SCons.Node.Node() + three = SCons.Node.Node() + four = SCons.Node.Node() + five = SCons.Node.Node() + six = SCons.Node.Node() + + node.add_source([one, two, three]) + node.add_dependency([four, five, six]) + node.add_ignore([two, five]) + kids = node.all_children() assert len(kids) == 6 assert one in kids assert two in kids diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 1d09b20b..c0de58e1 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -228,11 +228,16 @@ class Node: self.wkids.append(wkid) def children(self): + """Return a list of the node's direct children, minus those + that are ignored by this node.""" + return filter(lambda x, i=self.ignore: x not in i, self.all_children()) + + def all_children(self): + """Return a list of all the node's direct children.""" #XXX Need to remove duplicates from this - return filter(lambda x, i=self.ignore: x not in i, - self.sources \ - + self.depends \ - + reduce(lambda x, y: x + y, self.implicit.values(), [])) + return self.sources \ + + self.depends \ + + reduce(lambda x, y: x + y, self.implicit.values(), []) def get_parents(self): return self.parents diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index a34814ed..dfd969ec 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -130,7 +130,7 @@ exit_status = 0 # exit status, assume success by default # utility functions -def get_children(node): return node.children() +def get_children(node): return node.all_children() def _scons_syntax_error(e): """Handle syntax errors. Print out a message and show where the error diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index e4c9421a..fba383e6 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -51,6 +51,7 @@ class DummyNode: self.path = file.path self.builder = file.builder self.depends = [] + self.ignore = [] self.use_signature = 1 self.bsig = None self.csig = None @@ -81,6 +82,10 @@ class DummyNode: return self.exists_cache def children(self): + return filter(lambda x, i=self.ignore: x not in i, + self.sources + self.depends) + + def all_children(self): return self.sources + self.depends def current(self): @@ -288,9 +293,12 @@ class CalcTestCase(unittest.TestCase): self.bsig = bsig self.csig = csig self.kids = [] + self.ignore = [] self.builder = None self.use_signature = 1 def children(self): + return filter(lambda x, i=self.ignore: x not in i, self.kids) + def all_children(self): return self.kids def exists(self): return 1 @@ -332,6 +340,10 @@ class CalcTestCase(unittest.TestCase): assert self.calc.bsig(n1) == 55 + n1.ignore = [n2] + + assert self.calc.bsig(n1) == 33 + def test_Calc_bsig(self): n = self.nodeclass('n', 11, 12) diff --git a/src/engine/SCons/Sig/__init__.py b/src/engine/SCons/Sig/__init__.py index d1e546f0..a85019aa 100644 --- a/src/engine/SCons/Sig/__init__.py +++ b/src/engine/SCons/Sig/__init__.py @@ -199,7 +199,8 @@ class Calculator: # for us. Hence: def walk_non_derived(n, myself=node): if not n.builder or n is myself: - return n.children() + return filter(lambda x, i=myself.ignore: x not in i, + n.all_children()) return [] walker = SCons.Node.Walker(node, walk_non_derived) sigs = [] -- 2.26.2