aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-12-03 22:35:44 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2017-12-03 22:35:44 +0200
commit2cf1e8da15b954725fa9c9467bfb35a516814c89 (patch)
tree1b3c1a344095fa256233d268ed685f7a58ffe13a /mesonbuild
parent754e33e574dd37ab0efb0d336bb805861bc3e6cf (diff)
parentf8a419b27d3605c4b4d1af42debb10124a51b908 (diff)
downloadmeson-2cf1e8da15b954725fa9c9467bfb35a516814c89.zip
meson-2cf1e8da15b954725fa9c9467bfb35a516814c89.tar.gz
meson-2cf1e8da15b954725fa9c9467bfb35a516814c89.tar.bz2
Merged array option branch.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/coredata.py7
-rw-r--r--mesonbuild/optinterpreter.py20
2 files changed, 16 insertions, 11 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 7fbf18a..376570c 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -132,7 +132,7 @@ class UserStringArrayOption(UserOption):
def validate(self, value, user_input):
# User input is for options defined on the command line (via -D
- # options). Users should put their input in as a comma separated
+ # options). Users can put their input in as a comma separated
# string, but for defining options in meson_options.txt the format
# should match that of a combo
if not user_input:
@@ -144,7 +144,10 @@ class UserStringArrayOption(UserOption):
newvalue = value
else:
assert isinstance(value, str)
- newvalue = [v.strip() for v in value.split(',')]
+ if value.startswith('['):
+ newvalue = ast.literal_eval(value)
+ else:
+ newvalue = [v.strip() for v in value.split(',')]
if not isinstance(newvalue, list):
raise MesonException('"{0}" should be a string array, but it is not'.format(str(newvalue)))
for i in newvalue:
diff --git a/mesonbuild/optinterpreter.py b/mesonbuild/optinterpreter.py
index 22a263e..3cca239 100644
--- a/mesonbuild/optinterpreter.py
+++ b/mesonbuild/optinterpreter.py
@@ -86,15 +86,17 @@ def ComboParser(name, description, kwargs):
@permitted_kwargs({'value', 'choices'})
def string_array_parser(name, description, kwargs):
- if 'choices' not in kwargs:
- raise OptionException('Array option missing "choices" keyword.')
- choices = kwargs['choices']
- if not isinstance(choices, list):
- raise OptionException('Array choices must be an array.')
- for i in choices:
- if not isinstance(i, str):
- raise OptionException('Array choice elements must be strings.')
- value = kwargs.get('value', choices)
+ if 'choices' in kwargs:
+ choices = kwargs['choices']
+ if not isinstance(choices, list):
+ raise OptionException('Array choices must be an array.')
+ for i in choices:
+ if not isinstance(i, str):
+ raise OptionException('Array choice elements must be strings.')
+ value = kwargs.get('value', choices)
+ else:
+ choices = None
+ value = kwargs.get('value', [])
if not isinstance(value, list):
raise OptionException('Array choices must be passed as an array.')
return coredata.UserStringArrayOption(name, description, value, choices=choices)