diff options
author | Steven Knight <knight@baldmt.com> | 2003-10-07 14:02:21 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-10-07 14:02:21 (GMT) |
commit | c758e5b84c91197de129134c2ab67f45f96dff52 (patch) | |
tree | e02b79d178c03add93ae76b0cd6668bc49c3d2e0 /src | |
parent | 15f50a47c4cc226b9326d3bb1271e26a62644f22 (diff) | |
download | SCons-c758e5b84c91197de129134c2ab67f45f96dff52.zip SCons-c758e5b84c91197de129134c2ab67f45f96dff52.tar.gz SCons-c758e5b84c91197de129134c2ab67f45f96dff52.tar.bz2 |
Allow Dirs to be sources of Depends, Ignores, Precious and SideEffect. (Gary Oberbrunner)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 7 | ||||
-rw-r--r-- | src/engine/SCons/Environment.py | 14 | ||||
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 108 |
3 files changed, 89 insertions, 40 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index fd9fca6..d228c81 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -123,6 +123,11 @@ RELEASE X.XX - XXX - Split the non-SCons-specific functionality from SConf.py to a new, re-usable Conftest.py module. + From Gary Oberbrunner: + + - Allow a directory to be the target or source or dependency of a + Depends(), Ignore(), Precious() or SideEffect() call. + From Marko Rauhamaa: - Have the closing message say "...terminated because of errors" if @@ -134,7 +139,7 @@ RELEASE X.XX - XXX used. ("rm" doesn't understand Win32-format path names.) From Christoph Wiedemann: - + - Fix test/SWIG.py to find the Python include directory in all cases. diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py index 40e039d..36be2e4 100644 --- a/src/engine/SCons/Environment.py +++ b/src/engine/SCons/Environment.py @@ -774,8 +774,8 @@ class Base: def Depends(self, target, dependency): """Explicity specify that 'target's depend on 'dependency'.""" - tlist = self.arg2nodes(target, self.fs.File) - dlist = self.arg2nodes(dependency, self.fs.File) + tlist = self.arg2nodes(target, self.fs.Entry) + dlist = self.arg2nodes(dependency, self.fs.Entry) for t in tlist: t.add_dependency(dlist) @@ -809,8 +809,8 @@ class Base: def Ignore(self, target, dependency): """Ignore a dependency.""" - tlist = self.arg2nodes(target, self.fs.File) - dlist = self.arg2nodes(dependency, self.fs.File) + tlist = self.arg2nodes(target, self.fs.Entry) + dlist = self.arg2nodes(dependency, self.fs.Entry) for t in tlist: t.add_ignore(dlist) @@ -869,7 +869,7 @@ class Base: def Precious(self, *targets): tlist = [] for t in targets: - tlist.extend(self.arg2nodes(t, self.fs.File)) + tlist.extend(self.arg2nodes(t, self.fs.Entry)) for t in tlist: t.set_precious() @@ -891,8 +891,8 @@ class Base: def SideEffect(self, side_effect, target): """Tell scons that side_effects are built as side effects of building targets.""" - side_effects = self.arg2nodes(side_effect, self.fs.File) - targets = self.arg2nodes(target, self.fs.File) + side_effects = self.arg2nodes(side_effect, self.fs.Entry) + targets = self.arg2nodes(target, self.fs.Entry) for side_effect in side_effects: # A builder of 1 means the node is supposed to appear diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index f46df73..360eb4c 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1343,23 +1343,35 @@ class EnvironmentTestCase(unittest.TestCase): assert d == ['bbb', 'another_file'], d def test_Depends(self): - """Test the explicit Depends method.""" - env = Environment(FOO = 'xxx', BAR='yyy') - t = env.Depends(target='EnvironmentTest.py', dependency='Environment.py') - assert t.__class__.__name__ == 'File' - assert t.path == 'EnvironmentTest.py' - assert len(t.depends) == 1 - d = t.depends[0] - assert d.__class__.__name__ == 'File' - assert d.path == 'Environment.py' - - t = env.Depends(target='${FOO}.py', dependency='${BAR}.py') - assert t.__class__.__name__ == 'File' - assert t.path == 'xxx.py' - assert len(t.depends) == 1 - d = t.depends[0] - assert d.__class__.__name__ == 'File' - assert d.path == 'yyy.py' + """Test the explicit Depends method.""" + env = Environment(FOO = 'xxx', BAR='yyy') + env.Dir('dir1') + env.Dir('dir2') + env.File('xxx.py') + env.File('yyy.py') + t = env.Depends(target='EnvironmentTest.py', dependency='Environment.py') + assert t.__class__.__name__ == 'Entry', t.__class__.__name__ + assert t.path == 'EnvironmentTest.py' + assert len(t.depends) == 1 + d = t.depends[0] + assert d.__class__.__name__ == 'Entry', d.__class__.__name__ + assert d.path == 'Environment.py' + + t = env.Depends(target='${FOO}.py', dependency='${BAR}.py') + assert t.__class__.__name__ == 'File', t.__class__.__name__ + assert t.path == 'xxx.py' + assert len(t.depends) == 1 + d = t.depends[0] + assert d.__class__.__name__ == 'File', d.__class__.__name__ + assert d.path == 'yyy.py' + + t = env.Depends(target='dir1', dependency='dir2') + assert t.__class__.__name__ == 'Dir', t.__class__.__name__ + assert t.path == 'dir1' + assert len(t.depends) == 1 + d = t.depends[0] + assert d.__class__.__name__ == 'Dir', d.__class__.__name__ + assert d.path == 'dir2' def test_Dir(self): """Test the Dir() method""" @@ -1427,21 +1439,35 @@ class EnvironmentTestCase(unittest.TestCase): def test_Ignore(self): """Test the explicit Ignore method.""" env = Environment(FOO='yyy', BAR='zzz') + env.Dir('dir1') + env.Dir('dir2') + env.File('yyyzzz') + env.File('zzzyyy') + t = env.Ignore(target='targ.py', dependency='dep.py') - assert t.__class__.__name__ == 'File' + assert t.__class__.__name__ == 'Entry', t.__class__.__name__ assert t.path == 'targ.py' assert len(t.ignore) == 1 i = t.ignore[0] - assert i.__class__.__name__ == 'File' + assert i.__class__.__name__ == 'Entry', i.__class__.__name__ assert i.path == 'dep.py' + t = env.Ignore(target='$FOO$BAR', dependency='$BAR$FOO') - assert t.__class__.__name__ == 'File' + assert t.__class__.__name__ == 'File', t.__class__.__name__ assert t.path == 'yyyzzz' assert len(t.ignore) == 1 i = t.ignore[0] - assert i.__class__.__name__ == 'File' + assert i.__class__.__name__ == 'File', i.__class__.__name__ assert i.path == 'zzzyyy' + t = env.Ignore(target='dir1', dependency='dir2') + assert t.__class__.__name__ == 'Dir', t.__class__.__name__ + assert t.path == 'dir1' + assert len(t.ignore) == 1 + i = t.ignore[0] + assert i.__class__.__name__ == 'Dir', i.__class__.__name__ + assert i.path == 'dir2' + def test_Install(self): """Test the Install method""" env = Environment(FOO='iii', BAR='jjj') @@ -1530,21 +1556,24 @@ class EnvironmentTestCase(unittest.TestCase): def test_Precious(self): """Test the Precious() method""" env = Environment(FOO='ggg', BAR='hhh') - t = env.Precious('a', '${BAR}b', ['c', 'd'], '$FOO') - assert t[0].__class__.__name__ == 'File' - assert t[0].path == 'a' + env.Dir('p_hhhb') + env.File('p_d') + t = env.Precious('p_a', 'p_${BAR}b', ['p_c', 'p_d'], 'p_$FOO') + + assert t[0].__class__.__name__ == 'Entry', t[0].__class__.__name__ + assert t[0].path == 'p_a' assert t[0].precious - assert t[1].__class__.__name__ == 'File' - assert t[1].path == 'hhhb' + assert t[1].__class__.__name__ == 'Dir', t[1].__class__.__name__ + assert t[1].path == 'p_hhhb' assert t[1].precious - assert t[2].__class__.__name__ == 'File' - assert t[2].path == 'c' + assert t[2].__class__.__name__ == 'Entry', t[2].__class__.__name__ + assert t[2].path == 'p_c' assert t[2].precious - assert t[3].__class__.__name__ == 'File' - assert t[3].path == 'd' + assert t[3].__class__.__name__ == 'File', t[3].__class__.__name__ + assert t[3].path == 'p_d' assert t[3].precious - assert t[4].__class__.__name__ == 'File' - assert t[4].path == 'ggg' + assert t[4].__class__.__name__ == 'Entry', t[4].__class__.__name__ + assert t[4].path == 'p_ggg' assert t[4].precious def test_Repository(self): @@ -1602,10 +1631,13 @@ class EnvironmentTestCase(unittest.TestCase): def test_SideEffect(self): """Test the SideEffect() method""" env = Environment(LIB='lll', FOO='fff', BAR='bbb') + env.File('mylll.pdb') + env.Dir('mymmm.pdb') foo = env.Object('foo.obj', 'foo.cpp') bar = env.Object('bar.obj', 'bar.cpp') s = env.SideEffect('mylib.pdb', ['foo.obj', 'bar.obj']) + assert s.__class__.__name__ == 'Entry', s.__class__.__name__ assert s.path == 'mylib.pdb' assert s.side_effect assert foo.side_effects == [s] @@ -1616,6 +1648,7 @@ class EnvironmentTestCase(unittest.TestCase): fff = env.Object('fff.obj', 'fff.cpp') bbb = env.Object('bbb.obj', 'bbb.cpp') s = env.SideEffect('my${LIB}.pdb', ['${FOO}.obj', '${BAR}.obj']) + assert s.__class__.__name__ == 'File', s.__class__.__name__ assert s.path == 'mylll.pdb' assert s.side_effect assert fff.side_effects == [s], fff.side_effects @@ -1623,6 +1656,17 @@ class EnvironmentTestCase(unittest.TestCase): assert s.depends_on([bbb]) assert s.depends_on([fff]) + ggg = env.Object('ggg.obj', 'ggg.cpp') + ccc = env.Object('ccc.obj', 'ccc.cpp') + s = env.SideEffect('mymmm.pdb', ['ggg.obj', 'ccc.obj']) + assert s.__class__.__name__ == 'Dir', s.__class__.__name__ + assert s.path == 'mymmm.pdb' + assert s.side_effect + assert ggg.side_effects == [s], ggg.side_effects + assert ccc.side_effects == [s], ccc.side_effects + assert s.depends_on([ccc]) + assert s.depends_on([ggg]) + def test_SourceCode(self): """Test the SourceCode() method.""" env = Environment(FOO='mmm', BAR='nnn') |