I'd like to be able to replace a template variable ('$(SOFTWARE_VERSION)') while installing some python scripts from scons. Does scons already have such functionality? If not, what's the best way to hook into the scons install process so I can do this during install?
Click the start button, (on XP click Run), then type cmd and from the command line type python -V. It should say something like Python 2.7. 2. Any version 2.4 or higher is ok for SCons.
DESCRIPTION. The scons utility builds software (or other files) by determining which component pieces must be rebuilt and executing the necessary commands to rebuild them.
The SConstruct File. If you're used to build systems like Make you've already figured out that the SConstruct file is the SCons equivalent of a Makefile. That is, the SConstruct file is the input file that SCons reads to control the build.
The command 'scons --max-drift=1 --implicit-deps-unchanged' will execute your build as fast as possible.
You could use the Substfile
method. This takes a input file and produces an output file substituting marked variables. So if you have script.py.in
:
#!/usr/bin/python
print "$SOFTWARE_VERSION"
Then you can use the following SConsctruct file to generate an output:
env = Environment(tools=['textfile'])
script_dict = {'\$SOFTWARE_VERSION': '1.0'}
env.Substfile('script.py.in', SUBST_DICT = script_dict)
You need to escape the $
in the string '\$SOFTWARE_VERSION'
otherwise SCons interprets it as an internal environment variable. The result would be a file script.py
with this contents:
#!/usr/bin/python
print "1.0"
You can then install this resulting substituted file using env.Install
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With