SCons User Guide 0.92 | ||
---|---|---|
<<< Previous | Writing Your Own Builders | Next >>> |
SCons Builder objects can create an action "on the fly" by using a function called a generator. This provides a great deal of flexibility XXX A generator looks like:
def generate_actions(source, target, env, for_signature): return XXX |
The arguments of a generator are:
A list of Node objects representing the sources to be built by the command or other action generated by this function. The file names of these source(s) may be extracted using the Python str funcion.
A list of Node objects representing the target or targets to be built by the command or other action generated by this function. The file names of these target(s) may be extracted using the Python str funcion.
The construction environment used for building the target(s). The generator may use any of the environment's construction variables in any way to determine what command or other action to return.
A flag that specifies whether the generator is being called to contribute to a build signature, as opposed to actually executing the command. XXX
The generator must return a command string or other action that will be used to build the specified target(s) from the specified source(s).
Once you've defined a generator, you create a Builder to use it by specifying the generator keyword argument instead of action.
bld = Builder(generator = generate_actions, suffix = '.foo', src_suffix = '.input') env = Environment(BUILDERS = {'Foo' : bld}) env.Foo('file') |
% scons
XXX
Note that it's illegal to specify both an action and a generator for a Builder.
<<< Previous | Home | Next >>> |
Builders That Execute Python Functions | Up | Builders That Modify the Target or Source Lists Using an Emitter |