I want to be able to selectively build a hierarchical source tree based on common build patterns defined at the top-level. The source tree is comprised of a number of different modules, sometimes at different levels within the hierarchy, something like this:
- Large Module Package
- Submodule Package A
- Module A1
- Module A2
- Submodule Package B
- Module B1
- Submodule Package A
- Small Module Package
- Module C1
- Module C2
Each module may depend on any number of other modules (without cycles, of course).
Each module needs to be able to activate a selection of a set of template targets, defined at the top-level, that will look for certain source files and build certain outputs. For example, the Library template target will simply build the current module's shared library. The UnitTest target will make sure all upstream dependencies have their libraries built, look for the unit test source, build and then run a unit test executable.
The goal is to have each module to have its own encapsulated SConscript file that would list a) its dependencies and b) the names of the top-level targets that should be enabled for it.
Ideally, I'd like to ensure these targets can be built in a manner similar to this:
scons ModuleA1_UnitTest
How can I set up scons to do this for me, particularly in a way that is friendly to adding new modules?