diff options
author | Steven Knight <knight@baldmt.com> | 2005-03-19 04:09:34 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2005-03-19 04:09:34 (GMT) |
commit | ae7d0a92dbd26115a52905c2593b2715a4ec54c0 (patch) | |
tree | e19b396b3d6c813ad9992dfe772f5da3d55e03d5 /src | |
parent | 12158becc0aaee3b5b486a00bdd304f331ab4b24 (diff) | |
download | SCons-ae7d0a92dbd26115a52905c2593b2715a4ec54c0.zip SCons-ae7d0a92dbd26115a52905c2593b2715a4ec54c0.tar.gz SCons-ae7d0a92dbd26115a52905c2593b2715a4ec54c0.tar.bz2 |
Fix Builders with empty source lists. (Stanislav Baranov)
Diffstat (limited to 'src')
-rw-r--r-- | src/CHANGES.txt | 2 | ||||
-rw-r--r-- | src/engine/SCons/Builder.py | 10 | ||||
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 16 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index d6edd56..ae16481 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -29,6 +29,8 @@ RELEASE 0.97 - XXX - Make it possible to support with custom Alias (sub-)classes. + - Allow Builders to take empty source lists when called. + From Timothee Besset: - Add support for Objective C/C++ .m and .mm file suffixes (for diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index a20757e..7069ef0 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -152,6 +152,9 @@ class DictCmdGenerator(SCons.Util.Selector): self[suffix] = action def __call__(self, target, source, env, for_signature): + if not source: + return [] + ext = None for src in map(str, source): my_ext = SCons.Util.splitext(src)[1] @@ -506,8 +509,11 @@ class BuilderBase: t_from_s = slist[0].target_from_source except AttributeError: raise UserError("Do not know how to create a target from source `%s'" % slist[0]) - splitext = lambda S,self=self,env=env: self.splitext(S,env) - tlist = [ t_from_s(pre, suf, splitext) ] + except IndexError: + tlist = [] + else: + splitext = lambda S,self=self,env=env: self.splitext(S,env) + tlist = [ t_from_s(pre, suf, splitext) ] else: target = _adjustixes(target, pre, suf) tlist = env.arg2nodes(target, self.target_factory) diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index 8d60d33..09927f1 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -219,6 +219,9 @@ class BuilderTestCase(unittest.TestCase): target_factory=MyNode, source_factory=MyNode) + tgt = builder(env, source=[]) + assert tgt == [], tgt + n1 = MyNode("n1") n2 = MyNode("n2") builder(env, target = n1, source = n2) @@ -667,6 +670,10 @@ class BuilderTestCase(unittest.TestCase): env = Environment() builder = SCons.Builder.Builder(action = function2) + + tgts = builder(env, source=[]) + assert tgts == [], tgts + tgts = builder(env, target = [outfile, outfile2], source = 'foo') for t in tgts: t.prepare() @@ -715,6 +722,9 @@ class BuilderTestCase(unittest.TestCase): src_builder = builder1, src_suffix = '.foo') + tgt = builder2(env, source=[]) + assert tgt == [], tgt + tgt = builder2(env, target='baz', source=['test.bar', 'test2.foo', 'test3.txt'])[0] assert str(tgt.sources[0]) == 'test.foo', str(tgt.sources[0]) @@ -763,15 +773,21 @@ class BuilderTestCase(unittest.TestCase): '.bar' : func_action, '$BAR_SUFFIX' : func_action, '$FOO_SUFFIX' : func_action }) + + tgt = builder(env, source=[]) + assert tgt == [], tgt assert isinstance(builder, SCons.Builder.CompositeBuilder) assert isinstance(builder.action, SCons.Action.CommandGeneratorAction) + tgt = builder(env, target='test1', source='test1.foo')[0] assert isinstance(tgt.builder, SCons.Builder.BuilderBase) assert tgt.builder.action is builder.action + tgt = builder(env, target='test2', source='test1.bar')[0] assert isinstance(tgt.builder, SCons.Builder.BuilderBase) assert tgt.builder.action is builder.action + flag = 0 tgt = builder(env, target='test3', source=['test2.bar', 'test1.foo'])[0] try: |