def __init__(self, **kw):
import SCons.Defaults
self._dict = our_deepcopy(SCons.Defaults.ConstructionEnvironment)
- if kw.has_key('BUILDERS') and type(kw['BUILDERS']) != type([]):
- kw['BUILDERS'] = [kw['BUILDERS']]
- if kw.has_key('SCANNERS') and type(kw['SCANNERS']) != type([]):
- kw['SCANNERS'] = [kw['SCANNERS']]
- self._dict.update(our_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)
-
- # This allows a Builder to be executed directly
- # through the Environment to which it's attached.
- # In practice, we shouldn't need this, because
- # builders actually get executed through a Node.
- # But we do have a unit test for this, and can't
- # yet rule out that it would be useful in the
- # future, so leave it for now.
- def execute(self, **kw):
- kw['env'] = self
- apply(self.builder.execute, (), kw)
-
- for b in self._dict['BUILDERS']:
- setattr(self, b.name, BuilderWrapper(self, b))
-
- for s in self._dict['SCANNERS']:
- setattr(self, s.name, s)
-
+ apply(self.Update, (), kw)
+
+ def __mungeDict(self):
+ """Take care of any special attributes in our dictionary."""
+
+
def __cmp__(self, other):
return cmp(self._dict, other._dict)
construction variables and/or values.
"""
self._dict.update(our_deepcopy(kw))
+ if self._dict.has_key('BUILDERS') and \
+ type(self._dict['BUILDERS']) != type([]):
+ self._dict['BUILDERS'] = [self._dict['BUILDERS']]
+ if self._dict.has_key('SCANNERS') and \
+ type(self._dict['SCANNERS']) != type([]):
+ self._dict['SCANNERS'] = [self._dict['SCANNERS']]
+
+ 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)
+
+ # This allows a Builder to be executed directly
+ # through the Environment to which it's attached.
+ # In practice, we shouldn't need this, because
+ # builders actually get executed through a Node.
+ # But we do have a unit test for this, and can't
+ # yet rule out that it would be useful in the
+ # future, so leave it for now.
+ def execute(self, **kw):
+ kw['env'] = self.env
+ apply(self.builder.execute, (), kw)
+
+ for b in self._dict['BUILDERS']:
+ setattr(self, b.name, BuilderWrapper(self, b))
+
+ for s in self._dict['SCANNERS']:
+ setattr(self, s.name, s)
def Depends(self, target, dependency):
"""Explicity specify that 'target's depend on 'dependency'."""
assert built_it['out1']
built_it = {}
- env3 = Environment(BUILDERS = [b1, b2])
+ env3 = Environment()
+ env3.Update(BUILDERS = [b1, b2])
env3.builder1.execute(target = 'out1')
env3.builder2.execute(target = 'out2')
env3.builder1.execute(target = 'out3')
assert built_it['out2']
assert built_it['out3']
+ env4 = env3.Copy()
+ assert env4.builder1.env is env4
+ assert env4.builder2.env is env4
+
def test_Scanners(self):
"""Test Scanner execution through different environments
assert scanned_it['out1']
scanned_it = {}
- env3 = Environment(SCANNERS = [s1, s2])
+ env3 = Environment()
+ env3.Update(SCANNERS = [s1, s2])
env3.scanner1.scan(filename = 'out1')
env3.scanner2.scan(filename = 'out2')
env3.scanner1.scan(filename = 'out3')