From 4a014d17240f50059e20ccae3e9faaa395bdbf98 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 14 Dec 2022 10:59:36 -0800 Subject: Add support for meson.options as a replacement for meson_options.txt We will still try to load `meson_options.txt` if `meson.options` doesn't exist. Because there are some advantages to using `meson.options` even with older versions of meson (such as better text editor handling) we will not warn about the existence of a `meson.options` file if a `meson_options.txt` file or symlink also exists. The name `meson.options` was picked instead of alternative proposals, such as `meson_options.build` for a couple of reasons: 1. meson.options is shorter 2. While the syntax is the same, only the `option()` function may be called in meson.options, while, it may not be called in meson.build 3. While the two files share a syntax and elementary types (strings, arrays, etc), they have different purposes: `meson.build` declares build targets, `meson.options` declares options. This is similar to the difference between C's `.c` and `.h` extensions. As an implementation detail `Interpreter.option_file` has been removed, as it is used exactly once, in the `project()` call to read the options, and we can just calculate it there and not store it. Fixes: #11176 --- docs/markdown/snippets/meson_options.md | 7 +++++++ docs/yaml/functions/dependency.yaml | 2 +- docs/yaml/functions/subproject.yaml | 4 ++-- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 docs/markdown/snippets/meson_options.md (limited to 'docs') diff --git a/docs/markdown/snippets/meson_options.md b/docs/markdown/snippets/meson_options.md new file mode 100644 index 000000000..f9d582ac9 --- /dev/null +++ b/docs/markdown/snippets/meson_options.md @@ -0,0 +1,7 @@ +## Support for reading options from meson.options + +Support has been added for reading options from `meson.options` instead of +`meson_options.txt`. These are equivalent, but not using the `.txt` extension +for a build file has a few advantages, chief among them many tools and text +editors expect a file with the `.txt` extension to be plain text files, not +build scripts. diff --git a/docs/yaml/functions/dependency.yaml b/docs/yaml/functions/dependency.yaml index 2d9e36656..85255b9f1 100644 --- a/docs/yaml/functions/dependency.yaml +++ b/docs/yaml/functions/dependency.yaml @@ -82,7 +82,7 @@ kwargs: since: 0.38.0 description: | An array of default option values - that override those set in the subproject's `meson_options.txt` + that override those set in the subproject's `meson.options` (like `default_options` in [[project]], they only have effect when Meson is run for the first time, and command line arguments override any default options in build files) diff --git a/docs/yaml/functions/subproject.yaml b/docs/yaml/functions/subproject.yaml index 4d19a3178..14a778dd8 100644 --- a/docs/yaml/functions/subproject.yaml +++ b/docs/yaml/functions/subproject.yaml @@ -9,7 +9,7 @@ description: | `${MESON_SOURCE_ROOT}/subprojects/foo`. - `default_options` *(since 0.37.0)*: an array of default option values - that override those set in the subproject's `meson_options.txt` + that override those set in the subproject's `meson.options` (like `default_options` in `project`, they only have effect when Meson is run for the first time, and command line arguments override any default options in build files). *(since 0.54.0)*: `default_library` @@ -45,7 +45,7 @@ kwargs: since: 0.37.0 description: | An array of default option values - that override those set in the subproject's `meson_options.txt` + that override those set in the subproject's `meson.options` (like `default_options` in [[project]], they only have effect when Meson is run for the first time, and command line arguments override any default options in build files). *(since 0.54.0)*: `default_library` -- cgit v1.2.3