diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2020-05-25 10:06:41 +0200 |
---|---|---|
committer | Xavier Claessens <xclaesse@gmail.com> | 2020-05-26 13:48:26 -0400 |
commit | 7e8f1de063eea43bd9ff390e1573bd7ff475db54 (patch) | |
tree | 721e14f5abbb4f29b19305a4b69dd1751b0f3177 | |
parent | 1d02fd924bdd407f99b278286efff5aae98535cb (diff) | |
download | meson-7e8f1de063eea43bd9ff390e1573bd7ff475db54.zip meson-7e8f1de063eea43bd9ff390e1573bd7ff475db54.tar.gz meson-7e8f1de063eea43bd9ff390e1573bd7ff475db54.tar.bz2 |
opts: Allow string concatenation (fixes #7199)
-rw-r--r-- | mesonbuild/optinterpreter.py | 7 | ||||
-rw-r--r-- | test cases/common/43 options/meson_options.txt | 6 |
2 files changed, 10 insertions, 3 deletions
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py index dfbe6d7..81206ab 100644 --- a/mesonbuild/optinterpreter.py +++ b/mesonbuild/optinterpreter.py @@ -177,6 +177,13 @@ class OptionInterpreter: if not isinstance(res, bool): raise OptionException('Token after "not" is not a a boolean') 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: raise OptionException('Arguments may only be string, int, bool, or array of those.') diff --git a/test cases/common/43 options/meson_options.txt b/test cases/common/43 options/meson_options.txt index c5986ba..db649de 100644 --- a/test cases/common/43 options/meson_options.txt +++ b/test cases/common/43 options/meson_options.txt @@ -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('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('free_array_opt', type : 'array') 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) |