[Scons-users] Changing VariantDir in an SConscript file

Luke Tunmer luke.tunmer at gmail.com
Mon Nov 15 09:54:42 EST 2021


Hi all,

I'm trying to understand why calling VariantDir on my environment within an
SConstript file doesn't do what I thought it would. I suspect it's my
understanding that is broken, and if so, I'm looking for advice for how to
do this properly.

My top level SConstruct file started the ball rolling with a variant_dir
that encapsulates all the different configurations that this system can be
built to ensure each configuration is built into a unique build folder
location (I turn duplicate off).

Deep down in the tree in a particular SConscript file I need to compile
some C files two different ways which target the C compiler optimizer for
the particular CPU on which it will run (the embedded system is a multicore
one with at least 5 different CPU types). Some of these C files will be
running on different cores.

I thought I could clone the environment two ways and modify the VariantDir
of each:

Import('env')

env_A = env.Clone()
env_A.VariantDir('build/A', '.', duplicate=0)
# add various CC flags to env_A

env_B = env.Clone()
env_B.VariantDir('build/B', '.', duplicate=0)
# add different CC flags to env_B

And then I would like to be able to specify the two different libraries
that need to be built at this level in the tree:

lib_A = env_A.Library('lib_A', ['src/common.c', 'src/impl_A.c'])
lib_B = env_B.Library('lib_B', ['src/common.c', 'src/impl_B.c'])

and then common.c will be compiled two ways into different build folders,
and the appropriate one included in each library. However, the change to
the VariantDir of each environment seems to make no difference at all: it
uses the build folder specified right at the top of the tree for both the
.o files and for the .lib files that it makes.

Any help in my understanding of how VariantDir is supposed to work, and
what it is actually doing is appreciated. Or, of course, any information on
the proper way to achieve this result would be great.

Regards,
Luke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20211115/8b0533a9/attachment.htm>


More information about the Scons-users mailing list