aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLyude Paul <lyude@redhat.com>2017-10-23 15:37:06 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2017-10-29 01:56:57 +0300
commit1a159db8e90fa6b9571a06768d6f1ba08074e819 (patch)
treead68a408fe39d115c84f04ab435f25e419011be1
parent6e406ed0dbd326728240237391e18b0726753b4b (diff)
downloadmeson-1a159db8e90fa6b9571a06768d6f1ba08074e819.zip
meson-1a159db8e90fa6b9571a06768d6f1ba08074e819.tar.gz
meson-1a159db8e90fa6b9571a06768d6f1ba08074e819.tar.bz2
Raise InvalidArguments when trying to link against strings
With executable(), if the link_with argument has a string as one of it's elements, meson ends up throwing an AttributeError exception: ... File "/home/lyudess/Projects/meson/mesonbuild/build.py", line 868, in link if not t.is_linkable_target(): AttributeError: 'str' object has no attribute 'is_linkable_target' Which is not very helpful in figuring out where exactly the project is trying to link against a string instead of an actual link target. So, fix this by verifying in BuildTarget.link() that each given target is actually a Target object and not something else. Additionally, add a simple test case for this in failing tests. At the moment, this test case just passes unconditionally due to meson throwing the AttributeError exception and failing as expected. However, this test case will be useful eventually if we ever end up making failing tests more strict about failing gracefully (per advice of QuLogic).
-rw-r--r--mesonbuild/build.py2
-rw-r--r--test cases/failing/66 string as link target/meson.build2
-rw-r--r--test cases/failing/66 string as link target/prog.c1
3 files changed, 5 insertions, 0 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index 2a71b8b..2840f29 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -863,6 +863,8 @@ You probably should put it in link_with instead.''')
def link(self, target):
for t in listify(target, unholder=True):
+ if not isinstance(t, Target):
+ raise InvalidArguments('{!r} is not a target.'.format(t))
if not t.is_linkable_target():
raise InvalidArguments('Link target {!r} is not linkable.'.format(t))
if isinstance(self, SharedLibrary) and isinstance(t, StaticLibrary) and not t.pic:
diff --git a/test cases/failing/66 string as link target/meson.build b/test cases/failing/66 string as link target/meson.build
new file mode 100644
index 0000000..cb83fff
--- /dev/null
+++ b/test cases/failing/66 string as link target/meson.build
@@ -0,0 +1,2 @@
+project('string as link argument', 'c')
+executable('myprog', 'prog.c', link_with: [ '' ])
diff --git a/test cases/failing/66 string as link target/prog.c b/test cases/failing/66 string as link target/prog.c
new file mode 100644
index 0000000..0314ff1
--- /dev/null
+++ b/test cases/failing/66 string as link target/prog.c
@@ -0,0 +1 @@
+int main(int argc, char **argv) { return 0; }