aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-03-27 10:39:18 -0400
committerXavier Claessens <xclaesse@gmail.com>2023-03-27 15:19:17 -0400
commit65c22d8c38eba320f34576f917b106cc03e89123 (patch)
treecb6c1ace93e402016407fce424721a17ea315ac9
parent0c91c474d379e21a6c4f117aecd7178f6ff353dd (diff)
downloadmeson-65c22d8c38eba320f34576f917b106cc03e89123.zip
meson-65c22d8c38eba320f34576f917b106cc03e89123.tar.gz
meson-65c22d8c38eba320f34576f917b106cc03e89123.tar.bz2
custom_target: libfoo.so.1 is linkable
-rw-r--r--mesonbuild/build.py14
-rw-r--r--test cases/common/208 link custom/meson.build9
2 files changed, 18 insertions, 5 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 82992cd..6d6403b 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -2595,11 +2595,18 @@ class CustomTarget(Target, CommandBase):
raise InvalidArguments('Substitution in depfile for custom_target that does not have an input file.')
return self.depfile
+ def is_linkable_output(self, output: str) -> bool:
+ if output.endswith(('.a', '.dll', '.lib', '.so', '.dylib')):
+ return True
+ # libfoo.so.X soname
+ if re.search(r'\.so(\.\d+)*$', output):
+ return True
+ return False
+
def is_linkable_target(self) -> bool:
if len(self.outputs) != 1:
return False
- suf = os.path.splitext(self.outputs[0])[-1]
- return suf in {'.a', '.dll', '.lib', '.so', '.dylib'}
+ return self.is_linkable_output(self.outputs[0])
def links_dynamically(self) -> bool:
"""Whether this target links dynamically or statically
@@ -2868,8 +2875,7 @@ class CustomTargetIndex(HoldableObject):
return self.target.get_link_dep_subdirs()
def is_linkable_target(self) -> bool:
- suf = os.path.splitext(self.output)[-1]
- return suf in {'.a', '.dll', '.lib', '.so', '.dylib'}
+ return self.target.is_linkable_output(self.output)
def links_dynamically(self) -> bool:
"""Whether this target links dynamically or statically
diff --git a/test cases/common/208 link custom/meson.build b/test cases/common/208 link custom/meson.build
index 4d4f655..41ce78c 100644
--- a/test cases/common/208 link custom/meson.build
+++ b/test cases/common/208 link custom/meson.build
@@ -83,4 +83,11 @@ exe1 = executable('exe1', 'custom_target.c', link_with: lib1)
test('custom_target_1', exe1)
exe1_2 = executable('exe1_2', 'custom_target.c', link_with: lib2)
-test('custom_target_2', exe2) \ No newline at end of file
+test('custom_target_2', exe2)
+
+# Link with custom target containing a SONAME
+dummy3 = shared_library('dummy3', 'dummy.c', version: '1.0')
+t = custom_target(input: dummy, output: 'libcustom@PLAINNAME@', command: [custom_prog, '@INPUT@', '@OUTPUT@'])
+lib3 = static_library('lib3', 'outerlib.c', link_with: t)
+exe3 = executable('exe3', 'custom_target.c', link_with: lib3)
+test('custom_target_3', exe3)