[Scons-users] Retrieving variables

Bill Deegan bill at baddogconsulting.com
Tue Jun 14 15:47:37 EDT 2016


On Tue, Jun 14, 2016 at 2:46 PM, Stefan Seefeld <stefan at seefeld.name> wrote:

> Hi Bill,
>
> thanks for the quick reply.
>
> On 14.06.2016 14:32, Bill Deegan wrote:
> > Stefan,
> >
> > For what you want to do, you're probably best initializing tools=[] in
> > your Environment.
> > Then setting TARGET_ARCH, then env.Tool(...) for each/all the tools
> > you want to use.
> > Or just have a Environment(tools=[],variables=vars) just for
> > retrieving the value.
>
> Can you elaborate a bit on what that would do ? Note that in my real
> code I already use a 'tools' argument. What do you mean by "Then setting
> TARGET_ARCH" specifically ? Setting this after the Environment is
> constructed is what I was trying to figure out.
>

As long as you don't add the MSVC/MSVS to your Environment() changing
TARGET_ARCH doesn't affect their initialization in the Environment() you
are using.

env=Environment(tools=[], variables=vars)

env['TARGET_ARCH'] = env['arch']
env.Tool('msvc')

Should more or less do what you want.
Likely you'll want to validate the value of arch=


>
> I find this recipe in the scons manual page:
>
> env = Environment(...)
> t = Tool('msvc')
> t(env)  # adds 'msvc' to the TOOLS variable
>

Hmm. I never call it that way.

I call:
env.Tool('msvc')
(not t=Tool...)



>
>
> which presumably would let me specify the TARGET_ARCH as a Tool()
> argument, yes ? (This is another point I'd like to make: I find it very
> hard to find a comprehensive documentation that lists all the available
> arguments for those functions / methods, such as Tool().)
>

So what you're missing is that any Environment() variable can be passed to
any Builder.
SCons will create an OverrideEnvironment() which is a shallow copy of the
Environment() being used, with whatever variables you set overridden for
the purpose of the target(s) of that builder. (and many of the non builder
methods hanging off Environment like Tool()).



>
> While this may work, it really looks like a kludge.
>

not sure what you are referring to here..


>
> >
> > Why not use --arch= instead of arch=?
> >
> > Also, why not use site_scons/ instead of bin.SCons ?
>
> bin.SCons is my build directory, where I want all generated files to be
> stored, including the scons caches.
>
> Thanks,
>         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/20160614/dcc0defe/attachment-0001.html>


More information about the Scons-users mailing list