Commits

Anonymous committed d733957

Refactor the Builder binding so the calling Environment gets passed in.

Comments (0)

Files changed (3)

src/scons/Builder.py

     def __cmp__(self, other):
 	return cmp(self.__dict__, other.__dict__)
 
-    def __call__(self, target = None, source = None):
+    def __call__(self, env, target = None, source = None):
 	node = lookup(self.node_class, target)
 	node.builder_set(self)
+	node.env_set(self)
 	node.sources = source	# XXX REACHING INTO ANOTHER OBJECT
 	return node
 

src/scons/Environment.py

 	    import scons.Defaults
 	    kw['BUILDERS'] = scons.Defaults.Builders[:]
 	self.Dictionary.update(copy.deepcopy(kw))
+
+	class BuilderWrapper:
+	    """Wrapper class that allows an environment to
+	    be associated with a Builder at instantiation.
+	    """
+	    def __init__(self, env, builder):
+		self.env = env
+		self.builder = builder
+	
+	    def __call__(self, target = None, source = None):
+		return self.builder(self.env, target, source)
+
+	    def execute(self, **kw):
+		apply(self.builder.execute, (), kw)
+
 	for b in kw['BUILDERS']:
-	    setattr(self, b.name, b)
+	    setattr(self, b.name, BuilderWrapper(self, b))
+
+
 
     def __cmp__(self, other):
 	return cmp(self.Dictionary, other.Dictionary)

src/scons/Node/__init__.py

 
     def builder_set(self, builder):
 	self.builder = builder
+
+    def env_set(self, env):
+	self.env = env