meson: Use feature.require() and feature.allowed()
authorDylan Baker <dylan@pnwbakers.com>
Fri, 1 Sep 2023 19:23:35 +0000 (12:23 -0700)
committerSimon Ser <contact@emersion.fr>
Fri, 20 Oct 2023 05:21:01 +0000 (05:21 +0000)
commit16e6a965051fae4d5142e9f16c47bb6bd3dd6f59
treea256dde05cfb7a96285b4927f313b1836208b63f
parenta6a2ccb4486306c3caa5ccd337d972b61b97f75a
meson: Use feature.require() and feature.allowed()

To reduce the size and complexity of checks. require() allows combining
auto and enabled checks(), so that something like
```meson
x = get_option('feature')
y = false
if x.enabled()
  if not condition
    error(...)
  endif
  y = condition
endif
```
can be rewritten as:
```meson
y = get_option('feature').require(condition, error_message : ...).allowed()
```
require checks the condition, then if the feature is required it emits
an error with the given message otherwise it returns a disabled feature.
allowed then returns whether the feature is not disabled, and returns
that (ie, .allowed() == not .disabled()). This is especially helpful for
longer more complex conditions

Signed-off-by: Dylan Baker <dylan.c.baker@intel.com>
.gitlab-ci.yml
meson.build