Refactor Builders to remove the node_factory keyword argument (in favor of the separa...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 4 May 2004 22:19:53 +0000 (22:19 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 4 May 2004 22:19:53 +0000 (22:19 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@970 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/RELEASE.txt
src/engine/SCons/Builder.py
src/engine/SCons/BuilderTests.py

index e651afb25b544b22fbdebf06e7ef1d069fe33c55..4964fb2f2bfa2d76fbec7474b7883ee5b36cd7ca 100644 (file)
@@ -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
index 55ea07fd7acc77efa2daa69eb0c2bce9002eff71..5c75a0f8056cb97baa52bd79884dd568acffc555 100644 (file)
@@ -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 ]
index bd254b02e331b7ccdb363d80f64741fe1f911a70..e33d95c04c395f1a470a2e5e4ce4930c2c34677c 100644 (file)
@@ -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')