diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-05-16 17:53:48 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-06-08 10:18:12 +0200 |
commit | 2f2d99e1d88c9f14fa139d450cb6f55173d73c9a (patch) | |
tree | e7be9760bda87b34f15b4eb0e31ba3ea08226fc3 /docs | |
parent | 5298d8eaf18a97c3e0bd68ea1d44b7fee21c3c81 (diff) | |
download | meson-2f2d99e1d88c9f14fa139d450cb6f55173d73c9a.zip meson-2f2d99e1d88c9f14fa139d450cb6f55173d73c9a.tar.gz meson-2f2d99e1d88c9f14fa139d450cb6f55173d73c9a.tar.bz2 |
interpreter: add feature.require()
Add a method to perform a logical AND on a feature object. The method
also takes care of raising an error if 'enabled' is ANDed with false.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/markdown/Reference-manual.md | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index f6b3fc2..12ddfce 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -2819,6 +2819,21 @@ 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'` +- `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 + is `'auto'` or `'disabled'` and the value is false. + +`require` is useful to restrict the applicability of `'auto'` features, +for example based on other features or on properties of the host machine: + +``` +if get_option('directx').require(host_machine.system() == 'windows', + error_message: 'DirectX only available on Windows').allowed() then + src += ['directx.c'] + config.set10('HAVE_DIRECTX', 1) +endif +``` ### `generator` object |