|
Size: 497
Comment: converted to 1.6 markup
|
← Revision 3 as of 2008-03-20 00:21:12 ⇥
Size: 1202
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| 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 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. |
| Line 11: | Line 11: |
Here's a better implementation that handles multiple targets and doesn't require generating an Environment every time. {{{#!python def PhonyTargets(env = None, **kw): if not env: env = DefaultEnvironment() for target,action in kw.items(): env.AlwaysBuild(env.Alias(target, [], action)) PhonyTargets(TAGS = 'tools/mktags.sh -e') env = Environment(parse_flags = '-std=c89 -DFOO -lm') PhonyTargets(env, CFLAGS = '@echo $CFLAGS', DEFINES = '@echo $CPPDEFINES', LIBS = '@echo $LIBS') }}} The output looks like this: {{{ $ scons TAGS tools/mktags.sh -e ... $ scons CFLAGS -std=c89 $ scons DEFINES FOO $ scons LIBS m }}} |
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
