[Scons-users] Undocumented env override feature
Bill Deegan
bill at baddogconsulting.com
Thu Aug 31 16:49:19 EDT 2017
It's definitely in the manpage. Note that it doesn't clone the
environment, but creates an OverrideEnvironment() which is much lighter
weight than a whole Environment().
It is possible to override or add construction variables when calling a
builder method by passing additional keyword arguments. These overridden or
added variables will only be in effect when building the target, so they
will not affect other parts of the build. For example, if you want to add
additional libraries for just one program:
env.Program('hello', 'hello.c', LIBS=['gl', 'glut'])
or generate a shared library with a non-standard suffix:
env.SharedLibrary('word', 'word.cpp',
SHLIBSUFFIX='.ocx',
LIBSUFFIXES=['.ocx'])
(Note that both the $SHLIBSUFFIX and $LIBSUFFIXES variables must be set if
you want SCons to search automatically for dependencies on the non-standard
library names; see the descriptions of these variables, below, for more
information.)
It is also possible to use the *parse_flags* keyword argument in an
override:
env = Program('hello', 'hello.c', parse_flags = '-Iinclude -DEBUG -lm')
This example adds 'include' to *CPPPATH*, 'EBUG' to *CPPDEFINES*, and 'm' to
*LIBS*.
On Thu, Aug 31, 2017 at 1:41 PM, RW via Scons-users <scons-users at scons.org>
wrote:
> Hi,
> Just to ask, I've noticed that there might be a feature that's quite
> useful but not documented in the user manual (or at least non obvious). I
> just thought to check before adding in a change to the user docs.
>
> If you have a single Construction Environment but want to launch multiple
> builders with different parameters per call.
> I've noticed it's possible to override env variables by passing them into
> the builder call
>
> env = Environment(tools = ['Tool1'])
> env.Tool1('target1.txt', 'source1.txt', Tool1_Param="Example1")
> env.Tool1('target1.txt', 'source1.txt', Tool1_Param="Example2")
>
> From what I can gather in this scenario the env is cloned / modified per
> builder call, so that each builder instance gets a different env value when
> running.
>
> http://scons.1086193.n5.nabble.com/custom-builder-
> additional-arguments-td26701.html
>
> Many Thanks
> Richard
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170831/6baa65b6/attachment.html>
More information about the Scons-users
mailing list