[Scons-users] Using Validators

Dirk Bächle tshortik at gmx.de
Fri Jul 18 05:37:25 EDT 2014


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.

Best regards,

Dirk



More information about the Scons-users mailing list