From: stevenknight Date: Sat, 5 Jan 2002 20:07:24 +0000 (+0000) Subject: Refactor BuilderBase.__call__() to separate node creation from attribute initialization. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=f732fda9d0f6957263ef18fb642025662cca265a;p=scons.git Refactor BuilderBase.__call__() to separate node creation from attribute initialization. git-svn-id: http://scons.tigris.org/svn/scons/trunk@190 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 856d6dc0..e1e57ec5 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Builder.py b/src/engine/SCons/Builder.py index 0cf70e41..6651b138 100644 --- a/src/engine/SCons/Builder.py +++ b/src/engine/SCons/Builder.py @@ -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