From e79b602298ca3810c4ee0c99a23ae3ae50c879b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A1lint=20Aradi?= Date: Fri, 19 May 2017 17:22:42 +0200 Subject: [PATCH] Enable variables for output in configure_file --- mesonbuild/interpreter.py | 4 ++++ test cases/common/16 configure file/config4a.h.in | 2 ++ test cases/common/16 configure file/config4b.h.in | 2 ++ test cases/common/16 configure file/meson.build | 12 ++++++++++++ test cases/common/16 configure file/prog4.c | 6 ++++++ 5 files changed, 26 insertions(+) create mode 100644 test cases/common/16 configure file/config4a.h.in create mode 100644 test cases/common/16 configure file/config4b.h.in create mode 100644 test cases/common/16 configure file/prog4.c diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 454ee66cb..39d596ff3 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -2344,6 +2344,10 @@ class Interpreter(InterpreterBase): output = kwargs['output'] if not isinstance(output, str): raise InterpreterException('Output file name must be a string') + if ifile_abs: + values = mesonlib.get_filenames_templates_dict([ifile_abs], None) + outputs = mesonlib.substitute_values([output], values) + output = outputs[0] if os.path.split(output)[0] != '': raise InterpreterException('Output file name must not contain a subdirectory.') (ofile_path, ofile_fname) = os.path.split(os.path.join(self.subdir, output)) diff --git a/test cases/common/16 configure file/config4a.h.in b/test cases/common/16 configure file/config4a.h.in new file mode 100644 index 000000000..aafd195c2 --- /dev/null +++ b/test cases/common/16 configure file/config4a.h.in @@ -0,0 +1,2 @@ +/* Dummy file */ +#define RESULTA @ZERO@ diff --git a/test cases/common/16 configure file/config4b.h.in b/test cases/common/16 configure file/config4b.h.in new file mode 100644 index 000000000..3408bab6f --- /dev/null +++ b/test cases/common/16 configure file/config4b.h.in @@ -0,0 +1,2 @@ +/* Dummy file */ +#define RESULTB @ZERO@ diff --git a/test cases/common/16 configure file/meson.build b/test cases/common/16 configure file/meson.build index 8ffc28cc3..0d0e46107 100644 --- a/test cases/common/16 configure file/meson.build +++ b/test cases/common/16 configure file/meson.build @@ -74,3 +74,15 @@ configure_file(output : 'config3.h', configuration : dump) test('Configless.', executable('dumpprog', 'dumpprog.c')) + + +# Config file generation in a loop with @BASENAME@ substitution +dump = configuration_data() +dump.set('ZERO', 0) +config_templates = files(['config4a.h.in', 'config4b.h.in']) +foreach config_template : config_templates + configure_file(input : config_template, output : '@BASENAME@', + configuration : dump) +endforeach + +test('Substituted', executable('prog4', 'prog4.c')) diff --git a/test cases/common/16 configure file/prog4.c b/test cases/common/16 configure file/prog4.c new file mode 100644 index 000000000..92dc7cbb6 --- /dev/null +++ b/test cases/common/16 configure file/prog4.c @@ -0,0 +1,6 @@ +#include +#include + +int main(int argc, char **argv) { + return RESULTA + RESULTB; +}