aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2020-11-17 10:22:03 -0500
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2021-12-22 08:04:08 +0530
commit95a4c6a62a925fc888e7c07ae3d9937c87e1c759 (patch)
tree2cdaceb586e019c60316995c1504e5d45b36385a /mesonbuild/build.py
parentee0baa97cd0411e15bd8f47e3874f217887d0a7a (diff)
downloadmeson-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/build.py')
-rw-r--r--mesonbuild/build.py19
1 files changed, 11 insertions, 8 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()