[Scons-users] How to deal with a list of targets in a Command	builder?
    Carsten Fuchs 
    carsten.fuchs at cafu.de
       
    Mon Feb  9 05:29:08 EST 2015
    
    
  
Dear SCons fellows,
at this time I use SCons to build my project's C++ programs. This is 
followed by a series of manual, custom steps to build the related 
reference documentation.
Please consider this outline of the process:
   1. Run `scons` to build the C++ programs.
   2. Call one of the built programs with a command line parameter. The 
program (named "CaWE") then creates a set of *.hpp files in a predefined 
directory relative to the project root, possibly overwriting existing 
files. More specifically, running in the project directory something 
like `build\win32\vc11\x86\debug\CaWE\CaWE.exe --update-doxygen` 
generates all `Doxygen/scripting/tmpl/*.hpp` files.
   3. Have a small, custom Python script loop over all these files and 
run some tests on their contents, e.g. absence of lines with string "// 
WARNING:" in them. Also if file `Doxygen/scripting/tmpl/X.hpp` has lines 
that are not (yet) present in its sibling file 
`Doxygen/scripting/src/X.hpp` (in `src/`, not `tmpl/`), the script stops 
with an error.
   4. If step 3. found any problem at all, manual intervention is 
necessary: As the actual documentation source is in `src/`, not `tmpl/`, 
the situation must now be manually examined, usually with a directory 
comparison/diff tool with which differences between the files in `src/` 
and `tmpl/` can manually be fixed. Once step 3. is successful, there is 
a set of *.hpp files in the `src/` directory that meets the criteria as 
defined by step 3's script.
   5. Eventually run Doxygen on directory `Doxygen/scripting/src/` and 
upload the resulting output to a public website.
I have implemented steps 2, 3, and 5 as standalone Python scripts, which 
are in fact quite short and simple. Now I would like to migrate steps 2 
and 3 into the SCons script of step 1, in order to reduce the manual 
work and to auto-run the tests of step 3 after each successful build of 
the "CaWE" program.
Unfortunately, starting with moving step 2 into the `SConscript` file of 
a variant build, I did not get very far:
~~~~~~
# ...
progCaWE = envCaWE.Program('CaWE/CaWE', SourceFilesList)
def UpdateDocTemplates(target, source, env):
     print "target:", target
     print "source:", source
     # TODO: Run the CaWE program as given in `source` with added 
`--update-doxygen` switch.
     return None
if buildMode=="dbg":
     envCaWE.Command("#/Doxygen/scripting/tmpl", progCaWE, 
UpdateDocTemplates)
~~~~~~
This never prints anything, probably because the target directory exists 
and is not the real target anyway: the real targets are the *.hpp files 
in that directory, which possibly not exist before the build and which I 
don't know how to specify properly.
So this is my question: How do I properly specify the 
`#/Doxygen/scripting/tmpl/*.hpp` files, which are unknown ahead of 
running the build, as a target for the custom Command builder?
These target files would be used as source files for the next step (step 
3), and I believe coping with this will be much easier, because there, 
each source file (in `tmpl/`) has a clearly defined target (the sibling 
in `src/`).
Any hint would very much be appreciated!
Many thanks and best regards,
Carsten
    
    
More information about the Scons-users
mailing list