[Scons-dev] How to get variables passed to Env(variables = whatever)?
Gary Oberbrunner
garyo at oberbrunner.com
Sat Oct 6 16:33:04 EDT 2012
On Sat, Oct 6, 2012 at 2:53 PM, Left Right <olegsivokon at gmail.com> wrote:
> > With Variables you can control logic for example on how to deal with
> unknown values
> > Jason
>
> OK... well, my question was how to control it? Right now it does the
> opposite of what I need. How to make it do what I need?
> I.e. I want to allow FLEX_HOME to be set in this way (this is a
> directory name, so the way variables have special function for
> directories looks appealing)
>
I think you have a basic (and common) confusion between the construction
environment (what Environment() makes) and the shell environment which is
passed to commands that are executed by SCons. That environment is stored
in one sub-key of the construction environment. So:
env = Environment()
env['FOO'] = 'Foo in construction environment'
env['ENV']['FOO'] = 'Foo passed to subshells'
env.Command('tgt', 'src', 'make-target $TARGET $SOURCE FOO=$FOO')
In a SConstruct like the above, the actual command executed will be:
make-target tgt src "Foo in construction environment"
However if make-target itself is a shell script, and that shell script
contains a $FOO, that one will expand to "Foo passed to subshells".
Basically, SCons is not like Make; construction variables are distinct from
the shell environment and each can be manipulated completely independently.
I think what you care about is setting FLEX_HOME in the shell environment
passed to commands executed by SCons, right? In that case you want to set
(in any way you like) env['ENV']['FLEX_HOME']. Note that simply applying a
Variables object to an Environment sets construction variables, not shell
environment variables. That's probably what was tripping you up.
--
Gary
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/scons-dev/attachments/20121006/e525b4e5/attachment.html>
More information about the Scons-dev
mailing list