aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2021-05-16 17:54:43 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2021-06-08 10:18:12 +0200
commita87e32d1817ba750b054774e589b595135fb9145 (patch)
tree2118719c756142508f3b5f84cd59dbc6d6aa8f3c /docs
parent2f2d99e1d88c9f14fa139d450cb6f55173d73c9a (diff)
downloadmeson-a87e32d1817ba750b054774e589b595135fb9145.zip
meson-a87e32d1817ba750b054774e589b595135fb9145.tar.gz
meson-a87e32d1817ba750b054774e589b595135fb9145.tar.bz2
interpreter: add feature.disable_auto_if()
Add a method to downgrade an option to disabled if it is not used. This is useful to avoid unnecessary search for dependencies; for example dep = dependency('dep', required: get_option('feature').disable_auto_if(not foo)) can be used instead of the more verbose and complex if get_option('feature').auto() and not foo then dep = dependency('', required: false) else dep = dependency('dep', required: get_option('feature')) endif or to avoid unnecessary dependency searches: dep1 = dependency('dep1', required: get_option('foo')) # dep2 is only used together with dep1 dep2 = dependency('dep2', required: get_option('foo').disable_auto_if(not dep1.found())) ``` Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs')
-rw-r--r--docs/markdown/Reference-manual.md9
1 files changed, 9 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md
index 12ddfce..111a6f0 100644
--- a/docs/markdown/Reference-manual.md
+++ b/docs/markdown/Reference-manual.md
@@ -2819,6 +2819,15 @@ The following methods are defined for all [`feature` options](Build-options.md#f
- `disabled()`: returns whether the feature was set to `'disabled'`
- `auto()`: returns whether the feature was set to `'auto'`
- `allowed()` *(since 0.59.0)*: returns whether the feature was set to `'enabled'` or `'auto'`
+- `disable_auto_if(value)` *(since 0.59.0)*: returns the feature, with
+ `'auto'` converted to `'disabled'` if value is true.
+
+ | Feature / Condition | True | False |
+ | ------------------- | ---- | ----- |
+ | Enabled | Enabled | Enabled |
+ | Disabled | Disabled | Disabled |
+ | Auto | Disabled | Auto |
+
- `require(value, error_message: '')` *(since 0.59.0)*: returns
the object itself if the value is true; an error if the object is
`'enabled'` and the value is false; a disabled feature if the object