summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2025-12-05 08:58:25 -0800
committerDylan Baker <dylan@pnwbakers.com>2025-12-17 14:04:17 -0800
commit404139d72a3fba77bbc3d4c4d6549b542694dfa0 (patch)
tree7717e867dc377d95360e3de69061735811bfec1d
parentbde1c23b4f3eb9eb63e835b722bb9bbcccc4c8c1 (diff)
downloadmeson-404139d72a3fba77bbc3d4c4d6549b542694dfa0.tar.gz
build|interpreter: use the LINK_WHOLE validator for BuildTarget
-rw-r--r--mesonbuild/build.py14
-rw-r--r--mesonbuild/interpreter/kwargs.py1
-rw-r--r--mesonbuild/interpreter/type_checking.py1
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,