Search code examples
scons

Scons: combining multiple targets into one


I have several environments in my project. When I use target target1 to build some binaries and shared libraries.

I want to use target target2 to build a binary and do everything that gets done for target1

I would like to achieve following,

  1. Build and install program1 and library1 for command scons target1
  2. Build and install program1, program2 and library1 for command scons target2

What is the right way achieve this?


Solution

  • The correct way to combine multiple targets under a symbolic name is the Alias() command. Check out the UserGuide at http://scons.org/doc/production/HTML/scons-user.html , especially Chapter 25. "Alias Targets". Note that an Alias is a target node itself, so you can combine multiple defined Aliases #1-#3 into a global Alias like:

    alias1 = Alias("alias1", "target1")
    alias2 = Alias("alias2", "target2")
    alias3 = Alias("alias3", "target3")
    Alias("all", [alias1, alias2, alias3])
    

    , where you can also replace each "target" string with a reference to an actual file/dir node as it gets returned by a Builder...