.TP
.RI Append( key = val ", [...])"
Appends the specified keyword arguments
-to the construction variables in the environment.
+to the end of construction variables in the environment.
If the Environment does not have
the specified construction variable,
it is simply added to the environment.
and the value of the keyword argument
are both coerced to lists,
and the lists are added together.
+(See also the Prepend method, below.)
.ES
env.Append(CCFLAGS = ' -g', FOO = ['foo.yyy'])
Multiple targets can be passed in to a single call to
.BR Precious ().
+.TP
+.RI Prepend( key = val ", [...])"
+Appends the specified keyword arguments
+to the beginning of construction variables in the environment.
+If the Environment does not have
+the specified construction variable,
+it is simply added to the environment.
+If the values of the construction variable
+and the keyword argument are the same type,
+then the two values will be simply added together.
+Otherwise, the construction variable
+and the value of the keyword argument
+are both coerced to lists,
+and the lists are added together.
+(See also the Append method, above.)
+
+.ES
+env.Prepend(CCFLAGS = '-g ', FOO = ['foo.yyy'])
+.EE
+
.TP
.RI Replace( key = val ", [...])"
Replaces construction variables in the Environment
RELEASE 0.09 -
+ From Chad Austin:
+
+ - Add a Prepend() method to Environments, to append values to
+ the beginning of construction variables.
+
From Steven Knight:
- Add Repository() functionality.
self._dict[key] = self._dict[key] + kw[key]
self.__updateBuildersAndScanners()
+ def Prepend(self, **kw):
+ """Prepend values to existing construction variables
+ in an Environment.
+ """
+ kw = our_deepcopy(kw)
+ for key in kw.keys():
+ if not self._dict.has_key(key):
+ self._dict[key] = kw[key]
+ elif SCons.Util.is_List(self._dict[key]) and not \
+ SCons.Util.is_List(kw[key]):
+ self._dict[key] = [ kw[key] ] + self._dict[key]
+ elif SCons.Util.is_List(kw[key]) and not \
+ SCons.Util.is_List(self._dict[key]):
+ self._dict[key] = kw[key] + [ self._dict[key] ]
+ else:
+ self._dict[key] = kw[key] + self._dict[key]
+ self.__updateBuildersAndScanners()
+
def Depends(self, target, dependency):
"""Explicity specify that 'target's depend on 'dependency'."""
tlist = SCons.Node.arg2nodes(target, self.fs.File)
except:
raise
+ def test_Prepend(self):
+ """Test prepending to construction variables in an Environment
+ """
+ import UserList
+ UL = UserList.UserList
+ env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd',
+ EEE = ['e'], FFF = ['f'], GGG = ['g'], HHH = ['h'],
+ III = UL(['i']), JJJ = UL(['j']),
+ KKK = UL(['k']), LLL = UL(['l']))
+ env1.Prepend(BBB = 'B', CCC = ['C'], DDD = UL(['D']),
+ FFF = 'F', GGG = ['G'], HHH = UL(['H']),
+ JJJ = 'J', KKK = ['K'], LLL = UL(['L']))
+ env2 = Environment(AAA = 'a', BBB = 'Bb',
+ CCC = ['C', 'c'], DDD = UL(['D', 'd']),
+ EEE = ['e'], FFF = ['F', 'f'],
+ GGG = ['G', 'g'], HHH = UL(['H', 'h']),
+ III = UL(['i']), JJJ = UL(['J', 'j']),
+ KKK = UL(['K', 'k']), LLL = UL(['L', 'l']))
+ assert env1 == env2, diff_env(env1, env2)
+
+ env3 = Environment(X = {'x' : 7})
+ try:
+ env3.Prepend(X = {'x' : 8})
+ except TypeError:
+ pass
+ except:
+ raise
+
def test_Depends(self):
"""Test the explicit Depends method."""
env = Environment()