[Scons-users] Overriding Object to force global dependency

Greg Ward greg at gerg.ca
Thu Jul 5 17:33:33 EDT 2012


On 05 July 2012, Gary Oberbrunner said:

> The standard SharedObjectEmitter does this (see Defaults.py):

>

> def SharedObjectEmitter(target, source, env):

> for tgt in target:

> tgt.attributes.shared = 1

> return (target, source)

>

> and unfortunately I believe add_emitter is replacing the standard

> emitter with yours. (See Builder.py). Maybe for now just set

> tgt.attributes.shared=1 in your shared emitter.


Ahhhh. Emitters don't stack. Got it. If my time machine were working,
I'd hop back and ask someone to change add_emitter() to set_emitter().

Luckily, I can stack emitters myself manually. Here's how I did it:

def lbe_emitter(target, source, env):
env.Depends(target, '#dummy-lbe')
return (target, source)

def stack_lbe_emitter(builder, suffix):
orig_emitter = builder.emitter.get(suffix)
if orig_emitter:
def emitter(target, source, env):
(target, source) = orig_emitter(target, source, env)
(target, source) = lbe_emitter(target, source, env)
return (target, source)
else:
emitter = lbe_emitter
builder.add_emitter(suffix, emitter)

stack_lbe_emitter(env['BUILDERS']['StaticObject'], '.cpp')
stack_lbe_emitter(env['BUILDERS']['SharedObject'], '.cpp')

Seems to work. Should not be too hard to generalize if someone needs to.

Thanks!

Greg


More information about the Scons-users mailing list