[Scons-users] Replace env['BUILDERS']['Program'] and env.Configure

Luc Bourhis luc_j_bourhis at mac.com
Thu Aug 23 17:42:03 EDT 2012



>> I am using what seemed a classic trick:

>>

>> def _(env, target, source, **args):

>> env = env.Clone()

>> # do something to env

>> return env.OriginalProgram(target, source, **args)

>> env['BUILDERS']['OriginalProgram'] = env['BUILDERS']['Program']

>> env['BUILDERS']['Program'] = _

>>

>> However, this crashes env.TryBuild:

>>

> Why would you want to do something like this?


I am dealing with an existing build system creating many an executable with env.Program(...) and many a shared library with env.SharedLibrary(...). As part of a recent changeset, I have a piece of code that I have built into a static library libofmine.a and a shared library libofmine.so. Then I wish that every executable is linked with libofmine.a whereas every shared library is linked with libofmine.so.


> You could use a pseudo-builder


Indeed but that would require changing all the env.Program(...) to env.MyProgram(...) and forcing all my collaborators to switch to that. I preferred to try a more transparent approach.


> or pass ENV vars to the Program() would seem to be much more straightforward.


It seemed impossible to modify the environment by Append'ing a library in such a manner that env.Program would pick the static version whereas env.SharedLibrary would pick the shared version. If there is a way to do that, then I would adopt it immediately!

Best wishes,

Luc



More information about the Scons-users mailing list