1
votes

Hey I've written a custom builder that should work differently for my .c files as well as a .structdoc file. Here's the SConstruct file

env = Environment()
prepare_structdoc = Builder(action='python prep_structdoc.py < $SOURCE > $TARGET', suffix='.structdoc', src_suffix='.c')
prepare_postc = Builder(action='python preprocess_mods.py < $SOURCE > $TARGET', suffix='.postc', src_suffix='.structdoc')

env['BUILDERS']['StructdocBuilder'] = prepare_structdoc
env['BUILDERS']['PostcBuilder'] = prepare_postc
SConscript('mods/SConscript', exports='env')

These builders work on One source and produce One Target, so i run a loop in the SConscript over all *.c files like this

Import("env")
for fname in Glob("*.c"):
    struct_doc= env.StructdocBuilder(source=fname)
    post_c = env.PostcBuilder(source=struct_doc)

This does the trick. However, i would like it to use these builders only for one file if i mention so . i.e. inside mods/ i specify scons -u abc.c.

Ive tried using COMMAND_LINE_TARGETS as follows:

Import("env")
for fname in COMMAND_LINE_TARGETS or Glob("*.c"):
    struct_doc= env.StructdocBuilder(source=fname)
    post_c = env.PostcBuilder(source=struct_doc)

scons -u mod_dummy.c but the output it gives me is
scons: Building targets ...
scons: Nothing to be done for `mods/mod_dummy.c'.
scons: done building targets.

it is one of the targets in COMMAND_LINE_TARGETS but it isnt going inside this loop for some reason. There must be a way of achieving this.
How do i modify the code to work for just one of them ?

1
did you to a clean to make sure it actually needed to build something? - Tom Tanner

1 Answers

0
votes

You just need to specify the target node, not the source node on the commandline.

scons -u abc.postc