Here is a fragment that illustrates how to make Phony targets that run commands. The AlwaysBuild line makes sure the command runs even if there happens to be a file named the same as the target.
Here's a better implementation that handles multiple targets and doesn't require generating an Environment every time.
1 def PhonyTargets(env = None, **kw):
2 if not env: env = DefaultEnvironment()
3 for target,action in kw.items():
4 env.AlwaysBuild(env.Alias(target, [], action))
5
6 PhonyTargets(TAGS = 'tools/mktags.sh -e')
7
8 env = Environment(parse_flags = '-std=c89 -DFOO -lm')
9 PhonyTargets(env, CFLAGS = '@echo $CFLAGS',
10 DEFINES = '@echo $CPPDEFINES',
11 LIBS = '@echo $LIBS')
The output looks like this:
$ scons TAGS tools/mktags.sh -e ... $ scons CFLAGS -std=c89 $ scons DEFINES FOO $ scons LIBS m
