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

Dirk Bächle tshortik at gmx.de
Wed Jul 9 13:29:42 EDT 2014


Hi Andrew,

On 09.07.2014 18:43, Andrew C. Morrow wrote:
> [...]
> 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:

if you need to provide a default value for your option, you can do this 
with the "default=" keyword. AddOption() uses the same syntax as 
optparse.add_option, as mentioned in the UserGuide, sect. "10.1.5: the 
AddOption function".

>
> The documentation states that HOST_ARCH must be set at construction
> time, so I can't optionally do it later.

Note, that you can always start with an empty environment:

   env = Environment(tools=[])

and then add Tools later with:

   env.Tool('qt4')

, once its required environment variables are setup properly.

Best regards,

Dirk



More information about the Scons-users mailing list