Re: Wacky crash in Clone()

Marc Branchaud via Scons-users <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Organization XipLink
Message-ID <[email protected]>
On 2022-01-24 17:06, Bill Deegan wrote:
> So you just want CCFLAGS to be overwritten in the action? (or is this
> just an example?)

Not CCFLAGS, but variables that affect the behaviour of the BaseBuilder. 
  These should not retain their values after the invocation of the 
Builder, so stuffing them into a cloned Environment was convenient.  (My 
example showed the Clone() call in message(), but it was also happening 
in the builder() function.)

This code is over 10 years old, and I think it would be implemented very 
differently today -- not just to avoid Cloning inside an Action.  But a 
major refactoring is beyond the scope at this time.

> If you can be specific about what you want to override with your
> Clone(), I'd be there's another way to accomplish that than the Clone()..
>
> It may just be more advanced SCons-Fu.. :)
I rewrote things to avoid cloning Environments, and now all is joy -- 
thanks for the pointer!

For future spelunkers, my solution is a bit hacky:  I taught the 
BaseBuilder to drive its behaviour from a combination of the Environment 
and a module-level "overrides" dict.  The MyBuilder sets what it needs 
in BaseBuilder.overrides, and BaseBuilder.builder() clears the overrides 
when it's done.

Thanks again!

		M.
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.