[Scons-users] Retrieving variables

Bill Deegan bill at baddogconsulting.com
Fri Jun 17 18:03:59 EDT 2016


Stefan,



On Fri, Jun 17, 2016 at 12:30 PM, Stefan Seefeld <stefan at seefeld.name>
wrote:

> On 17.06.2016 14:35, Bill Deegan wrote:
> > Stefan,
> >
> > Really you're going about this the hard way I think.
> > Why reinvent the wheel.
> >
> > Try using this: (From manpage)
> >
> > Values of variables to be passed to the SConscript file(s) may be
> > specified on the command line:
> >
> > scons debug=1 .
> >
> > These variables are available in SConscript files through the
> > ARGUMENTS dictionary, and can be used in the SConscript file(s) to
> > modify the build in any way:
> >
> > if ARGUMENTS.get('debug', 0):
> >     env = Environment(CCFLAGS = '-g')
> > else:
> >     env = Environment()
>
> Yes, I could do
>
>   `if ARGUMENTS.get('arch', 'some default')`
>
> but I would have to duplicate the logic to set the default value (which
> I already had to add to
>
>   `vars.Add('arch', 'some default')`
>
> which is one of the reasons why I used the term "kludge"...
>
> I admit this is only a minor issue, but still I think SCons should
> provide a more elegant way to solve this.
>


So using Vars implies you want to set values in your Environment().
But in your case you want to use the value of a command line argument to
change how you initialize your Environment, thus the use of  ARGUMENTS.
It's a bit of chicken and egg type issue with a way out.

Can you provide a more elegant way of handling this?
I've provided several ways to do this:
1 -  a environment just for getting the values which you use to configure
the Environment() you actually use
2 - look for your values in ARGUMENTS.

-Bill



>
>         Stefan
>
>
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> 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/20160617/aa0ef521/attachment.html>


More information about the Scons-users mailing list