aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2018-09-21 14:18:31 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2018-10-08 21:03:32 +0300
commit38a65821454495cb48ceeb6446de46805fcd2d41 (patch)
treef032c3db9f2aa4c650cace21609e8d3b8a8b9358 /docs
parent1e7aea65e68a43b0319a4a28908daddfec621548 (diff)
downloadmeson-38a65821454495cb48ceeb6446de46805fcd2d41.zip
meson-38a65821454495cb48ceeb6446de46805fcd2d41.tar.gz
meson-38a65821454495cb48ceeb6446de46805fcd2d41.tar.bz2
configure_file: Support taking values from a dict
Closes #4218
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/Configuration.md32
-rw-r--r--docs/markdown/Reference-manual.md9
2 files changed, 39 insertions, 2 deletions
diff --git a/docs/markdown/Configuration.md b/docs/markdown/Configuration.md
index 8b79bc6..cd1af14 100644
--- a/docs/markdown/Configuration.md
+++ b/docs/markdown/Configuration.md
@@ -121,6 +121,38 @@ you to specify which file encoding to use. It is however strongly advised to
convert your non utf-8 file to utf-8 whenever possible. Supported file
encodings are those of python3, see [standard-encodings](https://docs.python.org/3/library/codecs.html#standard-encodings).
+## Using dictionaries
+
+Since *0.49.0* `configuration_data()` takes an optional dictionary as first
+argument. If provided, each key/value pair is added into the
+`configuration_data` as if `set()` method was called for each of them.
+`configure_file()`'s `configuration` kwarg also accepts a dictionary instead of
+a configuration_data object.
+
+Example:
+```meson
+cdata = configuration_data({
+ 'STRING' : '"foo"',
+ 'INT' : 42,
+ 'DEFINED' : true,
+ 'UNDEFINED' : false,
+})
+
+configure_file(output : 'config1.h',
+ configuration : cdata,
+)
+
+configure_file(output : 'config2.h',
+ configuration : {
+ 'STRING' : '"foo"',
+ 'INT' : 42,
+ 'DEFINED' : true,
+ 'UNDEFINED' : false,
+ }
+)
+
+```
+
# A full example
Generating and using a configuration file requires the following steps:
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 0fb9f17..cc4ba9b 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -167,13 +167,17 @@ methods section](#build-target-object) below.
### configuration_data()
``` meson
- configuration_data_object = configuration_data()
+ configuration_data_object = configuration_data(...)
```
Creates an empty configuration object. You should add your
configuration with [its method calls](#configuration-data-object) and
finally use it in a call to `configure_file`.
+Since *0.49.0* takes an optional dictionary as first argument. If provided, each
+key/value pair is added into the `configuration_data` as if `set()` method was
+called for each of them.
+
### configure_file()
``` meson
@@ -187,7 +191,8 @@ When a [`configuration_data()`](#configuration_data) object is passed
to the `configuration:` keyword argument, it takes a template file as
the `input:` (optional) and produces the `output:` (required) by
substituting values from the configuration data as detailed in [the
-configuration file documentation](Configuration.md).
+configuration file documentation](Configuration.md). Since *0.49.0* a dictionary
+can be passed instead of a [`configuration_data()`](#configuration_data) object.
When a list of strings is passed to the `command:` keyword argument,
it takes any source or configured file as the `input:` and assumes