Search code examples
scons

Add extra targets to buildin builders


I need some extra files (p.ex. memory mapping) from the linker thus I've modified the flags accordingly: myenv.Append(LINKFLAGS=...)

How could I get these additional .map files cleaned up with scons -c?

I know there are Emitters to add targets. Is it possible to extend a buildin builder of myenv?

What is an appropriate way?


Solution

  • Ok, I found a way to do it. Scons provides a variable PROGEMITTER which is documented as 'TODO'.

    def prog_emitter(target, source, env):
        # assume target is a list!
        # exchange extension of target file with .map
        target.append(os.path.splitext(target[0].get_path())[0] + '.map')
        return target, source
    
    myenv.Append(PROGEMITTER=prog_emitter)
    

    For other builders you could use add_emitter. You'll find all loaded builders in myenv['BUILDERS'].