diff --git a/mesonbuild/build.py b/mesonbuild/build.py index a7a43b40c..45ff4cc2c 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -137,6 +137,15 @@ def get_target_macos_dylib_install_name(ld) -> str: name.append('.dylib') return ''.join(name) + +def extract_targets_as_list( + kwargs: T.Dict[str, T.Sequence[LibTypes]], + key: T.Literal['link_with', 'link_whole'], + self_libs: T.List[LibTypes]) -> T.List[LibTypes]: + lib_list = listify(kwargs.get(key, [])) + self_libs + return [t.get_default_object() if isinstance(t, BothLibraries) else t for t in lib_list] + + class InvalidArguments(MesonException): pass @@ -782,8 +791,8 @@ class BuildTarget(Target): # we have to call process_compilers() first and we need to process libraries # from link_with and link_whole first. # See https://github.com/mesonbuild/meson/pull/11957#issuecomment-1629243208. - link_targets = extract_as_list(kwargs, 'link_with') + self.link_targets - link_whole_targets = extract_as_list(kwargs, 'link_whole') + self.link_whole_targets + link_targets = extract_targets_as_list(kwargs, 'link_with', self.link_targets) + link_whole_targets = extract_targets_as_list(kwargs, 'link_whole', self.link_whole_targets) self.link_targets.clear() self.link_whole_targets.clear() self.link(link_targets) @@ -2493,6 +2502,9 @@ class BothLibraries(SecondLevelHolder): return self.static raise MesonBugException(f'self._preferred_library == "{self._preferred_library}" is neither "shared" nor "static".') + def get_id(self) -> str: + return self.get_default_object().get_id() + class CommandBase: depend_files: T.List[File] diff --git a/mesonbuild/interpreter/interpreter.py b/mesonbuild/interpreter/interpreter.py index 9de0f8762..d69f569c2 100644 --- a/mesonbuild/interpreter/interpreter.py +++ b/mesonbuild/interpreter/interpreter.py @@ -690,6 +690,7 @@ class Interpreter(InterpreterBase, HoldableObject): KwargInfo('version', (str, NoneType)), KwargInfo('objects', ContainerTypeInfo(list, build.ExtractedObjects), listify=True, default=[], since='1.1.0'), ) + @noSecondLevelHolderResolving def func_declare_dependency(self, node: mparser.BaseNode, args: T.List[TYPE_var], kwargs: kwtypes.FuncDeclareDependency) -> dependencies.Dependency: deps = kwargs['dependencies']