aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Turney <jon.turney@dronecode.org.uk>2019-05-05 19:11:20 +0100
committerJussi Pakkanen <jpakkane@gmail.com>2019-05-05 21:11:20 +0300
commit261878f438261585daa637e147c37dc60922afb1 (patch)
tree26e8c3560d5924c3f92a672301d8a29f9c00e56d
parent128d313b66d2bcb28c149516e8ab3538c88105f1 (diff)
downloadmeson-261878f438261585daa637e147c37dc60922afb1.zip
meson-261878f438261585daa637e147c37dc60922afb1.tar.gz
meson-261878f438261585daa637e147c37dc60922afb1.tar.bz2
Fix an assertion exception when misusing install_data
* Failing test case for trying to install_data a custom_target * Validate install_data() arguments are either string or file
-rw-r--r--mesonbuild/interpreter.py4
-rw-r--r--test cases/failing/97 custom target install data/Info.plist.cpp1
-rw-r--r--test cases/failing/97 custom target install data/meson.build11
-rw-r--r--test cases/failing/97 custom target install data/preproc.py13
4 files changed, 28 insertions, 1 deletions
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index ba97083..3f9d464 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3421,8 +3421,10 @@ This will become a hard error in the future.''' % kwargs['input'], location=self
for s in raw_sources:
if isinstance(s, mesonlib.File):
sources.append(s)
- else:
+ elif isinstance(s, str):
source_strings.append(s)
+ else:
+ raise InvalidArguments('Argument {!r} must be string or file.'.format(s))
sources += self.source_strings_to_files(source_strings)
install_dir = kwargs.get('install_dir', None)
if not isinstance(install_dir, (str, type(None))):
diff --git a/test cases/failing/97 custom target install data/Info.plist.cpp b/test cases/failing/97 custom target install data/Info.plist.cpp
new file mode 100644
index 0000000..9ca2fcb
--- /dev/null
+++ b/test cases/failing/97 custom target install data/Info.plist.cpp
@@ -0,0 +1 @@
+Some data which gets processed before installation
diff --git a/test cases/failing/97 custom target install data/meson.build b/test cases/failing/97 custom target install data/meson.build
new file mode 100644
index 0000000..00d348c
--- /dev/null
+++ b/test cases/failing/97 custom target install data/meson.build
@@ -0,0 +1,11 @@
+project('custom target install data')
+
+preproc = find_program('preproc.py')
+
+t = custom_target('Info.plist',
+ command: [preproc, '@INPUT@', '@OUTPUT@'],
+ input: 'Info.plist.cpp',
+ output: 'Info.plist',
+)
+
+install_data(t)
diff --git a/test cases/failing/97 custom target install data/preproc.py b/test cases/failing/97 custom target install data/preproc.py
new file mode 100644
index 0000000..e6eba4c
--- /dev/null
+++ b/test cases/failing/97 custom target install data/preproc.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import sys
+
+if len(sys.argv) != 3:
+ print(sys.argv[0], '<input>', '<output>')
+
+inf = sys.argv[1]
+outf = sys.argv[2]
+
+with open(outf, 'wb') as o:
+ with open(inf, 'rb') as i:
+ o.write(i.read())