[Scons-users] Attaching an emitter to an existing builder

Mats Wichmann mats at wichmann.us
Thu Jan 28 10:11:46 EST 2021


On 1/27/21 3:11 PM, Bill Deegan wrote:
> Jeremy,
> 
> Greetings!
> You're not the first to mention adding the map file as a side effect. 
> (or target)
> Please go ahead and file and Issue on github for this.
> Ideally with a simple example, what the gcc flag is, and what the file 
> naming/location would be?
> 
> So likely the easiest way to add an emitter to Program() would be the 
> following (not tested)
> 
> env.Append(PROGEMITTER = [my_map_emitter])
> 
> Give that a try and let us know if it works for you?
> 
> Also there's a discord server for scons help if you'd like to ask 
> questions/get help there.
> https://discord.gg/bXVpWAy <https://discord.gg/bXVpWAy>
> 
> Hope that helps!
> -Bill

For inspiration, the mslink tool does this (as does the qt tool) - see 
the somewhat messy SCons/Tool/mslink.py.

Meanwhile, while many tools use add_emitter, the code for add_emitter 
itself includes this comment:

         This assumes that emitter has been initialized with an
         appropriate dictionary type, and will throw a TypeError if
         not, so the caller is responsible for knowing that this is an
         appropriate method to call for the Builder in question.

>              env["BUILDERS"]["Program"].add_emitter(
>                  suffix = ".map",
>                  emitter = map_emitter)
> 
>     But it throws an exception:
> 
>     TypeError: 'EmitterProxy' object does not support item assignment

So I guess "expected"? although pretty awkward....



More information about the Scons-users mailing list