aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesonbuild/build.py9
-rw-r--r--test cases/common/216 link custom/meson.build10
2 files changed, 17 insertions, 2 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 4052beb..13a57e7 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -1070,13 +1070,18 @@ You probably should put it in link_with instead.''')
def link_whole(self, target):
for t in listify(target, unholder=True):
- if not isinstance(t, StaticLibrary):
+ if isinstance(t, CustomTarget):
+ if not t.is_linkable_target():
+ raise InvalidArguments('Custom target {!r} is not linkable.'.format(t))
+ if not t.get_filename().endswith('.a'):
+ raise InvalidArguments('Can only link_whole custom targets that are .a archives.')
+ elif not isinstance(t, StaticLibrary):
raise InvalidArguments('{!r} is not a static library.'.format(t))
if isinstance(self, SharedLibrary) and not t.pic:
msg = "Can't link non-PIC static library {!r} into shared library {!r}. ".format(t.name, self.name)
msg += "Use the 'pic' option to static_library to build with PIC."
raise InvalidArguments(msg)
- if self.is_cross != t.is_cross:
+ if not isinstance(t, CustomTarget) and self.is_cross != t.is_cross:
raise InvalidArguments('Tried to mix cross built and native libraries in target {!r}'.format(self.name))
self.link_whole_targets.append(t)
diff --git a/test cases/common/216 link custom/meson.build b/test cases/common/216 link custom/meson.build
index a1923b9..5af27cd 100644
--- a/test cases/common/216 link custom/meson.build
+++ b/test cases/common/216 link custom/meson.build
@@ -23,3 +23,13 @@ d = declare_dependency(link_with: clib)
exe2 = executable('prog2', 'prog.c', dependencies: d)
test('linkcustom2', exe2)
+
+# Link whole tests
+
+exe3 = executable('prog3', 'prog.c', link_whole: clib)
+test('linkwhole', exe)
+
+d2 = declare_dependency(link_whole: clib)
+
+exe4 = executable('prog4', 'prog.c', dependencies: d2)
+test('linkwhole2', exe2)