The Link
method may be used in conjunction with multiple
construction environments to support variant builds. The following
SConstruct
and SConscript
files would build separate debug and
production versions of the same program side-by-side:
% cat SConstruct env = Environment() env.Link('build/debug', 'src') env.Link('build/production', 'src') flags = '-g' SConscript('build/debug/SConscript', Export(env)) flags = '-O' SConscript('build/production/SConscript', Export(env)) % cat src/SConscript env = Environment(CCFLAGS = flags) env.Program('hello', 'hello.c')
The following example would build the appropriate program for the current compilation platform, without having to clean any directories of object or executable files for other architectures:
% cat SConstruct build_platform = os.path.join('build', sys.platform) Link(build_platform, 'src') SConscript(os.path.join(build_platform, 'SConscript')) % cat src/SConscript env = Environment env.Program('hello', 'hello.c')