[Scons-users] Why is resetting user-defined options with SetOption forbidden?
bill at baddogconsulting.com
Sun Mar 12 16:11:22 EDT 2017
Coincidentally I'm working on that code as part of the py2/3 port.
If I remember correctly, allowing users to specify options wasn't there
from the beginning of SCons and was added after many user requests.
Currently the code whitelists some options which are allowed to be set via
I can't think of any good reason to dis-allow sconscripts to set the
locally added options.
On Fri, Mar 10, 2017 at 2:26 AM, Dirk Baechle <tshortik at gmx.de> wrote:
> Hi Andrew,
> depending on how your additional conditions look like, couldn't this also
> be handled in a validator for the option in question?
> Best regards,
> Am 9. März 2017 20:06:45 MEZ schrieb "Andrew C. Morrow" <
> andrew.c.morrow at gmail.com>:
>> Hi -
>> I'd like to be able to rewrite the value of an option I've defined with
>> AddOption, but SetOption appears to forbid this except for certain
>> intrinsic SCons options. This seems quite restrictive. I have many options
>> of this form:
>> choices=['on', 'off', 'auto'],
>> help='faster dependency checking',
>> The 'auto' value is intended to allow the system to decide whether 'on'
>> or 'off' is appropriate, given the value of other options. However, the end
>> result is that it should hold the value 'on' or 'off'. So, ideally, I'd
>> later write:
>> if GetOption('build-fast') == 'auto':
>> if <conditions>:
>> SetOption('build-fast') = 'on'
>> SetOption('build-fast') = 'off'
>> That way, once I've done this normalization step, I can just ask anywhere
>> I need:
>> if GetOption('build-fast') == 'on':
>> However, it seems that this is forbidden by SCons internally, even for
>> user-defined options, failing with a message like:
>> scons: *** This option is not settable from a SConscript file: build-fast
>> As a result, I need to hoist the option value into a variable, and
>> normalize that, then Export it for others to see and use instead of the
>> option value:
>> build_fast = GetOption('build-fast')
>> if build_fast == 'auto':
>> build_fast = 'on' if conditions else 'off'
>> This is unfortunate, since now the value of GetOption('build-fast')
>> isn't canonical, this exported state variable is instead, they vary in
>> their values, and it is easy to query the wrong one yielding different
>> I understand that some intrinsic SCons options may not make sense to be
>> reset, but is there an explicit reason that it cannot be done for user
>> defined options?
> Sent from my Android with K-9 Mail.
> Scons-users mailing list
> Scons-users at scons.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Scons-users