qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2 1/5] configure: Add the possibility to read options from m


From: Eric Blake
Subject: Re: [PATCH v2 1/5] configure: Add the possibility to read options from meson_options.txt
Date: Fri, 3 Sep 2021 12:09:56 -0500
User-agent: NeoMutt/20210205-739-420e15

On Fri, Sep 03, 2021 at 10:13:54AM +0200, Thomas Huth wrote:
> To avoid double maintenance between the configure script and
> meson_options.txt, add some simple logic in the configure script
> to read the options from meson_options.txt.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure | 24 +++++++++++++++++++++++-
>  1 file changed, 23 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 9a79a004d7..528e9c80c5 100755
> --- a/configure
> +++ b/configure
> @@ -836,6 +836,8 @@ fi
>  
>  werror=""
>  
> +meson_options=""
> +
>  for opt do
>    optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
>    case "$opt" in
> @@ -1581,6 +1583,26 @@ for opt do
>    ;;
>    --disable-slirp-smbd) slirp_smbd=no
>    ;;
> +  --enable-*)
> +      arg=$(printf %s\\n "$opt" | sed -e "s/--enable-//" -e "s/-/_/g")

Sorry for not pointing this out earlier, but if an annoying user
passes:

./configure --'enable-my bad opt'

this results in $arg being set to 'my bad opt'...

> +      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
> +                $source_path/meson_options.txt; then
> +          printf "ERROR: unknown option %s\n" "$opt"
> +          printf "Try '%s --help' for more information\n" "$0"
> +          exit 1
> +      fi
> +      meson_options="$meson_options -D$arg=enabled"

...and that breaks $meson_options.  Other odd arguments, such as
"--enable-my.*arg" could mess with the grep above.  I don't know if we
care about users that go to such lengths to shoot themselves in the
foot, so it's probably not worth trying to guarantee that $opt
consists only of [a-zA-Z0-9_-].

> +  ;;
> +  --disable-*)
> +      arg=$(printf %s\\n "$opt" | sed -e "s/--disable-//" -e "s/-/_/g")

Whatever we decide above, we should repeat here (including the
decision to leave as-is).

> +      if ! grep -q "option('$arg', type[ ]*: 'feature'" \
> +                $source_path/meson_options.txt; then
> +          printf "ERROR: unknown option %s\n" "$opt"
> +          printf "Try '%s --help' for more information\n" "$0"
> +          exit 1
> +      fi
> +      meson_options="$meson_options -D$arg=disabled"
> +  ;;
>    *)
>        echo "ERROR: unknown option $opt"
>        echo "Try '$0 --help' for more information"
> @@ -5211,7 +5233,7 @@ if test "$skip_meson" = no; then
>          -Dvhost_user_blk_server=$vhost_user_blk_server 
> -Dmultiprocess=$multiprocess \
>          -Dfuse=$fuse -Dfuse_lseek=$fuse_lseek 
> -Dguest_agent_msi=$guest_agent_msi -Dbpf=$bpf\
>          $(if test "$default_feature" = no; then echo 
> "-Dauto_features=disabled"; fi) \
> -     -Dtcg_interpreter=$tcg_interpreter \
> +        -Dtcg_interpreter=$tcg_interpreter $meson_options \
>          $cross_arg \
>          "$PWD" "$source_path"

Unless we thing super-robustness is mandatory, I'm okay with:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




reply via email to

[Prev in Thread] Current Thread [Next in Thread]