Refactor BuilderBase.__call__() to separate node creation from attribute initialization.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Jan 2002 20:07:24 +0000 (20:07 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 5 Jan 2002 20:07:24 +0000 (20:07 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@190 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Builder.py

index 856d6dc0af89571cd86b3f7b578207df13c4bc01..e1e57ec5b16e91a8efdfb9d1edba41446161266a 100644 (file)
@@ -27,6 +27,9 @@ RELEASE 0.03 -
     factory wrapper to the __init__() method, and allow a Builder to
     have both an action and a src_builder (or array of them).
 
+  - Refactor BuilderBase.__call__() to separate Node creation/lookup
+    from initialization of the Node's builder information.
+
   From Anthony Roach:
 
   - Add a "duplicate" keyword argument to BuildDir() that can be set
index 0cf70e4133b2ceb45556743e016e8a3951726eb8..6651b1387180a453a382514749dc391d34f26c01 100644 (file)
@@ -160,7 +160,9 @@ class BuilderBase:
     def __cmp__(self, other):
        return cmp(self.__dict__, other.__dict__)
 
-    def __call__(self, env, target = None, source = None):
+    def _create_nodes(self, env, target = None, source = None):
+        """Create and return lists of target and source nodes.
+        """
        def adjustixes(files, pre, suf):
            ret = []
             if type(files) is types.StringType or isinstance(files, UserString):
@@ -183,10 +185,16 @@ class BuilderBase:
                                            env.subst(self.suffix)),
                                 self.node_factory)
 
-       slist = scons_str2nodes(adjustixes(source, None,
+        slist = scons_str2nodes(adjustixes(source,
+                                           None,
                                            env.subst(self.src_suffix)),
                                 self.node_factory)
+        return tlist, slist
 
+    def _init_nodes(self, env, tlist, slist):
+        """Initialize lists of target and source nodes with all of
+        the proper Builder information.
+        """
        for t in tlist:
             t.cwd = SCons.Node.FS.default_fs.getcwd()  # XXX
            t.builder_set(self)
@@ -201,6 +209,11 @@ class BuilderBase:
             if scanner:
                 s.scanner_set(scanner.instance(env))
 
+    def __call__(self, env, target = None, source = None):
+       tlist, slist = self._create_nodes(env, target, source)
+
+       self._init_nodes(env, tlist, slist)
+
        if len(tlist) == 1:
            tlist = tlist[0]
        return tlist