Revision 1 as of 2007-01-14 12:26:32
Added new page EnvValue
converted to 1.6 markup
|No differences found!|
This value node has a string argument which substitutes values from the environment. This is usefull for:
- Generating small initialization files
- Ensuring that builders which are python function gets the correct dependencies if the function uses environment values.
1 import SCons.Node.Python 2 3 class EnvValue(SCons.Node.Python.Value): 4 """Node class which substitutes variables from the environment""" 5 def __init__(self,env,value): 6 """Initialiser takes an Environment and a string to be 7 expanded.""" 8 SCons.Node.Python.Value.__init__(self,value) 9 self.env=env 10 def __str__(self): 11 return env.subst(self.value)
Now you can do something like this:
There is one scenario in which the results might not be as expected. This is when the builder creates an override environment. In this case the environment used for the value node is not the same as that used for the builder:
In this example the command becomes
For a builder which is a python function which references environment values, you might want to have add an emitter function which adds a EnvValue as a dependency (I have not tried that yet).