[Scons-users] Modifying the provided environment in an emitter?

Bill Deegan bill at baddogconsulting.com
Fri Apr 21 19:00:52 EDT 2017


Andrew,

I'm not sure why you wouldn't just do:
env['LIBS'] = env.get('LIBS',[])
env.AppendUnique('LIBS','foo')

Why do this in the emitter, instead of in the environment?

-Bill


On Fri, Apr 21, 2017 at 2:29 PM, Andrew C. Morrow <andrew.c.morrow at gmail.com
> wrote:

>
> Hi all -
>
> Is it legit to modify the passed in env in an emitter?
>
>     def add_lib_foo_emitter(target, source, env):
>         libs = env.get('LIBS', [])
>         libs.append('foo')
>         env['LIBS'] = libs
>         return (target, source)
>
>     def add_emitter(builder):
>         base_emitter = builder.emitter
>         new_emitter = SCons.Builder.ListEmitter([add_lib_foo_emitter,
> base_emitter])
>         builder.emitter = new_emitter
>
>     target_builders = ['Program', 'SharedLibrary', 'LoadableModule',
> 'StaticLibrary']
>     for builder in target_builders:
>         add_emitter(env['BUILDERS'][builder])
>
> I've found myself wanting to do this with increasing frequency, but am
> unclear on whether this is acceptable. It appears to work, but the
> documentation doesn't seem to offer any clear guidance that I've found on
> whether it is guaranteed to work. If so (which would be great!), am I
> guaranteed that the modification of env is scoped only to the passed in
> targets?
>
> Thanks,
> Andrew
>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170421/1a6724b7/attachment.html>


More information about the Scons-users mailing list