Add extra targets to buildin builders

256 views Asked by At

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?

2

There are 2 answers

0
Knut On BEST ANSWER

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'].

9
Kenneth E. Bellock On

If you know what the name of the file is going to be, then you list it as a side effect and set it to be cleaned.

myenv.Append(LINKFLAGS=...)
lib = myenv.SharedLibrary(source)
map = SideEffect('file.map', lib)
Clean(lib, map)