[Scons-users] Build Order
Russell, J.J.
russell at slac.stanford.edu
Sat Jul 12 14:29:50 EDT 2014
Before compiling some C code, an include directory which that code uses needs to be populated. I’ve written a builder to do this populating, but, because SCons controls the build order, there is no guarantee that the include directory will be populated when needed by the Object builder.
The Requires method seems just the ticket and appears to work, however I am a little worried. The Requires method does two things
1) Ensures that prerequisite target is built first
- Here, populating the include directory, just want I want
2) That targets of the prerequisites do not get built if only the prerequisites have changed
- Not what I want, if an include file needed by the C code changes, those targets do need to get rebuilt
(I note that even when using Requires method, the dependency tree is correct; given my understanding, I don’t know why.)
The Depends method is functionally what I want, but it is impractical, since it demands that all the include files for each C file be known and listed in the method. This list is what the Scanner normally automatically collects.
I’ve thought of other tactics to get this directory populated before the builders that need it access it, but they involve either
1) An awkward two pass build system (one pass to populate, one to build)
2) Making the populater just a Python function that runs before the build stage, rather than an SCons Builder
- This would work, but I lose the nice features that come with a builder, like the clean function.
If it makes a difference, the Builder to populate the include directory functions in two modes, either
1) Making symbolic links to the include files and the relevant sub-directories, or
2) By explicitly copying the include file directory tree (after doing some rearrangement).
I’ve only tested the former at this point.
What I am concerned about is in the case of the symbolic links, the prerequisite targets are the symbolic links, not the actual files, possibly explaining why the dependencies are correct. This will not be the case for explicit copies. I will certainly test this, but a clean explanation would help; nuances sometimes are not captured when just trying things by experiment or as I call it, the ‘poke with a stick’ method.
Jim Russell
More information about the Scons-users
mailing list