diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 0410b3144096..c87629108ff5 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -793,8 +793,8 @@ def process_kwargs(self, kwargs, environment): if not os.path.isfile(trial): raise InvalidArguments('Tried to add non-existing resource %s.' % r) self.resources = resources - if 'name_prefix' in kwargs: - name_prefix = kwargs['name_prefix'] + name_prefix = self.unwrap_target_dict(kwargs, 'name_prefix') + if name_prefix is not None: if isinstance(name_prefix, list): if name_prefix: raise InvalidArguments('name_prefix array must be empty to signify null.') @@ -803,8 +803,8 @@ def process_kwargs(self, kwargs, environment): raise InvalidArguments('name_prefix must be a string.') self.prefix = name_prefix self.name_prefix_set = True - if 'name_suffix' in kwargs: - name_suffix = kwargs['name_suffix'] + name_suffix = self.unwrap_target_dict(kwargs, 'name_suffix') + if name_suffix in not None: if isinstance(name_suffix, list): if name_suffix: raise InvalidArguments('name_suffix array must be empty to signify null.') @@ -1006,6 +1006,13 @@ def validate_target_dict(self, d): if k not in known_build_targets: raise MesonException('Dictionary keys must be in ' + str(known_build_targets)); + def unwrap_target_dict(self, kwargs, key): + value = kwargs.get(key, None) + if isinstance(value, dict): + self.validate_target_dict(value) + value = value.get(self.target_type, None) + return value + def validate_compiler_args(self, args): result = [] for a in args: