Please note:The SCons wiki is in read-only mode due to ongoing spam/DoS issues. Also, new account creation is currently disabled. We are looking into alternative wiki hosts.

Same as SconstructMultiple with an 'all' Alias used.

Now the command line also allows:

scons mode=release all  ; build all subprojects
scons mode=debug all

The Sconstruct does not change from SconstructMultiple. The Sconscript changes slightly (the last 2 lines):

   1 import glob
   3 Import('env', 'project', 'mymode', 'debugcflags', 'releasecflags')
   4 localenv = env.Copy()
   6 buildroot = '../' + mymode  #holds the root of the build directory tree
   7 builddir = buildroot + '/' + project   #holds the build directory for this project
   8 targetpath = builddir + '/' + project  #holds the path to the executable in the build directory
  10 #append the user's additional compile flags
  11 #assume debugcflags and releasecflags are defined
  12 if mymode == 'debug':
  13    localenv.Append(CCFLAGS=debugcflags)
  14 else:
  15    localenv.Append(CCFLAGS=releasecflags)
  17 #specify the build directory
  18 localenv.BuildDir(builddir, ".", duplicate=0)
  20 srclst = map(lambda x: builddir + '/' + x, glob.glob('*.cpp'))
  21 pgm = localenv.Program(targetpath, source=srclst)
  22 env.Alias('all', pgm)

The difference is that the Node from Program() is saved in variable 'pgm' and is used in an Alias(). The Alias() in the three sconscripts name the same alias name (i.e. 'all'). When the alias name is used on the command line, scons builds everything associated with it.

Note a couple of things:

SconstructMultipleAll (last edited 2008-03-12 02:46:57 by localhost)