[Scons-users] environment variables

Keith Brown keith6014 at gmail.com
Fri Jul 11 06:53:25 EDT 2014


On Thu, Jul 10, 2014 at 11:17 AM, Gary Oberbrunner <garyo at oberbrunner.com>
wrote:

>
>
>
> On Thu, Jul 10, 2014 at 10:57 AM, Keith Brown <keith6014 at gmail.com> wrote:
>
>> To further clarify, I would like to run a script called boilerplate.sh
>> which will set the appropriate bash environment and then run all my
>> subtasks.
>>
>> The subtasks should inherit the shell environment from boilerplate.sh
>>
>> That's nontrivial.  Shell scripts can't modify environment vars in their
> parent.  Consider how you'd do this without SCons, e.g. if you're just
> making a shell script to do your build.  You can't just say
>   ./boilerplate.sh # set vars
>   subtask_1 ...
>   subtask_2 ...
> because any changes to the shell env done by boilerplate.sh disappear when
> that subshell exits.
>
> You can source it:
>   source ./boilerplate.sh
>   subtask_1
>   subtask_2
> To do that in SCons, you'd just prepend that source to your Commands:
>   env.Command(..., 'source boilerplate.sh && subtask1')
> but it might be better (cleaner) to modify your boilerplate.sh to spit out
> the env var settings it's making on stdout, and read those into your
> SConscript (it's just a python script, after all) and use those vars to
> update your env['ENV'].
>
> --
> Gary
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
>
>
thanks for the response gary.

I am not trying to modify the parent's environment. that would be
non-sensical.

here is the way I am trying to do it now.

dataflow.sh
#!/usr/bin/env bash
source boilerplate.sh
scons


In my SConstruct,

env=Environment()
env.Command(..., 'subtask1')

so, if I loop thru the os.environ() and populate env['ENV'][env keys] work?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20140711/9a2753da/attachment.html>


More information about the Scons-users mailing list