opts: Allow `-` and `not` in meson_options.txt (fixes #6948)
This commit is contained in:
parent
a54506fe46
commit
03b86cdbed
|
@ -166,6 +166,16 @@ class OptionInterpreter:
|
|||
return arg.value
|
||||
elif isinstance(arg, mparser.ArrayNode):
|
||||
return [self.reduce_single(curarg) for curarg in arg.args.arguments]
|
||||
elif isinstance(arg, mparser.UMinusNode):
|
||||
res = self.reduce_single(arg.value)
|
||||
if not isinstance(res, (int, float)):
|
||||
raise OptionException('Token after "-" is not a number')
|
||||
return -res
|
||||
elif isinstance(arg, mparser.NotNode):
|
||||
res = self.reduce_single(arg.value)
|
||||
if not isinstance(res, bool):
|
||||
raise OptionException('Token after "not" is not a a boolean')
|
||||
return not res
|
||||
else:
|
||||
raise OptionException('Arguments may only be string, int, bool, or array of those.')
|
||||
|
||||
|
|
|
@ -30,4 +30,8 @@ if get_option('integer_opt') != 3
|
|||
error('Incorrect value in integer option.')
|
||||
endif
|
||||
|
||||
if get_option('neg_int_opt') != -3
|
||||
error('Incorrect value in negative integer option.')
|
||||
endif
|
||||
|
||||
assert(get_option('wrap_mode') == 'default', 'Wrap mode option is broken.')
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
option('testoption', type : 'string', value : 'optval', description : 'An option to do something')
|
||||
option('other_one', type : 'boolean', value : false)
|
||||
option('other_one', type : 'boolean', value : not (not (not (not false))))
|
||||
option('combo_opt', type : 'combo', choices : ['one', 'two', 'combo'], value : 'combo')
|
||||
option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one', 'two'])
|
||||
option('free_array_opt', type : 'array')
|
||||
option('integer_opt', type : 'integer', min : 0, max : 5, value : 3)
|
||||
option('integer_opt', type : 'integer', min : 0, max : -(-5), value : 3)
|
||||
option('neg_int_opt', type : 'integer', min : -5, max : 5, value : -3)
|
||||
|
|
Loading…
Reference in New Issue