Re: Attaching an emitter to an existing builder

Bill Deegan <[email protected]>
Newsgroups gmane.comp.programming.tools.scons.user
Message-ID <CAEyG4CFj-7vfY5A1btC48S4Xv8msQdyeBkaj=vsiAEHHmPUyFg@mail.gmail.com>
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

Hope that helps!
-Bill

On Wed, Jan 27, 2021 at 1:31 PM Jeremy Elson <[email protected]> wrote:

> Hi scons gurus,
>
> Is there a way to attach an emitter to a pre-existing builder? I know how
> to create my own custom Builders that have emitters, but I'm trying to add
> an emitter to one of the standard builders that comes with SCons. I see a
> function in Builder called add_emitter, so I tried this:
>
>         def map_emitter(target, source, env):
>             print("emitter is being called")
>
>         env["BUILDERS"]["Program"].add_emitter(
>             suffix = ".map",
>             emitter = map_emitter)
>
> But it throws an exception:
>
> TypeError: 'EmitterProxy' object does not support item assignment
>
> I'm using the standard SCons Program() Builder to build my program. But I
> am also passing a linker option in LINKFLAGS so that when gcc is called at
> the link stage, it generates both the program binary as its main output and
> also an extra file (a .map file) that contains linker symbol metadata. I
> want SCons to understand this side-effect so that if the map file gets
> deleted, scons will run gcc again to regenerate it.
>
> Thanks!
>
> -Jeremy
>
> _______________________________________________
> Scons-users mailing list
> [email protected]
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>

_______________________________________________
Scons-users mailing list
[email protected]
https://pairlist4.pair.net/mailman/listinfo/scons-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.