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

William Deegan bill at baddogconsulting.com
Thu Aug 23 18:05:57 EDT 2012


Luc,

On Aug 23, 2012, at 2:42 PM, Luc Bourhis <luc_j_bourhis at mac.com> wrote:


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


Sounds like you could get into trouble if the programs link with any of those shared libraries..


>

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


I'm always wary of any "magic which happens behind the curtain" type solutions.
Eventually there'll be an issue and then debugging it is a much bigger cost than a clean solution up front. (IHMO)


>

>> 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!


If you create the shared and static libraries into different directories, then it should be fairly easy.

-Bill


More information about the Scons-users mailing list