Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-06 Thread Gary Oberbrunner
On Sat, Oct 6, 2012 at 2:53 PM, Left Right  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
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-06 Thread Left Right
> 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)

> If all you're looking to do is have foo in the shell environment of the 
> commands you run
> -Bill

No. This variable is most likely not set in the shell environment,
when the build script is called. It is very likely that users will
have to set it.

> then you don't need to use Variables at all

Fair enough... but I thought it's a suggested way of doing it.

> If you want to pass foo on the scons command line and have

Not sure. I want to pass it to my function, that will do something
based on that variable (in this particular case, it will try to find a
bunch of programs, configuration files etc.)

Best.

Oleg
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread William Deegan
Oleg,

If all you're looking to do is have foo in the shell environment of the 
commands you run, then you don't need to use Variables at all.
If you want to pass foo on the scons command line and have that affect the 
Environment(), though not the shell environment unless you explicitly copy the 
value:
env=Environment()
env['ENV']['foo']=env['foo']
Then Variables is useful.

Sounds like you really need to do a thorough read of the users guide and the 
man page.

-Bill

On Oct 5, 2012, at 9:42 AM, "Kenny, Jason L"  wrote:

> Variable objects are a defined type that allow for some basic validation, and 
> conversion. With Variables you can control logic for example on how to deal 
> with unknown values. This was meant to be an improvement over just taking the 
> arguments and passing them in to the Environment.  
> 
> Jason
> 
> -Original Message-
> From: scons-dev-boun...@scons.org [mailto:scons-dev-boun...@scons.org] On 
> Behalf Of Left Right
> Sent: Friday, October 05, 2012 11:14 AM
> To: scons-dev@scons.org
> Subject: Re: [Scons-dev] How to get variables passed to Env(variables = 
> whatever)?
> 
> Nope, it doesn't. It was a typo, in the original code it was Environment, not 
> Env.
> I can, however, do it like so:
> 
> env = Environment(ENV = { 'foo' : 42 })
> env['ENV']['foo'] <--- this works then
> 
> But was curious of the reason why not allow to do it via Variables?
> 
> Thanks.
> 
> Oleg
> ___
> Scons-dev mailing list
> Scons-dev@scons.org
> http://two.pairlist.net/mailman/listinfo/scons-dev
> ___
> Scons-dev mailing list
> Scons-dev@scons.org
> http://two.pairlist.net/mailman/listinfo/scons-dev

___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread Kenny, Jason L
Variable objects are a defined type that allow for some basic validation, and 
conversion. With Variables you can control logic for example on how to deal 
with unknown values. This was meant to be an improvement over just taking the 
arguments and passing them in to the Environment.  

Jason

-Original Message-
From: scons-dev-boun...@scons.org [mailto:scons-dev-boun...@scons.org] On 
Behalf Of Left Right
Sent: Friday, October 05, 2012 11:14 AM
To: scons-dev@scons.org
Subject: Re: [Scons-dev] How to get variables passed to Env(variables = 
whatever)?

Nope, it doesn't. It was a typo, in the original code it was Environment, not 
Env.
I can, however, do it like so:

env = Environment(ENV = { 'foo' : 42 })
env['ENV']['foo'] <--- this works then

But was curious of the reason why not allow to do it via Variables?

Thanks.

Oleg
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread Left Right
Nope, it doesn't. It was a typo, in the original code it was
Environment, not Env.
I can, however, do it like so:

env = Environment(ENV = { 'foo' : 42 })
env['ENV']['foo'] <--- this works then

But was curious of the reason why not allow to do it via Variables?

Thanks.

Oleg
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread Left Right
Some more info:

for k in keys:
print 'will try to set: %s' % k
try:
save[k] = self._dict[k]
except KeyError:
print 'and fail...: %s' % k
# No value may have been set if they tried to pass in a
# reserved variable name like TARGETS.
pass

This is where it fails... why?.. I'm giving it a totally rouge name,
it can't be a reserved name or anything. In particular, I need to
allow specify $FLEX_HOME, if it's not set in current shell, or to
override it.
Unfortunately, none of *my* code runs before this point, so I cannot
affect this *decision*.

Thanks.
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


Re: [Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread Gary Oberbrunner
On Oct 5, 2012 9:36 AM, "Left Right"  wrote:
>
> Hi,
> I've found this page:
http://www.scons.org/doc/1.1.0/HTML/scons-user/x2361.html
> And it shows that the user could, in theory do something like:
>
> v = Variables()
> v.Add('foo', 42)
> env = Env(variables = v)

This should work, except the name of the environment constructor is
Environment(), not Env().

Then env['foo'] should be 42.

> I was struggling to find where did this variable go, but no traces...
> I would expect them to appear in
>
> def generate(env):
> env.get('foo') <--- but it doesn't exist here
> env._dict.keys() <--- foo doesn't exist here either...
>
> Why? How else should I look for it?
>
> Thanks.
>
> Oleg
> ___
> Scons-dev mailing list
> Scons-dev@scons.org
> http://two.pairlist.net/mailman/listinfo/scons-dev
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev


[Scons-dev] How to get variables passed to Env(variables = whatever)?

2012-10-05 Thread Left Right
Hi,
I've found this page: http://www.scons.org/doc/1.1.0/HTML/scons-user/x2361.html
And it shows that the user could, in theory do something like:

v = Variables()
v.Add('foo', 42)
env = Env(variables = v)

I was struggling to find where did this variable go, but no traces...
I would expect them to appear in

def generate(env):
env.get('foo') <--- but it doesn't exist here
env._dict.keys() <--- foo doesn't exist here either...

Why? How else should I look for it?

Thanks.

Oleg
___
Scons-dev mailing list
Scons-dev@scons.org
http://two.pairlist.net/mailman/listinfo/scons-dev