SCons: How to use the same builders for multiple variants (release/debug) of a program

Posted by OK on Stack Overflow See other posts from Stack Overflow or by OK
Published on 2010-03-17T16:15:47Z Indexed on 2010/03/30 17:13 UTC
Read the original article Hit count: 376

Filed under:
|
|
|

The SCons User Guide tells about the usage of Multiple Construction Environments to build build multiple versions of a single program and gives the following example:

opt = Environment(CCFLAGS = '-O2')
dbg = Environment(CCFLAGS = '-g')

o = opt.Object('foo-opt', 'foo.c')
opt.Program(o)

d = dbg.Object('foo-dbg', 'foo.c')
dbg.Program(d)

Instead of manually assigning different names to the objects compiled with different environments, VariantDir() / variant_dir sounds like a better solution...

But if I place the Program() builder inside the SConscript:

Import('env')
env.Program('foo.c')

How can I export different environments to the same SConscript file?

opt = Environment(CCFLAGS = '-O2')
dbg = Environment(CCFLAGS = '-g')

SConscript('SConscript', 'opt', variant_dir='release') #'opt' --> 'env'???
SConscript('SConscript', 'dbg', variant_dir='debug')   #'dbg' --> 'env'???

Unfortunately the discussion in the SCons Wiki does not bring more insight to this topic.

Thanks for your input!

© Stack Overflow or respective owner

Related posts about scons

Related posts about build