env3 = env.Copy(CCFLAGS = '-g')
.EE
+Additionally, a list of tools may be specified, as in the Environment
+constructor:
+
+.ES
+def MyTool(env): env['FOO'] = 'bar'
+env4 = env.Copy(tools = ['msvc', MyTool])
+.EE
+
+
.TP
.RI CVS( repository ", " module )
A factory function that
RELEASE 0.XX - XXX
+ From Chad Austin:
+
+ - Support specifying a list of tools when calling Environment.Copy().
+
From Steven Knight:
- Tighten up the scons -H help output.
copy = x
return copy
+def apply_tools(env, tools):
+ if tools:
+ for tool in tools:
+ if SCons.Util.is_String(tool):
+ tool = SCons.Tool.Tool(tool)
+ tool(env)
+
class BuilderWrapper:
"""Wrapper class that associates an environment with a Builder at
instantiation."""
if tools is None:
tools = ['default']
- for tool in tools:
- if SCons.Util.is_String(tool):
- tool = SCons.Tool.Tool(tool)
- tool(self)
+ apply_tools(self, tools)
# Reapply the passed in variables after calling the tools,
# since they should overide anything set by the tools:
def Builders(self):
pass # XXX
- def Copy(self, **kw):
+ def Copy(self, tools=None, **kw):
"""Return a copy of a construction Environment. The
copy is like a Python "deep copy"--that is, independent
copies are made recursively of each objects--except that
clone._dict['BUILDERS'] = BuilderDict(cbd, clone)
except KeyError:
pass
+
+ apply_tools(clone, tools)
+
+ # Apply passed-in variables after the new tools.
apply(clone.Replace, (), kw)
return clone
assert hasattr(env2, 'b2'), "env2.b2 was not set"
assert env2.b2.env == env2, "b2.env doesn't point to env2"
+ # Ensure that specifying new tools in a copied environment
+ # works.
+ def foo(env): env['FOO'] = 1
+ def bar(env): env['BAR'] = 2
+ def baz(env): env['BAZ'] = 3
+ env1 = Environment(tools=[foo])
+ env2 = env1.Copy()
+ env3 = env1.Copy(tools=[bar, baz])
+
+ assert env1.get('FOO') is 1
+ assert env1.get('BAR') is None
+ assert env1.get('BAZ') is None
+ assert env2.get('FOO') is 1
+ assert env2.get('BAR') is None
+ assert env2.get('BAZ') is None
+ assert env3.get('FOO') is 1
+ assert env3.get('BAR') is 2
+ assert env3.get('BAZ') is 3
+
def test_Dictionary(self):
"""Test retrieval of known construction variables