[Scons-users] Not clobbering autodetected HOST_ARCH when configured via Options

Andrew C. Morrow andrew.c.morrow at gmail.com
Wed Jul 9 13:04:27 EDT 2014


On Wed, Jul 9, 2014 at 12:46 PM, Kenny, Jason L <jason.l.kenny at intel.com> wrote:
> HOST_ARCH should not be set by the user. HOST here is the system you are building on. TARGET is what you are building for.

At least some Express versions of VS don't ship the 64-bit compiler.
They only ship the 32 bit compiler, and the 32-to-64 cross compiler.
If you are building on a 64 bit machine where HOST_ARCH autodetects to
x86_64 and try to do a TARGET_ARCH=x86_64 build, it fails because it
can't invoke the 64-bit compiler, since it isn't present.

You can cheat by setting PROCESSOR_ARCHITECTURE=x86 in the cmd.exe
environment before invoking SCons, which fakes out the HOST_ARCH
autodetection, but I'd prefer to allow users who are facing this
difficulty the option of explicitly setting HOST_ARCH=x86 to select
the cross compiler.

But HOST_ARCH is just an example here. The question is really about
how to deal with passing possibly empty option values to the
Environment constructor without disturbing defaults.


>
> Jason
>
> -----Original Message-----
> From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Andrew C. Morrow
> Sent: Wednesday, July 9, 2014 11:44 AM
> To: SCons users mailing list
> Subject: [Scons-users] Not clobbering autodetected HOST_ARCH when configured via Options
>
> The following question uses HOST_ARCH because it is the construction variable that was giving me trouble, but I think the question applies to any construction variable that, if it is to be customized, must be set at Environment construction time.
>
> I can set up HOST_ARCH reasonably using Variables:
>
> variables = AddVariables(
>     (HOST_ARCH, "The host architecture for Windows builds"),
> )
>
> env = Environment(variables=variables).
>
> The above does the right thing whether or not HOST_ARCH is passed to scons:
>
> # OK, HOST_ARCH will be autoselected by SCons internals
>> scons
>
> # OK, HOST_ARCH will be set to x86
>> scons HOST_ARCH=x86
>
>
> If, instead, I want to manage HOST_ARCH via Options for consistency with a project that currently uses Options for everything:
>
> AddOption('--host-arch', ...)
>
> env = Environment(
>     HOST_ARCH=GetOption('host-arch'))
> )
>
> Then all is well if I pass --host-arch:
>
> # OK, HOST_ARCH gets the value of --host-arch
>> scons --host-arch=x86
>
> But if I don't set the option, things are not OK:
>
> # NOT OK, HOST_ARCH becomes 'None' in Environment, instead of taking autoselected value:
>> scons
>
> The documentation states that HOST_ARCH must be set at construction time, so I can't optionally do it later. One thought was to build the argument dictionary to the Environment constructor incrementally, and then pass it as the kwargs:
>
> envdict = dict()
>
> if GetOption('host-arch'):
>     envdict['HOST_ARCH'] = GetOption('host-arch')
>
> env = Environment(**envdict);
>
> What is the preferred mechanism for optionally setting Environment variables without disturbing defaults?
>
> Thanks,
> Andrew
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> http://four.pairlist.net/mailman/listinfo/scons-users


More information about the Scons-users mailing list