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

Mats Wichmann mats at wichmann.us
Sun Jul 25 13:51:44 EDT 2021


On 7/25/21 9:05 AM, Gabe Black wrote:
> Sure. Here is an example SConstruct I was playing with:
> 
> '''
> env = Environment()
> 
> foo_o = env.Object('foo.c', CCFLAGS='${CCFLAGS} -DFOO=foo')
> 
> env.Append(CCFLAGS=['-DBAR=bar'])
> foo = env.Program('foo', foo_o)
> 
> Default(foo)
> '''
> 
> When that builds foo.o, it always uses -DFOO=foo, and never -DFOO=bar, 
> so the env.Append line seems to be clobbered by the override in 
> env.Object().

I think that's just an ordering thing, as the substitution is done when 
this line runs, not when SCons actually performs the build... if you 
move the Append above the Object call does it change?

By the way, normally it's suggested to use CPPDEFINES for preprocessor 
macros (where you don't include the -D, SCons will fill that in for the 
target compiler) instead of CCFLAGS.


More information about the Scons-users mailing list