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

Kenny, Jason L jason.l.kenny at intel.com
Wed Jul 9 12:46:55 EDT 2014


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.

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


More information about the Scons-users mailing list