From 64bfc6cf7b6439578191e75cbc05bb96de1c70e2 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Sun, 13 May 2018 10:36:58 -0400 Subject: [PATCH] UserArrayOption: Add support for splitting on space instead of coma --- mesonbuild/coredata.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index f3313f3f9..93a3d2f76 100644 --- a/mesonbuild/coredata.py +++ b/mesonbuild/coredata.py @@ -138,8 +138,9 @@ class UserComboOption(UserOption): return value class UserArrayOption(UserOption): - def __init__(self, name, description, value, **kwargs): + def __init__(self, name, description, value, shlex_split=False, **kwargs): super().__init__(name, description, kwargs.get('choices', []), yielding=kwargs.get('yielding', None)) + self.shlex_split = shlex_split self.value = self.validate_value(value, user_input=False) def validate_value(self, value, user_input=True): @@ -159,7 +160,10 @@ class UserArrayOption(UserOption): if value.startswith('['): newvalue = ast.literal_eval(value) else: - newvalue = [v.strip() for v in value.split(',')] + if self.shlex_split: + newvalue = shlex.split(value) + else: + newvalue = [v.strip() for v in value.split(',')] if len(set(newvalue)) != len(newvalue): mlog.log(mlog.red('DEPRECATION:'), '''Duplicated values in an array type is deprecated. This will become a hard error in the future.''')