diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2020-10-08 12:05:51 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-10-08 12:24:07 +0200 |
commit | 726b82205492a9e1f2dfd0fba96b237b51eeb428 (patch) | |
tree | df49508fe8547d69b232e90fa2cf6fc17dcc8b2b /docs/markdown/Reference-manual.md | |
parent | 1eec5cf41f905c988af4be003a03d29fca7baef4 (diff) | |
download | meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.zip meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.gz meson-726b82205492a9e1f2dfd0fba96b237b51eeb428.tar.bz2 |
dependency: support boolean argument "allow_fallback"
Sometimes, distros want to configure a project so that it does not
use any bundled library. In this case, meson.build might want
to do something like this, where slirp is a combo option
with values auto/system/internal:
slirp = dependency('', required: false)
if get_option('slirp') != 'internal'
slirp = dependency('slirp',
required: get_option('slirp') == 'system')
endif
if not slirp.found()
slirp = subproject('libslirp', ...) .variable('...')
endif
and we cannot use "fallback" because the "system" value should never
look for a subproject.
This worked until 0.54.x, but in 0.55.x this breaks because of the
automatic subproject search. Note that the desired effect here is
backwards compared to the policy of doing an automatic search on
"required: true"; we only want to do the search if "required" is false!
It would be possible to look for the dependency with `required: false`
and issue the error manually, but it's ugly and it may produce an error
message that looks "different" from Meson's.
Instead, with this change it is possible to achieve this effect in an
even simpler way:
slirp = dependency('slirp',
required: get_option('slirp') != 'auto',
allow_fallback: get_option('slirp') == 'system' ? false : ['slirp', 'libslirp_dep'])
The patch also adds support for "allow_fallback: true", which is
simple and enables automatic fallback to a wrap even for non-required
dependencies.
Diffstat (limited to 'docs/markdown/Reference-manual.md')
-rw-r--r-- | docs/markdown/Reference-manual.md | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/docs/markdown/Reference-manual.md b/docs/markdown/Reference-manual.md index b6ca743..38ae558 100644 --- a/docs/markdown/Reference-manual.md +++ b/docs/markdown/Reference-manual.md @@ -454,15 +454,15 @@ Dependencies can also be resolved in two other ways: * by a fallback subproject which, if needed, will be brought into the current build specification as if [`subproject()`](#subproject) had been called. The subproject can be specified with the `fallback` argument. Alternatively, - if the `fallback` argument is absent and `required` is `true` or - [`enabled`](Build-options.md#features), *since 0.55.0* Meson will + if the `fallback` argument is absent, *since 0.55.0* Meson can automatically identify a subproject as a fallback if a wrap file [provides](Wrap-dependency-system-manual.md#provide-section) the dependency, or if a subproject has the same name as the dependency. In the latter case, the subproject must use `meson.override_dependency` to specify the replacement, or Meson will report a hard error. See the [Wrap documentation](Wrap-dependency-system-manual.md#provide-section) - for more details. + for more details. This automatic search can be controlled using the + `allow_fallback` keyword argument. This function supports the following keyword arguments: @@ -471,7 +471,16 @@ This function supports the following keyword arguments: (like `default_options` in [`project()`](#project), they only have effect when Meson is run for the first time, and command line arguments override any default options in build files) -- `fallback`: manually specifies a subproject +- `allow_fallback` (boolean argument, *since 0.56.0*): specifies whether Meson + should automatically pick a fallback subproject in case the dependency + is not found in the system. If `true` and the dependency is not found + on the system, Meson will fallback to a subproject that provides this + dependency. If `false`, Meson will not fallback even if a subproject + provides this dependency. By default, Meson will do so if `required` + is `true` or [`enabled`](Build-options.md#features); see the [Wrap + documentation](Wrap-dependency-system-manual.md#provide-section) + for more details. +- `fallback` (string or array argument): manually specifies a subproject fallback to use in case the dependency is not found in the system. This is useful if the automatic search is not applicable or if you want to support versions of Meson older than 0.55.0. If the value is an |