diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2017-06-03 21:29:01 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-03 21:29:01 +0300 |
commit | 3f6c55b9b3ac5a19d30cf2b5a33af906c5885cf0 (patch) | |
tree | bd932935cba186808024ced12678333f5f1a5708 | |
parent | 4828b46b73c0e4874634be0439a1653144e4e0e7 (diff) | |
parent | 706b3cafab114e8d7ff7306cb471259ae1597e04 (diff) | |
download | meson-3f6c55b9b3ac5a19d30cf2b5a33af906c5885cf0.zip meson-3f6c55b9b3ac5a19d30cf2b5a33af906c5885cf0.tar.gz meson-3f6c55b9b3ac5a19d30cf2b5a33af906c5885cf0.tar.bz2 |
Merge pull request #1857 from aradi/configure-subsval
Configure subsval
-rw-r--r-- | docs/markdown/Reference-manual.md | 2 | ||||
-rw-r--r-- | docs/markdown/Release-notes-for-0.41.0.md | 4 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 4 | ||||
-rw-r--r-- | test cases/common/16 configure file/config4a.h.in | 2 | ||||
-rw-r--r-- | test cases/common/16 configure file/config4b.h.in | 2 | ||||
-rw-r--r-- | test cases/common/16 configure file/meson.build | 12 | ||||
-rw-r--r-- | test cases/common/16 configure file/prog4.c | 6 |
7 files changed, 31 insertions, 1 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index fab317d..29c073c 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -124,7 +124,7 @@ When a list of strings is passed to the `command:` keyword argument, it takes an These are all the supported keyword arguments: - `input` the input file name. If it's not specified in configuration mode, all the variables in the `configuration:` object (see above) are written to the `output:` file. -- `output` the output file name. In configuration mode, the permissions of the input file (if it is specified) are copied to the output file. +- `output` the output file name (since v0.41.0, may contain `@PLAINNAME@` or `@BASENAME@` substitutions). In configuration mode, the permissions of the input file (if it is specified) are copied to the output file. - `configuration` as explained above, this is where you pass the configuration data object as returned by `configuration_data()` - `command` as explained above, if specified, Meson does not create the file itself but rather runs the specified command, which allows you to do fully custom file generation - `install_dir` the subdirectory to install the generated file to (e.g. `share/myproject`), if omitted the file is not installed. diff --git a/docs/markdown/Release-notes-for-0.41.0.md b/docs/markdown/Release-notes-for-0.41.0.md index 80bf0b3..f995cc5 100644 --- a/docs/markdown/Release-notes-for-0.41.0.md +++ b/docs/markdown/Release-notes-for-0.41.0.md @@ -67,3 +67,7 @@ coverage must be combined before producing a report (`coverage3 combine`.) All known issues have been fixed and Meson can now build reproducible Debian packages out of the box. +## Extended template substitution in configure_file + +The output argument of `configure_file()` is parsed for @BASENAME@ and +@PLAINNAME@ substitutions. diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 454ee66..39d596f 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 0000000..aafd195 --- /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 0000000..3408bab --- /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 8ffc28c..0d0e461 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 0000000..92dc7cb --- /dev/null +++ b/test cases/common/16 configure file/prog4.c @@ -0,0 +1,6 @@ +#include <config4a.h> +#include <config4b.h> + +int main(int argc, char **argv) { + return RESULTA + RESULTB; +} |