diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 11 | ||||
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 32 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 12 |
5 files changed, 67 insertions, 3 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index ea9bf43..a246711 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -19,6 +19,8 @@ RELEASE 0.04 - - Allow LIBS and LIBPATH to be strings, not just arrays. + - Print a traceback if a Python-function builder throws an exception. + From Steven Knight: - Fix using a directory as a Default(), and allow Default() to @@ -46,6 +48,8 @@ RELEASE 0.04 - surround $_INCDIRS and $_LIBDIRS so we don't rebuild in response to changes to -I or -L options. + - Add the Ignore() method to ignore dependencies. + From Steve Leblanc: - Add var=value command-line arguments. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 612ae9a..3c1ee43 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -174,6 +174,17 @@ class Environment: tlist = tlist[0] return tlist + def Ignore(self, target, dependency): + """Ignore a dependency.""" + tlist = SCons.Util.scons_str2nodes(target) + dlist = SCons.Util.scons_str2nodes(dependency) + for t in tlist: + t.add_ignore(dlist) + + if len(tlist) == 1: + tlist = tlist[0] + return tlist + def Dictionary(self, *args): if not args: return self._dict diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index a65cc33..59f3c78 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -258,6 +258,17 @@ class EnvironmentTestCase(unittest.TestCase): assert d.__class__.__name__ == 'File' assert d.path == 'Environment.py' + def test_Ignore(self): + """Test the explicit Ignore method.""" + env = Environment() + t = env.Ignore(target='targ.py', dependency='dep.py') + assert t.__class__.__name__ == 'File' + assert t.path == 'targ.py' + assert len(t.ignore) == 1 + i = t.ignore[0] + assert i.__class__.__name__ == 'File' + assert i.path == 'dep.py' + def test_Command(self): """Test the Command() method.""" env = Environment() diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 1050767..aa9dccb 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -312,6 +312,38 @@ class NodeTestCase(unittest.TestCase): assert node.implicit[3] == [two, three] assert node.implicit[4] == [three, four, one] + def test_add_ignore(self): + """Test adding files whose dependencies should be ignored. + """ + node = SCons.Node.Node() + assert node.ignore == [] + + zero = SCons.Node.Node() + try: + node.add_ignore(zero) + except TypeError: + pass + else: + assert 0 + + one = SCons.Node.Node() + two = SCons.Node.Node() + three = SCons.Node.Node() + four = SCons.Node.Node() + + node.add_ignore([one]) + assert node.ignore == [one] + node.add_ignore([two, three]) + assert node.ignore == [one, two, three] + node.add_ignore([three, four, one]) + assert node.ignore == [one, two, three, four] + + assert zero.get_parents() == [] + assert one.get_parents() == [node] + assert two.get_parents() == [node] + assert three.get_parents() == [node] + assert four.get_parents() == [node] + def test_scan(self): """Test Scanner functionality""" class DummyScanner: diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index c641895..03705f7 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -59,6 +59,7 @@ class Node: self.sources = [] # source files used to build node self.depends = [] # explicit dependencies (from Depends) self.implicit = {} # implicit (scanned) dependencies + self.ignore = [] # dependencies to ignore self.parents = [] self.wkids = None # Kids yet to walk, when it's an array self.builder = None @@ -167,6 +168,10 @@ class Node: """Adds dependencies. The depend argument must be a list.""" self._add_child(self.depends, depend) + def add_ignore(self, depend): + """Adds dependencies to ignore. The depend argument must be a list.""" + self._add_child(self.ignore, depend) + def add_source(self, source): """Adds sources. The source argument must be a list.""" self._add_child(self.sources, source) @@ -201,9 +206,10 @@ class Node: def children(self): #XXX Need to remove duplicates from this - return self.sources \ - + self.depends \ - + reduce(lambda x, y: x + y, self.implicit.values(), []) + return filter(lambda x, i=self.ignore: x not in i, + self.sources \ + + self.depends \ + + reduce(lambda x, y: x + y, self.implicit.values(), [])) def get_parents(self): return self.parents |