diff options
| author | Dylan Baker <dylan@pnwbakers.com> | 2025-12-05 08:58:25 -0800 |
|---|---|---|
| committer | Dylan Baker <dylan@pnwbakers.com> | 2025-12-17 14:04:17 -0800 |
| commit | 404139d72a3fba77bbc3d4c4d6549b542694dfa0 (patch) | |
| tree | 7717e867dc377d95360e3de69061735811bfec1d /mesonbuild | |
| parent | bde1c23b4f3eb9eb63e835b722bb9bbcccc4c8c1 (diff) | |
| download | meson-404139d72a3fba77bbc3d4c4d6549b542694dfa0.tar.gz | |
build|interpreter: use the LINK_WHOLE validator for BuildTarget
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/build.py | 14 | ||||
| -rw-r--r-- | mesonbuild/interpreter/kwargs.py | 1 | ||||
| -rw-r--r-- | mesonbuild/interpreter/type_checking.py | 1 |
3 files changed, 7 insertions, 9 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index ae6770be2..32a643601 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -1491,16 +1491,12 @@ class BuildTarget(Target): self.check_can_link_together(t) self.link_targets.append(t) - def link_whole(self, targets: T.List[BuildTargetTypes], promoted: bool = False) -> None: + def link_whole( + self, + targets: T.List[T.Union[StaticLibrary, CustomTarget, CustomTargetIndex]], + promoted: bool = False) -> None: for t in targets: - if isinstance(t, (CustomTarget, CustomTargetIndex)): - if not t.is_linkable_target(): - raise InvalidArguments(f'Custom target {t!r} is not linkable.') - if t.links_dynamically(): - raise InvalidArguments('Can only link_whole custom targets that are static archives.') - elif not isinstance(t, StaticLibrary): - raise InvalidArguments(f'{t!r} is not a static library.') - elif isinstance(self, SharedLibrary) and not t.pic: + if isinstance(self, SharedLibrary) and not getattr(t, 'pic', True): msg = f"Can't link non-PIC static library {t.name!r} into shared library {self.name!r}. " msg += "Use the 'pic' option to static_library to build with PIC." raise InvalidArguments(msg) diff --git a/mesonbuild/interpreter/kwargs.py b/mesonbuild/interpreter/kwargs.py index 1dee9a65c..e3e919019 100644 --- a/mesonbuild/interpreter/kwargs.py +++ b/mesonbuild/interpreter/kwargs.py @@ -348,6 +348,7 @@ class _BaseBuildTarget(TypedDict): implicit_include_directories: bool link_depends: T.List[T.Union[str, File, build.GeneratedTypes]] link_language: T.Optional[str] + link_whole: T.List[T.Union[build.StaticLibrary, build.CustomTarget, build.CustomTargetIndex]] name_prefix: T.Optional[str] name_suffix: T.Optional[str] native: MachineChoice diff --git a/mesonbuild/interpreter/type_checking.py b/mesonbuild/interpreter/type_checking.py index 7515cbcef..259b55f75 100644 --- a/mesonbuild/interpreter/type_checking.py +++ b/mesonbuild/interpreter/type_checking.py @@ -726,6 +726,7 @@ _BUILD_TARGET_KWS: T.List[KwargInfo] = [ INCLUDE_DIRECTORIES.evolve(since_values={ContainerTypeInfo(list, str): '0.50.0'}), DEPENDENCIES_KW, INCLUDE_DIRECTORIES.evolve(name='d_import_dirs'), + LINK_WHOLE_KW, _NAME_PREFIX_KW, _NAME_PREFIX_KW.evolve(name='name_suffix', validator=_name_suffix_validator), RUST_CRATE_TYPE_KW, |
