Creating a &Builder; and attaching it to a &consenv;
allows for a lot of flexibility when you
want to re-use the same actions
to build multiple files of the same type.
This can, however, be cumbersome
if you only need to execute one specific command
to build a single file (or single group of files).
For these situations, &SCons; supports a
&Command; &Builder; that arranges
for a specific action to be executed
to build a specific file or files.
This looks a lot like the other builders
(like &Program;, &Object;, etc.),
but takes as an additional argument
the command to be executed to build the file:
env = Environment()
env.Command('foo.out', 'foo.in', "sed 's/x/y/' < $TARGET > $SOURCE")
% scons .
sed 's/x/y' < foo.in > foo.out
This is often more convenient than
creating a &Builder; object
and adding it to the &BUILDERS; variable
of a &consenv;
Note that the action you
env = Environment()
def build(target, source, env)
XXX
return None
env.Command('foo.out', 'foo.in', build)
% scons .
build("foo.out", "foo.in")