aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2017-08-22 22:59:49 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2017-08-22 23:00:26 +0300
commit3ff76f62a2f65c56ccaae33dee2571bff69563bc (patch)
tree40fe93546f2506e508da25626e2e9f6c6743b155
parent0a5bba1937111cfe0552ef39c59cc1691b2830e7 (diff)
downloadmeson-3ff76f62a2f65c56ccaae33dee2571bff69563bc.zip
meson-3ff76f62a2f65c56ccaae33dee2571bff69563bc.tar.gz
meson-3ff76f62a2f65c56ccaae33dee2571bff69563bc.tar.bz2
Clarify immutability description. Closes #2234.
-rw-r--r--docs/markdown/Configuration.md36
1 files changed, 27 insertions, 9 deletions
diff --git a/docs/markdown/Configuration.md b/docs/markdown/Configuration.md
index 70649d7..ae14e7b 100644
--- a/docs/markdown/Configuration.md
+++ b/docs/markdown/Configuration.md
@@ -4,7 +4,11 @@ short-description: Build-time configuration options
# Configuration
-If there are multiple configuration options, passing them through compiler flags becomes very burdensome. It also makes the configuration settings hard to inspect. To make things easier, Meson supports the generation of configure files. This feature is similar to one found in other build systems such as CMake.
+If there are multiple configuration options, passing them through
+compiler flags becomes very burdensome. It also makes the
+configuration settings hard to inspect. To make things easier, Meson
+supports the generation of configure files. This feature is similar to
+one found in other build systems such as CMake.
Suppose we have the following Meson snippet:
@@ -22,15 +26,22 @@ and that the contents of `config.h.in` are
#define VERSION_STR "@version@"
```
-Meson will then create a file called `config.h` in the corresponding build directory whose contents are the following.
+Meson will then create a file called `config.h` in the corresponding
+build directory whose contents are the following.
```c
#define VERSION_STR "1.2.3"
```
-More specifically, Meson will find all strings of the type `@varname@` and replace them with respective values set in `conf_data`. You can use a single `configuration_data` object as many times as you like, but it becomes immutable after the first use. That is, after it has been used once the `set` function becomes unusable and trying to call it causes an error.
+More specifically, Meson will find all strings of the type `@varname@`
+and replace them with respective values set in `conf_data`. You can
+use a single `configuration_data` object as many times as you like,
+but it becomes immutable after being passed to the `configure_file`
+function. That is, after it has been used once to generate output the
+`set` function becomes unusable and trying to call it causes an error.
-For more complex configuration file generation Meson provides a second form. To use it, put a line like this in your configuration file.
+For more complex configuration file generation Meson provides a second
+form. To use it, put a line like this in your configuration file.
#mesondefine TOKEN
@@ -43,20 +54,24 @@ The replacement that happens depends on what the value and type of TOKEN is:
/* undef TOKEN */ // If TOKEN has not been set to any value.
```
-Note that if you want to define a C string, you need to do the quoting yourself like this:
+Note that if you want to define a C string, you need to do the quoting
+yourself like this:
```meson
conf.set('TOKEN', '"value"')
```
-Since this is such a common operation, Meson provides a convenience method:
+Since this is such a common operation, Meson provides a convenience
+method:
```meson
plain_var = 'value'
conf.set_quoted('TOKEN', plain_var) # becomes #define TOKEN "value"
```
-Often you have a boolean value in Meson but need to define the C/C++ token as 0 or 1. Meson provides a convenience function for this use case.
+Often you have a boolean value in Meson but need to define the C/C++
+token as 0 or 1. Meson provides a convenience function for this use
+case.
```meson
conf.set10(token, boolean_value)
@@ -70,7 +85,9 @@ endif
## Configuring without an input file
-If the input file is not defined then Meson will generate a header file all the entries in the configuration data object. The replacements are the same as when generating `#mesondefine` entries:
+If the input file is not defined then Meson will generate a header
+file all the entries in the configuration data object. The
+replacements are the same as when generating `#mesondefine` entries:
```meson
cdata.set('FOO', '"string"') => #define FOO "string"
@@ -81,7 +98,8 @@ cdata.set('FOO', 1) => #define FOO 1
cdata.set('FOO', 0) => #define FOO 0
```
-In this mode, you can also specify a comment which will be placed before the value so that your generated files are self-documenting.
+In this mode, you can also specify a comment which will be placed
+before the value so that your generated files are self-documenting.
```meson
cdata.set('BAR', true, description : 'Set BAR if it is available')