[Scons-users] persistent but local tweaks to a node's environment

Mats Wichmann mats at wichmann.us
Sun Jul 25 09:52:37 EDT 2021


On 7/24/21 4:18 AM, Gabe Black wrote:
> Hi! The project I work on builds several different versions of its 
> outputs, like a debug version, an optimized version, etc. Also, some 
> files in the project, for instance automatically generated files, need 
> to have slightly customized build flags, like disabling certain warnings 
> that are false positives and/or are in source we can't change.
> 
> Right now we handle that by creating an environment for each build, 
> which I think is the standard approach. Unfortunately, we then have to 
> have a separate step which goes through and generates new environments 
> based on those for each file that needs its slightly customized build flags.
> 
> What I would *like* to do, is to be able to specify for any given node 
> that it should build using the flags that would be implied by the 
> environment that's pulling it in, except that they should be tweaked 
> just a little bit. Something like:
> 
> Object('foo.cc', '-Wno-deprecated-copy')
> 
> and then:
> 
> opt.Program('foo.opt', 'foo.cc', CCFLAGS='${CCFLAGS} -O3')
> debug.Program('foo.debug', 'foo.cc', CCFLAGS='${CCFLAGS} -g', 
> OBJSUFFIX='.do')
> etc
> 
> and then have foo.do build with "-Wno-deprecated-copy -g", and foo.o 
> build with "-Wno-deprecated-copy -O3"
> 
> The problem is, that as soon as I tell SCons to use custom variables, it 
> Clone-s the underlying environment and disassociates from the underlying 
> environment.

could you explain what you're seeing a little further?

In the case of construction variable overrides in a builder call, it 
doesn't Clone, as that's considered expensive, it just builds an 
override dictionary, and it doesn't disassociate - it retains the 
underlying construction environment and only applies the override dict 
if there were any overrides - so it's supposed to be a kind of 
copy-on-write setup.  Since this doesn't seem to match what you're 
seeing it would be good to figure out what's actually happening.






More information about the Scons-users mailing list