[Scons-users] Replace env['BUILDERS']['Program'] and env.Configure

Francis Bolduc fbolduc at gmail.com
Thu Aug 23 08:43:10 EDT 2012


I had the same problem as you. I ended up using a functor instead of a
function. Now I can chain builders, which is extremely useful.

def ChainMyBuilder(original_builder):
class MyChainedBuilder:
def __init__(self, builder):
self.builder = builder
self.emitter = builder.emitter
def __call__(self, env, program, sources, **args):
outputs = self.builder(env, program, sources, **args)
...
do your magick here
...
return outputs
return MyChainedBuilder(original_builder)
env['BUILDERS']['Program'] = ChainMyBuilder(envGlobal['BUILDERS']['Program'])

I suspect you could forward the prefix attribute to the chained
builder using this technique.

--
Francis Bolduc, B.Sc.


On Wed, Aug 22, 2012 at 6:06 PM, Luc Bourhis <luc_j_bourhis at mac.com> wrote:

> Hi,

>

> I am using what seemed a classic trick:

>

> def _(env, target, source, **args):

> env = env.Clone()

> # do something to env

> return env.OriginalProgram(target, source, **args)

> env['BUILDERS']['OriginalProgram'] = env['BUILDERS']['Program']

> env['BUILDERS']['Program'] = _

>

> However, this crashes env.TryBuild:

>

> File "/Users/luc/Developer/cctbx/scons/src/engine/SCons/SConf.py", line 546, in TryBuild

> pref = self.env.subst( builder.builder.prefix )

>

> Here builder.builder is that function "_" of mine, which does not have an attribute "prefix" of course.

>

> That's with SCons 2.2.0.

>

> How would I go to work that problem around?

>

> Best wishes,

>

> Luc J. Bourhis

>

>

> _______________________________________________

> Scons-users mailing list

> Scons-users at scons.org

> http://four.pairlist.net/mailman/listinfo/scons-users



More information about the Scons-users mailing list