opts: Allow string concatenation (fixes #7199)

pull/7207/head
Daniel Mensinger 5 years ago committed by Xavier Claessens
parent 1d02fd924b
commit 7e8f1de063
  1. 7
      mesonbuild/optinterpreter.py
  2. 6
      test cases/common/43 options/meson_options.txt

@ -177,6 +177,13 @@ class OptionInterpreter:
if not isinstance(res, bool): if not isinstance(res, bool):
raise OptionException('Token after "not" is not a a boolean') raise OptionException('Token after "not" is not a a boolean')
return not res return not res
elif isinstance(arg, mparser.ArithmeticNode):
l = self.reduce_single(arg.left)
r = self.reduce_single(arg.right)
if not (arg.operation == 'add' and isinstance(l, str) and isinstance(r, str)):
raise OptionException('Only string concatenation with the "+" operator is allowed')
FeatureNew.single_use('string concatenation in meson_options.txt', '0.55.0', self.subproject)
return l + r
else: else:
raise OptionException('Arguments may only be string, int, bool, or array of those.') raise OptionException('Arguments may only be string, int, bool, or array of those.')

@ -1,7 +1,7 @@
option('testoption', type : 'string', value : 'optval', description : 'An option to do something') option('testoption', type : 'string', value : 'optval', description : 'An option ' + 'to do something')
option('other_one', type : 'boolean', value : not (not (not (not false)))) option('other_one', type : 'boolean', value : not (not (not (not false))))
option('combo_opt', type : 'combo', choices : ['one', 'two', 'combo'], value : 'combo') option('combo_opt', type : 'co' + 'mbo', choices : ['one', 'two', 'combo'], value : 'combo')
option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one', 'two']) option('array_opt', type : 'array', choices : ['one', 'two', 'three'], value : ['one', 'two'])
option('free_array_opt', type : 'array') 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) option('neg' + '_' + 'int' + '_' + 'opt', type : 'integer', min : -5, max : 5, value : -3)

Loading…
Cancel
Save