[Spice-devel] [spice-common] meson: Support auto/true/false for optional dependencies
Frediano Ziglio
fziglio at redhat.com
Wed Jun 6 10:52:18 UTC 2018
>
> At the moment, missing optional dependencies will be silently ignored
> when the corresponding configuration flag is 'true', and won't be tested
> for when the flag is 'false'.
> In the autotools build, this corresponds respectively to
> --enable-foo=auto and --disable-foo.
> Having a way to get an error when the package is enabled but missing is
> quite desirable. f52247384 has some half-baked attempt at that, but this
> was supposed to be removed from the series. This causes errors when
> processing meson.build, breaking the meson build.
> This commit adds 'true'/'false'/'auto' in a proper way.
> ---
> "meson: Remove '(default: xxx)' from option description" which I sent
> earlier needs to be applied before that patch. I can rebase on top of
> master if that's better for review.
>
I would prefer to have this patch in before
"meson: Remove '(default: xxx)' from option description" as this patch
is also fixing Meson build. Acking it would be meaning ack without
a base test.
> meson.build | 23 ++++++++++-------------
> meson_options.txt | 10 ++++++----
> 2 files changed, 16 insertions(+), 17 deletions(-)
>
> diff --git a/meson.build b/meson.build
> index 4386c83..cb8a1ee 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -115,22 +115,19 @@ endforeach
> #
> # Check deps which are optional but enabled by default. This foreach block
> only
> # checks the option, and adds the package to the deps list, while the real
> check
> -# for the dependency is done in the foeach block below.
> +# for the dependency is done in the foreach block below.
> optional_deps = [
> - ['celt051', '>= 0.5.1.1', false, 'HAVE_CELT051'],
> - ['opus', '>= 0.9.14', true, 'HAVE_OPUS'],
> + ['celt051', '>= 0.5.1.1', 'HAVE_CELT051'],
> + ['opus', '>= 0.9.14', 'HAVE_OPUS'],
> ]
> foreach dep : optional_deps
> - if get_option(dep[0])
> - deps += [dep]
> - endif
> -endforeach
> -
> -foreach dep : deps
> - d = dependency(dep[0], required : dep[2], version : dep[1])
> - if d.found()
> - spice_common_deps += d
> - spice_common_config_data.set(dep[3], '1')
> + option_value = get_option(dep[0])
> + if option_value != 'false'
> + d = dependency(dep[0], required: (option_value == 'true'), version :
> dep[1])
> + if d.found()
> + spice_common_deps += d
> + spice_common_config_data.set(dep[2], '1')
> + endif
> endif
> endforeach
>
> diff --git a/meson_options.txt b/meson_options.txt
> index 84cc56d..ac9eefa 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -11,13 +11,15 @@ option('extra-checks',
> description : 'Enable extra checks on code')
>
> option('celt051',
> - type : 'boolean',
> - value : false,
> + type : 'combo',
> + choices : ['true', 'false', 'auto'],
> + value : 'auto',
> description: 'Enable celt051 audio codec')
>
> option('opus',
> - type : 'boolean',
> - value : true,
> + type : 'combo',
> + choices : ['true', 'false', 'auto'],
> + value : 'true',
> description: 'Enable Opus audio codec')
>
> option('python-checks',
Otherwise,
Acked-by: Frediano Ziglio <fziglio at redhat.com>
(tested applying it manually on master)
Frediano
More information about the Spice-devel
mailing list