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.
Differences between revisions 6 and 7
Revision 6 as of 2005-05-18 09:14:48
Size: 1521
Editor: 213
Comment:
Revision 7 as of 2008-03-12 02:46:57
Size: 1521
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

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
   2 
   3 Import('env', 'project', 'mymode', 'debugcflags', 'releasecflags')
   4 localenv = env.Copy()
   5 
   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
   9 
  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)
  16 
  17 #specify the build directory
  18 localenv.BuildDir(builddir, ".", duplicate=0)
  19 
  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:

  • the exact same alias name 'all' is used in all three sconscripts.
  • that 'env' is used for the Alias() not 'localenv'

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