[Scons-users] Modifying the provided environment in an emitter?
Bill Deegan
bill at baddogconsulting.com
Mon Apr 24 13:07:51 EDT 2017
Seems like given all that, perhaps a pseudoBuilder would be the simplest
solution?
MongoProgram()..
-Bill
On Sat, Apr 22, 2017 at 7:49 AM, Andrew C. Morrow <andrew.c.morrow at gmail.com
> wrote:
>
> Hi Bill -
>
> That was a minimal example, to demonstrate my intent, but what I want to
> do is a little more complex.
>
> In one case, I want to run a transform over any arguments passed in to a
> Program, SharedLibrary, etc. call:
>
> If the user writes:
>
> prog = env.Program(
> target="foo",
> source=[...],
> LIBS=[
> "thing/foo",
> "place/bar",
> )
>
> I want a chance to re-write the LIBS for these targets based on project
> specific rules, so that this is as if the user wrote:
>
> prog = env.Program(
> target="foo",
> source=[...],
> LIBS=[
> "thing/foo_actual_uglified_name",
> "place/bar_actual_uglified_name",
> )
>
>
> Another example would be something like this:
>
> def compiling_target_emitter(target, source, env):
> targetbase = str(target[0].get_subst_proxy().filebase)
> targetbase = targetbase.upper() # possibly more complex
> transformations in practice
> env.AppendUnique(CPPDEFINES=['COMPILING_' + targetbase])
> return target, source
>
> Here, I want every SharedLibrary or LoadableModule to automatically have
> COMPILING_$TARGET.filebase set in CPPDEFINES when it is built, as part of
> managing symbol visibility, and I don't want every user who writes a
> declaration for a library to know how to get it right, I want it to happen
> automatically. Also, there doesn't seem to be a SHCPPDEFINES...
>
> However, since it appears that all targets don't get a private env unless
> there is an override in the declaration, that this approach may not be
> viable.
>
> Thanks,
> Andrew
>
> On Fri, Apr 21, 2017 at 7:00 PM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> 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
>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
> _______________________________________________
> 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/20170424/26ad6f3f/attachment-0001.html>
More information about the Scons-users
mailing list