SCons supports a
that lets you get at the list of targets that the
user specified on the command line.
You can use the targets to manipulate the
build in any way you wish.
As a simple example,
suppose that you want to print a reminder
to the user whenever a specific program is built.
You can do this by checking for the
target in the
if 'bar' in COMMAND_LINE_TARGETS: print "Don't forget to copy `bar' to the archive!" Default(Program('foo.c')) Program('bar.c')
Then, running SCons with the default target works as it always does, but explicity specifying the bar target on the command line generates the warning message:
% scons -Q cc -o foo.o -c foo.c cc -o foo foo.o % scons -Q bar Don't forget to copy `bar' to the archive! cc -o bar.o -c bar.c cc -o bar bar.o
Another practical use for the
might be to speed up a build
by only reading certain subsidiary SConscript
files if a specific target is requested.