diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2021-02-22 17:19:48 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2021-05-31 16:01:57 +0200 |
commit | 08a8043f1916cb2a337b93b6b6d600df9af6ecb7 (patch) | |
tree | 755610159fe1fb03430842492db81cbf6dbd38c2 /docs | |
parent | 6aef800ba83a4dd469c354900b6e537777d3080c (diff) | |
download | meson-08a8043f1916cb2a337b93b6b6d600df9af6ecb7.zip meson-08a8043f1916cb2a337b93b6b6d600df9af6ecb7.tar.gz meson-08a8043f1916cb2a337b93b6b6d600df9af6ecb7.tar.bz2 |
interpreter: add feature.allowed()
This method simplifies the conversion of Feature objects to booleans.
Often, one has to use the "not" operator in order to treat "auto"
and "enabled" the same way.
"allowed()" also works well in conjunction with the require method that
is introduced in the next patch. For example,
if get_option('foo').require(host_machine.system() == 'windows').allowed() then
src += ['foo.c']
config.set10('HAVE_FOO', 1)
endif
can be used instead of
if host_machine.system() != 'windows'
if get_option('foo').enabled()
error('...')
endif
endif
if not get_option('foo').disabled() then
src += ['foo.c']
config.set10('HAVE_FOO', 1)
endif
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/markdown/Reference-manual.md | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index 103f4d8..f6b3fc2 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -2818,6 +2818,7 @@ The following methods are defined for all [`feature` options](Build-options.md#f - `enabled()`: returns whether the feature was set to `'enabled'` - `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'` ### `generator` object |