aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/Reference-manual.md5
-rw-r--r--mesonbuild/interpreter.py14
-rw-r--r--test cases/common/14 configure file/meson.build7
-rw-r--r--test cases/failing/91 invalid configure file/input0
-rw-r--r--test cases/failing/91 invalid configure file/meson.build9
5 files changed, 33 insertions, 2 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 3d4379a..5436ec3 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -231,6 +231,11 @@ the `@variable@` syntax.
- `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.
+- `install` *(added 0.50.0)* When true, this generated file is installed during
+the install step, and `install_dir` must be set and not empty. When false, this
+generated file is not installed regardless of the value of `install_dir`.
+When omitted it defaults to true when `install_dir` is set and not empty,
+false otherwise.
- `install_dir` the subdirectory to install the generated file to
(e.g. `share/myproject`), if omitted or given the value of empty
string, the file is not installed.
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
index 2a9d96e..e3a6a0b 100644
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -3530,6 +3530,7 @@ This will become a hard error in the future.''' % kwargs['input'])
@FeatureNewKwargs('configure_file', '0.47.0', ['copy', 'output_format', 'install_mode', 'encoding'])
@FeatureNewKwargs('configure_file', '0.46.0', ['format'])
@FeatureNewKwargs('configure_file', '0.41.0', ['capture'])
+ @FeatureNewKwargs('configure_file', '0.50.0', ['install'])
@permittedKwargs(permitted_kwargs['configure_file'])
def func_configure_file(self, node, args, kwargs):
if len(args) > 0:
@@ -3689,8 +3690,17 @@ This will become a hard error in the future.''' % kwargs['input'])
# Install file if requested, we check for the empty string
# for backwards compatibility. That was the behaviour before
# 0.45.0 so preserve it.
- idir = kwargs.get('install_dir', None)
- if isinstance(idir, str) and idir:
+ idir = kwargs.get('install_dir', '')
+ if not isinstance(idir, str):
+ raise InterpreterException('"install_dir" must be a string')
+ install = kwargs.get('install', idir != '')
+ if not isinstance(install, bool):
+ raise InterpreterException('"install" must be a boolean')
+ if install:
+ if not idir:
+ raise InterpreterException('"install_dir" must be specified '
+ 'when "install" in a configure_file '
+ 'is true')
cfile = mesonlib.File.from_built_file(ofile_path, ofile_fname)
install_mode = self._get_kwarg_install_mode(kwargs)
self.build.data.append(build.Data([cfile], idir, install_mode))
diff --git a/test cases/common/14 configure file/meson.build b/test cases/common/14 configure file/meson.build
index 53b06f3..982ae2a 100644
--- a/test cases/common/14 configure file/meson.build
+++ b/test cases/common/14 configure file/meson.build
@@ -141,6 +141,13 @@ cfile = configure_file(input : 'config.h.in',
install_dir : '',
configuration : conf)
+# test intsall_dir with install: false
+cfile = configure_file(input : 'config.h.in',
+ output : 'do_not_get_installed_in_install_dir.h',
+ install : false,
+ install_dir : 'share/appdir',
+ configuration : conf)
+
# Test escaping with cmake format
conf7 = configuration_data()
conf7.set('var1', 'foo')
diff --git a/test cases/failing/91 invalid configure file/input b/test cases/failing/91 invalid configure file/input
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test cases/failing/91 invalid configure file/input
diff --git a/test cases/failing/91 invalid configure file/meson.build b/test cases/failing/91 invalid configure file/meson.build
new file mode 100644
index 0000000..08eca2b
--- /dev/null
+++ b/test cases/failing/91 invalid configure file/meson.build
@@ -0,0 +1,9 @@
+project('invalid configura file')
+
+configure_file(
+ configuration : configuration_data(),
+ input : 'input',
+ output : 'output',
+ install_dir : '',
+ install : true,
+)