From 261878f438261585daa637e147c37dc60922afb1 Mon Sep 17 00:00:00 2001 From: Jon Turney Date: Sun, 5 May 2019 19:11:20 +0100 Subject: [PATCH] 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 --- mesonbuild/interpreter.py | 4 +++- .../97 custom target install data/Info.plist.cpp | 1 + .../97 custom target install data/meson.build | 11 +++++++++++ .../97 custom target install data/preproc.py | 13 +++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 test cases/failing/97 custom target install data/Info.plist.cpp create mode 100644 test cases/failing/97 custom target install data/meson.build create mode 100644 test cases/failing/97 custom target install data/preproc.py diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index ba9708317..3f9d46408 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 000000000..9ca2fcbaf --- /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 000000000..00d348cc0 --- /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 000000000..e6eba4c6a --- /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], '', '') + +inf = sys.argv[1] +outf = sys.argv[2] + +with open(outf, 'wb') as o: + with open(inf, 'rb') as i: + o.write(i.read())