[Scons-users] Retrieving variables

Bill Deegan bill at baddogconsulting.com
Fri Jun 17 14:35:47 EDT 2016


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()


Do something similar to this, and set TARGET_ARCH accordingly, then you can
let SCons take care of the tool initialization.
And/or specify a reasonable list of tools to Environment() for what the
user specifies.

I'm guessing you've not really absorbed all the info in the manpage.
I heartily encourage you to sit down and read the whole thing front to back.

-Bill


On Fri, Jun 17, 2016 at 11:27 AM, Stefan Seefeld <stefan at seefeld.name>
wrote:

> On 17.06.2016 14:14, Bill Deegan wrote:
> > Is there a msvc.pyc or .pyo still in your config dir?
>
> I'm not quite sure what the problem was, but after some further
> refactoring the symptom has disappeared. SCons is now correctly looking
> for tools both in my custom path as well as the builtin path(s).
>
> I'm still trying to figure out how to conditionalize the call to
>
>   env.Tool('msvc')
>
> The obvious check is for the platform ('win32'). But even there, not all
> Windows users have MSVC installed, so how can I reproduce the SCons
> logic of iterating over a list of tools until one is found ?
>
> In fact, what I really want is this:
>
> For each platform, find all available tools, then let the user pick. For
> example, on Linux:
>
> *  `scons` should pick gcc
> *  `scons toolchain=clang` should pick clang
> *  `scons toolchain=msvc` should fail ("no such toolchain")
>
> On Windows:
>
> * `scons` should pick msvc if available, or any other of the default
> tools being searched for
> * `scons toolchain=cygwin` should pick the cygwin compiler (if available)
> * etc.
>
> Any suggestion on how to implement that logic ?
>
> Many thanks for all your help !
>
>         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/416a092b/attachment-0001.html>


More information about the Scons-users mailing list