UserArrayOption: Allow duplicates when used as <lang>_args option
Closes: #4021.
This commit is contained in:
parent
6e00ab6236
commit
576f3bb1bf
|
@ -858,11 +858,11 @@ class Compiler:
|
||||||
self.language + '_args': coredata.UserArrayOption(
|
self.language + '_args': coredata.UserArrayOption(
|
||||||
self.language + '_args',
|
self.language + '_args',
|
||||||
description + ' compiler',
|
description + ' compiler',
|
||||||
compile_args, shlex_split=True, user_input=True),
|
compile_args, shlex_split=True, user_input=True, allow_dups=True),
|
||||||
self.language + '_link_args': coredata.UserArrayOption(
|
self.language + '_link_args': coredata.UserArrayOption(
|
||||||
self.language + '_link_args',
|
self.language + '_link_args',
|
||||||
description + ' linker',
|
description + ' linker',
|
||||||
link_args, shlex_split=True, user_input=True),
|
link_args, shlex_split=True, user_input=True, allow_dups=True),
|
||||||
})
|
})
|
||||||
|
|
||||||
return opts
|
return opts
|
||||||
|
|
|
@ -138,9 +138,10 @@ class UserComboOption(UserOption):
|
||||||
return value
|
return value
|
||||||
|
|
||||||
class UserArrayOption(UserOption):
|
class UserArrayOption(UserOption):
|
||||||
def __init__(self, name, description, value, shlex_split=False, user_input=False, **kwargs):
|
def __init__(self, name, description, value, shlex_split=False, user_input=False, allow_dups=False, **kwargs):
|
||||||
super().__init__(name, description, kwargs.get('choices', []), yielding=kwargs.get('yielding', None))
|
super().__init__(name, description, kwargs.get('choices', []), yielding=kwargs.get('yielding', None))
|
||||||
self.shlex_split = shlex_split
|
self.shlex_split = shlex_split
|
||||||
|
self.allow_dups = allow_dups
|
||||||
self.value = self.validate_value(value, user_input=user_input)
|
self.value = self.validate_value(value, user_input=user_input)
|
||||||
|
|
||||||
def validate_value(self, value, user_input=True):
|
def validate_value(self, value, user_input=True):
|
||||||
|
@ -166,7 +167,7 @@ class UserArrayOption(UserOption):
|
||||||
else:
|
else:
|
||||||
raise MesonException('"{0}" should be a string array, but it is not'.format(str(newvalue)))
|
raise MesonException('"{0}" should be a string array, but it is not'.format(str(newvalue)))
|
||||||
|
|
||||||
if len(set(newvalue)) != len(newvalue):
|
if not self.allow_dups and len(set(newvalue)) != len(newvalue):
|
||||||
msg = 'Duplicated values in array option "%s" is deprecated. ' \
|
msg = 'Duplicated values in array option "%s" is deprecated. ' \
|
||||||
'This will become a hard error in the future.' % (self.name)
|
'This will become a hard error in the future.' % (self.name)
|
||||||
mlog.deprecation(msg)
|
mlog.deprecation(msg)
|
||||||
|
|
Loading…
Reference in New Issue