SCons User Guide 2.0.0.final.0 | ||
---|---|---|
Prev |
There is a common set of simple tasks that many build configurations rely on as they become more complex. Most build tools have special purpose constructs for performing these tasks, but since SConscript files are Python scripts, you can use more flexible built-in Python services to perform these tasks. This appendix lists a number of these tasks and how to implement them in Python.
Example D-2. Filename extension substitution
import os.path filename = os.path.splitext(filename)[0]+extension
Example D-3. Appending a path prefix to a list of filenames
import os.path filenames = [os.path.join(prefix, x) for x in filenames]
Example D-4. Substituting a path prefix with another one
if filename.find(old_prefix) == 0: filename = filename.replace(old_prefix, new_prefix)