From 12a82e763d43f6280572b3f04357f77e50304855 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Sun, 26 May 2019 15:13:21 +0200 Subject: interpreter: add fallback argument to subproject.get_variable() --- docs/markdown/Reference-manual.md | 6 +++++- .../add_fallback_argument_to_subproject_get_variable.md | 13 +++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 docs/markdown/snippets/add_fallback_argument_to_subproject_get_variable.md (limited to 'docs/markdown') diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 9484c28..f59d627 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -2288,10 +2288,14 @@ opaque object representing it. - `found()` *(added 0.48.0)* which returns whether the subproject was successfully setup -- `get_variable(name)` fetches the specified variable from inside the +- `get_variable(name, fallback)` fetches the specified variable from inside the subproject. This is useful to, for instance, get a [declared dependency](#declare_dependency) from the [subproject](Subprojects.md). + If the variable does not exist, the variable `fallback` is returned. + If a fallback is not specified, then attempting to read a non-existing + variable will cause a fatal error. + ### `run result` object This object encapsulates the result of trying to compile and run a diff --git a/docs/markdown/snippets/add_fallback_argument_to_subproject_get_variable.md b/docs/markdown/snippets/add_fallback_argument_to_subproject_get_variable.md new file mode 100644 index 0000000..24dafa0 --- /dev/null +++ b/docs/markdown/snippets/add_fallback_argument_to_subproject_get_variable.md @@ -0,0 +1,13 @@ +--- +short-description: Add fallback argument to subproject.get_variable() +... + +## subproject.get_variable() now accepts a `fallback` argument + +Similar to `get_variable`, a fallback argument can now be passed to +`subproject.get_variable()`, it will be returned if the requested +variable name did not exist. + +``` meson +var = subproject.get_variable('does-not-exist', 'fallback-value') +``` -- cgit v1.1