interpreter: use typed_kwargs for build_target.name_suffix

pull/12392/head
Dylan Baker 1 year ago
parent 9f80a069ec
commit 1abdd9dd61
  1. 2
      mesonbuild/build.py
  2. 1
      mesonbuild/interpreter/kwargs.py
  3. 7
      mesonbuild/interpreter/type_checking.py

@ -1191,7 +1191,7 @@ class BuildTarget(Target):
raise InvalidArguments('name_prefix must be a string.')
self.prefix = name_prefix
self.name_prefix_set = True
if 'name_suffix' in kwargs:
if kwargs.get('name_suffix') is not None:
name_suffix = kwargs['name_suffix']
if isinstance(name_suffix, list):
if name_suffix:

@ -336,6 +336,7 @@ class _BaseBuildTarget(TypedDict):
link_depends: T.List[T.Union[str, File, build.CustomTarget, build.CustomTargetIndex, build.BuildTarget]]
link_language: T.Optional[str]
name_prefix: T.Optional[str]
name_suffix: T.Optional[str]
native: MachineChoice
override_options: T.Dict[OptionKey, T.Union[str, int, bool, T.List[str]]]
depend_files: NotRequired[T.List[File]]

@ -567,6 +567,12 @@ def _name_validator(arg: T.Optional[T.Union[str, T.List]]) -> T.Optional[str]:
return None
def _name_suffix_validator(arg: T.Optional[T.Union[str, T.List]]) -> T.Optional[str]:
if arg == '':
return 'must nt be a empty string. An empty array may be passed if you want Meson to use the default behavior.'
return _name_validator(arg)
_NAME_PREFIX_KW: KwargInfo[T.Optional[T.Union[str, T.List]]] = KwargInfo(
'name_prefix',
(str, NoneType, list),
@ -581,6 +587,7 @@ _BUILD_TARGET_KWS: T.List[KwargInfo] = [
BT_SOURCES_KW,
INCLUDE_DIRECTORIES.evolve(name='d_import_dirs'),
_NAME_PREFIX_KW,
_NAME_PREFIX_KW.evolve(name='name_suffix', validator=_name_suffix_validator),
RUST_CRATE_TYPE_KW,
KwargInfo('d_debug', ContainerTypeInfo(list, (str, int)), default=[], listify=True),
D_MODULE_VERSIONS_KW,

Loading…
Cancel
Save