diff options
author | Steven Knight <knight@baldmt.com> | 2004-05-04 22:19:53 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-05-04 22:19:53 (GMT) |
commit | 2a9941e968724723c70f106401fe8b984add626a (patch) | |
tree | 4fd1aa25b19acbfb905c673310fc8b68719cd1af | |
parent | 10efdf16045175fdd2deaa9b23ca73ebe7ead441 (diff) | |
download | SCons-2a9941e968724723c70f106401fe8b984add626a.zip SCons-2a9941e968724723c70f106401fe8b984add626a.tar.gz SCons-2a9941e968724723c70f106401fe8b984add626a.tar.bz2 |
Refactor Builders to remove the node_factory keyword argument (in favor of the separate and more flexible target_factory and source_factory keywords).
-rw-r--r-- | src/RELEASE.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Builder.py | 16 | ||||
-rw-r--r-- | src/engine/SCons/BuilderTests.py | 34 |
3 files changed, 26 insertions, 28 deletions
diff --git a/src/RELEASE.txt b/src/RELEASE.txt index e651afb..4964fb2 100644 --- a/src/RELEASE.txt +++ b/src/RELEASE.txt @@ -53,6 +53,10 @@ RELEASE 0.96 - XXX DScan.add_skey('.x') => env.Append(DSUFFIXES = ['.x']) FortranScan.add_skey('.x') => env.Append(FORTRANSUFFIXES = ['.x']) + - The internal "node_factory" keyword argument has been removed; + the seperate and more flexible "target_factory" and "source_factory" + keywords should be used instead. + - The behavior of the env.Append() and env.Prepend() methods has changed when appending a string value to a UserList, or vice versa. They now behave like normal Python addition of a string to diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 55ea07f..5c75a0f 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -387,9 +387,8 @@ class BuilderBase: prefix = '', suffix = '', src_suffix = '', - node_factory = SCons.Node.FS.default_fs.File, - target_factory = None, - source_factory = None, + target_factory = SCons.Node.FS.default_fs.File, + source_factory = SCons.Node.FS.default_fs.File, scanner = None, emitter = None, multi = 0, @@ -415,8 +414,8 @@ class BuilderBase: self.set_src_suffix(src_suffix) - self.target_factory = target_factory or node_factory - self.source_factory = source_factory or node_factory + self.target_factory = target_factory + self.source_factory = source_factory self.scanner = scanner self.emitter = emitter @@ -627,14 +626,13 @@ class MultiStepBuilder(BuilderBase): prefix = '', suffix = '', src_suffix = '', - node_factory = SCons.Node.FS.default_fs.File, - target_factory = None, - source_factory = None, + target_factory = SCons.Node.FS.default_fs.File, + source_factory = SCons.Node.FS.default_fs.File, scanner=None, emitter=None): if __debug__: logInstanceCreation(self) BuilderBase.__init__(self, action, prefix, suffix, src_suffix, - node_factory, target_factory, source_factory, + target_factory, source_factory, scanner, emitter) if not SCons.Util.is_List(src_builder): src_builder = [ src_builder ] diff --git a/src/engine/SCons/BuilderTests.py b/src/engine/SCons/BuilderTests.py index bd254b0..e33d95c 100644 --- a/src/engine/SCons/BuilderTests.py +++ b/src/engine/SCons/BuilderTests.py @@ -199,7 +199,9 @@ class BuilderTestCase(unittest.TestCase): """Test calling a builder to establish source dependencies """ env = Environment() - builder = SCons.Builder.Builder(action="foo", node_factory=MyNode) + builder = SCons.Builder.Builder(action="foo", + target_factory=MyNode, + source_factory=MyNode) n1 = MyNode("n1"); n2 = MyNode("n2"); @@ -255,7 +257,8 @@ class BuilderTestCase(unittest.TestCase): assert flag, "UserError should be thrown if a source node can't create a target." builder = SCons.Builder.Builder(action="foo", - node_factory=MyNode, + target_factory=MyNode, + source_factory=MyNode, prefix='p-', suffix='.s') target = builder(env, source='n21') @@ -326,18 +329,6 @@ class BuilderTestCase(unittest.TestCase): assert b1 != b3 assert b2 != b3 - def test_node_factory(self): - """Test a Builder that creates nodes of a specified class - """ - class Foo: - pass - def FooFactory(target): - global Foo - return Foo(target) - builder = SCons.Builder.Builder(node_factory = FooFactory) - assert builder.target_factory is FooFactory - assert builder.source_factory is FooFactory - def test_target_factory(self): """Test a Builder that creates target nodes of a specified class """ @@ -843,7 +834,8 @@ class BuilderTestCase(unittest.TestCase): env = Environment() builder = SCons.Builder.Builder(action='foo', emitter=emit, - node_factory=MyNode) + target_factory=MyNode, + source_factory=MyNode) tgt = builder(env, target='foo2', source='bar') assert str(tgt) == 'foo2', str(tgt) assert str(tgt.sources[0]) == 'bar', str(tgt.sources[0]) @@ -862,7 +854,8 @@ class BuilderTestCase(unittest.TestCase): env2=Environment(FOO=emit) builder2=SCons.Builder.Builder(action='foo', emitter="$FOO", - node_factory=MyNode) + target_factory=MyNode, + source_factory=MyNode) tgt = builder2(env2, target='foo5', source='bar') assert str(tgt) == 'foo5', str(tgt) @@ -881,7 +874,8 @@ class BuilderTestCase(unittest.TestCase): builder2a=SCons.Builder.Builder(action='foo', emitter="$FOO", - node_factory=MyNode) + target_factory=MyNode, + source_factory=MyNode) assert builder2 == builder2a, repr(builder2.__dict__) + "\n" + repr(builder2a.__dict__) # Test that, if an emitter sets a builder on the passed-in @@ -897,7 +891,8 @@ class BuilderTestCase(unittest.TestCase): builder3=SCons.Builder.Builder(action='foo', emitter=emit3, - node_factory=MyNode) + target_factory=MyNode, + source_factory=MyNode) tgt = builder3(env, target=node, source='bar') assert tgt is new_node, tgt assert tgt.builder is builder3, tgt.builder @@ -916,7 +911,8 @@ class BuilderTestCase(unittest.TestCase): builder4 = SCons.Builder.Builder(action='foo', emitter={'.4a':emit4a, '.4b':emit4b}, - node_factory=MyNode) + target_factory=MyNode, + source_factory=MyNode) tgt = builder4(env, source='aaa.4a') assert str(tgt) == 'emit4a-aaa', str(tgt) tgt = builder4(env, source='bbb.4b') |