UserArrayOption: Allow duplicates when used as <lang>_args option

Closes: #4021.
pull/4064/head
Xavier Claessens 7 years ago
parent 6e00ab6236
commit 576f3bb1bf
  1. 4
      mesonbuild/compilers/compilers.py
  2. 5
      mesonbuild/coredata.py

@ -858,11 +858,11 @@ class Compiler:
self.language + '_args': coredata.UserArrayOption(
self.language + '_args',
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',
description + ' linker',
link_args, shlex_split=True, user_input=True),
link_args, shlex_split=True, user_input=True, allow_dups=True),
})
return opts

@ -138,9 +138,10 @@ class UserComboOption(UserOption):
return value
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))
self.shlex_split = shlex_split
self.allow_dups = allow_dups
self.value = self.validate_value(value, user_input=user_input)
def validate_value(self, value, user_input=True):
@ -166,7 +167,7 @@ class UserArrayOption(UserOption):
else:
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. ' \
'This will become a hard error in the future.' % (self.name)
mlog.deprecation(msg)

Loading…
Cancel
Save