diff options
author | Xavier Claessens <xavier.claessens@collabora.com> | 2020-06-11 16:04:50 -0400 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2020-06-29 20:16:21 +0300 |
commit | 1c8731a10018e8ba1e6b30411a290ca50fa45d81 (patch) | |
tree | 9c5332199c2acd2f26bb131429e1251b76cd7dfa /docs/markdown/Machine-files.md | |
parent | 5696a5abbaaff75279d9c50d431de47f35dc6228 (diff) | |
download | meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.zip meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.gz meson-1c8731a10018e8ba1e6b30411a290ca50fa45d81.tar.bz2 |
envconfig: Add [constants] section in machine files
Machine files already supports `+` operator as an implementation detail,
since it's using eval(). Now make it an officially supported feature and
add a way to define constants that are used while evaluating an entry
value.
Diffstat (limited to 'docs/markdown/Machine-files.md')
-rw-r--r-- | docs/markdown/Machine-files.md | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/docs/markdown/Machine-files.md b/docs/markdown/Machine-files.md index 404c3d2..9011f79 100644 --- a/docs/markdown/Machine-files.md +++ b/docs/markdown/Machine-files.md @@ -8,10 +8,83 @@ environments](Native-environments.md). ## Sections The following sections are allowed: +- constants - binaries - paths - properties +### constants + +*Since 0.55.0* + +String and list concatenation is supported using the `+` operator, joining paths +is supported using the `/` operator. +Entries defined in the `[constants]` section can be used in any other section +(they are always parsed first), entries in any other section can be used only +within that same section and only after it has been defined. + +```ini +[constants] +toolchain = '/toolchain' +common_flags = ['--sysroot=' + toolchain / 'sysroot'] + +[properties] +c_args = common_flags + ['-DSOMETHING'] +cpp_args = c_args + ['-DSOMETHING_ELSE'] + +[binaries] +c = toolchain / 'gcc' +``` + +This can be useful with cross file composition as well. A generic cross file +could be composed with a platform specific file where constants are defined: +```ini +# aarch64.ini +[constants] +arch = 'aarch64-linux-gnu' +``` + +```ini +# cross.ini +[binaries] +c = arch + '-gcc' +cpp = arch + '-g++' +strip = arch + '-strip' +pkgconfig = arch + '-pkg-config' +... +``` + +This can be used as `meson setup --cross-file aarch64.ini --cross-file cross.ini builddir`. + +Note that file composition happens before the parsing of values. The example +below results in `b` being `'HelloWorld'`: +```ini +# file1.ini: +[constants] +a = 'Foo' +b = a + 'World' +``` + +```ini +#file2.ini: +[constants] +a = 'Hello' +``` + +The example below results in an error when file1.ini is included before file2.ini +because `b` would be defined before `a`: +```ini +# file1.ini: +[constants] +b = a + 'World' +``` + +```ini +#file2.ini: +[constants] +a = 'Hello' +``` + ### Binaries The binaries section contains a list of binaries. These can be used |