Re: persistent but local tweaks to a node's environment

Mats Wichmann <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <[email protected]>
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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.