[Scons-users] Using Validators

Florian Lindner mailinglists at xgm.de
Fri Jul 18 06:19:37 EDT 2014


Dirk Bächle wrote:

> Florian,
> 
> On 18.07.2014 11:16, Florian Lindner wrote:
>> Hello,
>>
>> I have a Variable with an validator:
>>
>> vars.Add("compiler", "desc", "g++", validator=compiler_validator)
>>
>> def compiler_validator(key, value, environment):
>>      if value in ["g++", "icc", "clang++"] or value.startswith("mpic"):
>>          return True
>>      else:
>>          return False
>>
>>
>> When called
>> scons [...] compiler=clang
>> the function above is called and returns False. Despite of that the
>> compilation starts...
>>
>> [...]
>>
>> I suppose that return False on invalidate values is correctly, the
>> validator is undocumented and the API states only the arguments, not the
>> return type and semantics.
> the MAN page gives an example for this. The return value of the
> validator method never gets checked, you have to throw an exception
> instead.

Ok, thanks.

Honestly, I never expected to find this in a manpage. The manpage I rather 
search for command line options and switches for scons.

Throwing the exception works, albeit is not very beautiful.

Regards,
Florian



More information about the Scons-users mailing list