diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-11-17 10:22:03 -0500 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2021-12-22 08:04:08 +0530 |
commit | 95a4c6a62a925fc888e7c07ae3d9937c87e1c759 (patch) | |
tree | 2cdaceb586e019c60316995c1504e5d45b36385a /mesonbuild | |
parent | ee0baa97cd0411e15bd8f47e3874f217887d0a7a (diff) | |
download | meson-95a4c6a62a925fc888e7c07ae3d9937c87e1c759.zip meson-95a4c6a62a925fc888e7c07ae3d9937c87e1c759.tar.gz meson-95a4c6a62a925fc888e7c07ae3d9937c87e1c759.tar.bz2 |
pkgconfig: Fix linking to a custom target
When generating pkgconfig file for a library that links to an
uninstalled static library built by custom_target() Meson was crashing
when trying to access some attributes that does not exist on that class.
Also fix is_internal() implementation, it only really make sense on a
CustomTargetIndex or if CustomTarget has only a single output.
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/build.py | 19 | ||||
-rw-r--r-- | mesonbuild/modules/pkgconfig.py | 3 |
2 files changed, 13 insertions, 9 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py index 7c873b2..70f52f9 100644 --- a/mesonbuild/build.py +++ b/mesonbuild/build.py @@ -2588,13 +2588,12 @@ class CustomTarget(Target, CommandBase): return [] def is_internal(self) -> bool: - if not self.should_install(): - return True - for out in self.get_outputs(): - # Can't check if this is a static library, so try to guess - if not out.endswith(('.a', '.lib')): - return False - return True + ''' + Returns True iif this is a not installed static library. + ''' + if len(self.outputs) != 1: + return False + return CustomTargetIndex(self, self.outputs[0]).is_internal() def extract_all_objects_recurse(self) -> T.List[T.Union[str, 'ExtractedObjects']]: return self.get_outputs() @@ -2764,7 +2763,11 @@ class CustomTargetIndex(HoldableObject): return self.target.should_install() def is_internal(self) -> bool: - return self.target.is_internal() + ''' + Returns True iif this is a not installed static library + ''' + suf = os.path.splitext(self.output)[-1] + return suf in {'.a', '.lib'} and not self.should_install() def extract_all_objects_recurse(self) -> T.List[T.Union[str, 'ExtractedObjects']]: return self.target.extract_all_objects_recurse() diff --git a/mesonbuild/modules/pkgconfig.py b/mesonbuild/modules/pkgconfig.py index 4a0b39e..6c5d347 100644 --- a/mesonbuild/modules/pkgconfig.py +++ b/mesonbuild/modules/pkgconfig.py @@ -183,7 +183,8 @@ class DependenciesHelper: # lists in case a library is link_with and link_whole at the same time. # See remove_dups() below. self.link_whole_targets.append(t) - self._add_lib_dependencies(t.link_targets, t.link_whole_targets, t.external_deps, public) + if isinstance(t, build.BuildTarget): + self._add_lib_dependencies(t.link_targets, t.link_whole_targets, t.external_deps, public) def add_version_reqs(self, name, version_reqs): if version_reqs: |