Skip to content

Commit

Permalink
Allow passing dict to name_prefix/suffix kwargs
Browse files Browse the repository at this point in the history
The dict must map a target type to a string. This makes possible to pass
different name_prefix and name_suffix to static and shared libraries
when using both_libraries().

Closes #4133.
  • Loading branch information
xclaesse committed Sep 11, 2018
1 parent 6231ee7 commit 5c6e7de
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions mesonbuild/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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.')
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 5c6e7de

Please sign in to comment.