[PATCH 03/18] curl: convert to meson

Paolo Bonzini posted 22 patches 5 years, 1 month ago
Only 18 patches received!
[PATCH 03/18] curl: convert to meson
Posted by Paolo Bonzini 5 years, 1 month ago
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 configure                   | 31 ++++---------------------------
 contrib/elf2dmp/meson.build |  2 +-
 meson.build                 | 11 +++++++----
 meson_options.txt           |  2 ++
 4 files changed, 14 insertions(+), 32 deletions(-)

diff --git a/configure b/configure
index c0a3e1556b..71196b1fe7 100755
--- a/configure
+++ b/configure
@@ -307,7 +307,7 @@ for opt do
 done
 
 brlapi="auto"
-curl="$default_feature"
+curl="auto"
 iconv="auto"
 curses="auto"
 docs="auto"
@@ -1216,9 +1216,9 @@ for opt do
   ;;
   --enable-iconv) iconv="enabled"
   ;;
-  --disable-curl) curl="no"
+  --disable-curl) curl="disabled"
   ;;
-  --enable-curl) curl="yes"
+  --enable-curl) curl="enabled"
   ;;
   --disable-fdt) fdt="disabled"
   ;;
@@ -3425,25 +3425,6 @@ for drv in $audio_drv_list; do
     esac
 done
 
-##########################################
-# curl probe
-if test "$curl" != "no" ; then
-  cat > $TMPC << EOF
-#include <curl/curl.h>
-int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
-EOF
-  curl_cflags=$($pkg_config libcurl --cflags 2>/dev/null)
-  curl_libs=$($pkg_config libcurl --libs 2>/dev/null)
-  if compile_prog "$curl_cflags" "$curl_libs" ; then
-    curl=yes
-  else
-    if test "$curl" = "yes" ; then
-      feature_not_found "curl" "Install libcurl devel"
-    fi
-    curl=no
-  fi
-fi # test "$curl"
-
 ##########################################
 # glib support probe
 
@@ -6104,11 +6085,6 @@ fi
 if test "$bswap_h" = "yes" ; then
   echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
 fi
-if test "$curl" = "yes" ; then
-  echo "CONFIG_CURL=y" >> $config_host_mak
-  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
-  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
-fi
 if test "$gtk" = "yes" ; then
   echo "CONFIG_GTK=y" >> $config_host_mak
   echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
@@ -6943,6 +6919,7 @@ NINJA=$ninja $meson setup \
         -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
         -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f -Dvirtiofsd=$virtiofsd \
         -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
+        -Dcurl=$curl \
         -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
         -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
         -Dvhost_user_blk_server=$vhost_user_blk_server \
diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
index b3de173316..4d86cb390a 100644
--- a/contrib/elf2dmp/meson.build
+++ b/contrib/elf2dmp/meson.build
@@ -1,4 +1,4 @@
-if 'CONFIG_CURL' in config_host
+if curl.found()
   executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c', 'pdb.c', 'qemu_elf.c'),
              dependencies: [glib, curl],
              install: true)
diff --git a/meson.build b/meson.build
index 70f81121d7..83dbc61acd 100644
--- a/meson.build
+++ b/meson.build
@@ -392,9 +392,11 @@ if 'CONFIG_VIRGL' in config_host
                              link_args: config_host['VIRGL_LIBS'].split())
 endif
 curl = not_found
-if 'CONFIG_CURL' in config_host
-  curl = declare_dependency(compile_args: config_host['CURL_CFLAGS'].split(),
-                            link_args: config_host['CURL_LIBS'].split())
+if not get_option('curl').auto() or have_block
+  curl = dependency('libcurl', version: '>=7.29.0',
+                    method: 'pkg-config',
+                    required: get_option('curl'),
+                    static: enable_static)
 endif
 libudev = not_found
 if targetos == 'linux' and (have_system or have_tools)
@@ -872,6 +874,7 @@ config_host_data.set('CONFIG_COCOA', cocoa.found())
 config_host_data.set('CONFIG_LIBUDEV', libudev.found())
 config_host_data.set('CONFIG_MPATH', mpathpersist.found())
 config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
+config_host_data.set('CONFIG_CURL', curl.found())
 config_host_data.set('CONFIG_CURSES', curses.found())
 config_host_data.set('CONFIG_SDL', sdl.found())
 config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
@@ -2160,7 +2163,7 @@ summary_info += {'iconv support':     iconv.found()}
 summary_info += {'curses support':    curses.found()}
 # TODO: add back version
 summary_info += {'virgl support':     config_host.has_key('CONFIG_VIRGL')}
-summary_info += {'curl support':      config_host.has_key('CONFIG_CURL')}
+summary_info += {'curl support':      curl.found()}
 summary_info += {'mingw32 support':   targetos == 'windows'}
 summary_info += {'Audio drivers':     config_host['CONFIG_AUDIO_DRIVERS']}
 summary_info += {'Block whitelist (rw)': config_host['CONFIG_BDRV_RW_WHITELIST']}
diff --git a/meson_options.txt b/meson_options.txt
index 62efe96a91..2b845ac62b 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -44,6 +44,8 @@ option('brlapi', type : 'feature', value : 'auto',
        description: 'brlapi character device driver')
 option('cocoa', type : 'feature', value : 'auto',
        description: 'Cocoa user interface (macOS only)')
+option('curl', type : 'feature', value : 'auto',
+       description: 'CURL block device driver')
 option('mpath', type : 'feature', value : 'auto',
        description: 'Multipath persistent reservation passthrough')
 option('iconv', type : 'feature', value : 'auto',
-- 
2.29.2



Re: [PATCH 03/18] curl: convert to meson
Posted by Daniel P. Berrangé 5 years, 1 month ago
On Thu, Dec 17, 2020 at 10:40:29AM +0100, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  configure                   | 31 ++++---------------------------
>  contrib/elf2dmp/meson.build |  2 +-
>  meson.build                 | 11 +++++++----
>  meson_options.txt           |  2 ++
>  4 files changed, 14 insertions(+), 32 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Re: [PATCH 03/18] curl: convert to meson
Posted by Marc-André Lureau 5 years, 1 month ago
Hi

On Thu, Dec 17, 2020 at 1:40 PM Paolo Bonzini <pbonzini@redhat.com> wrote:

> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>
---
>  configure                   | 31 ++++---------------------------
>  contrib/elf2dmp/meson.build |  2 +-
>  meson.build                 | 11 +++++++----
>  meson_options.txt           |  2 ++
>  4 files changed, 14 insertions(+), 32 deletions(-)
>
> diff --git a/configure b/configure
> index c0a3e1556b..71196b1fe7 100755
> --- a/configure
> +++ b/configure
> @@ -307,7 +307,7 @@ for opt do
>  done
>
>  brlapi="auto"
> -curl="$default_feature"
> +curl="auto"
>

What about default_feature=no ?

 iconv="auto"
>  curses="auto"
>  docs="auto"
> @@ -1216,9 +1216,9 @@ for opt do
>    ;;
>    --enable-iconv) iconv="enabled"
>    ;;
> -  --disable-curl) curl="no"
> +  --disable-curl) curl="disabled"
>    ;;
> -  --enable-curl) curl="yes"
> +  --enable-curl) curl="enabled"
>    ;;
>    --disable-fdt) fdt="disabled"
>    ;;
> @@ -3425,25 +3425,6 @@ for drv in $audio_drv_list; do
>      esac
>  done
>
> -##########################################
> -# curl probe
> -if test "$curl" != "no" ; then
> -  cat > $TMPC << EOF
> -#include <curl/curl.h>
> -int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0; }
> -EOF
> -  curl_cflags=$($pkg_config libcurl --cflags 2>/dev/null)
> -  curl_libs=$($pkg_config libcurl --libs 2>/dev/null)
> -  if compile_prog "$curl_cflags" "$curl_libs" ; then
> -    curl=yes
> -  else
> -    if test "$curl" = "yes" ; then
> -      feature_not_found "curl" "Install libcurl devel"
> -    fi
> -    curl=no
> -  fi
> -fi # test "$curl"
> -
>  ##########################################
>  # glib support probe
>
> @@ -6104,11 +6085,6 @@ fi
>  if test "$bswap_h" = "yes" ; then
>    echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
>  fi
> -if test "$curl" = "yes" ; then
> -  echo "CONFIG_CURL=y" >> $config_host_mak
> -  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
> -  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
> -fi
>  if test "$gtk" = "yes" ; then
>    echo "CONFIG_GTK=y" >> $config_host_mak
>    echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
> @@ -6943,6 +6919,7 @@ NINJA=$ninja $meson setup \
>          -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg
> -Dvnc_png=$vnc_png \
>          -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f
> -Dvirtiofsd=$virtiofsd \
>          -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
> +        -Dcurl=$curl \
>          -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
>          -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs \
>          -Dvhost_user_blk_server=$vhost_user_blk_server \
> diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
> index b3de173316..4d86cb390a 100644
> --- a/contrib/elf2dmp/meson.build
> +++ b/contrib/elf2dmp/meson.build
> @@ -1,4 +1,4 @@
> -if 'CONFIG_CURL' in config_host
> +if curl.found()
>    executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c',
> 'pdb.c', 'qemu_elf.c'),
>               dependencies: [glib, curl],
>               install: true)
> diff --git a/meson.build b/meson.build
> index 70f81121d7..83dbc61acd 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -392,9 +392,11 @@ if 'CONFIG_VIRGL' in config_host
>                               link_args: config_host['VIRGL_LIBS'].split())
>  endif
>  curl = not_found
> -if 'CONFIG_CURL' in config_host
> -  curl = declare_dependency(compile_args:
> config_host['CURL_CFLAGS'].split(),
> -                            link_args: config_host['CURL_LIBS'].split())
> +if not get_option('curl').auto() or have_block
> +  curl = dependency('libcurl', version: '>=7.29.0',
> +                    method: 'pkg-config',
> +                    required: get_option('curl'),
> +                    static: enable_static)
>  endif
>  libudev = not_found
>  if targetos == 'linux' and (have_system or have_tools)
> @@ -872,6 +874,7 @@ config_host_data.set('CONFIG_COCOA', cocoa.found())
>  config_host_data.set('CONFIG_LIBUDEV', libudev.found())
>  config_host_data.set('CONFIG_MPATH', mpathpersist.found())
>  config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
> +config_host_data.set('CONFIG_CURL', curl.found())
>  config_host_data.set('CONFIG_CURSES', curses.found())
>  config_host_data.set('CONFIG_SDL', sdl.found())
>  config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
> @@ -2160,7 +2163,7 @@ summary_info += {'iconv support':     iconv.found()}
>  summary_info += {'curses support':    curses.found()}
>  # TODO: add back version
>  summary_info += {'virgl support':     config_host.has_key('CONFIG_VIRGL')}
> -summary_info += {'curl support':      config_host.has_key('CONFIG_CURL')}
> +summary_info += {'curl support':      curl.found()}
>  summary_info += {'mingw32 support':   targetos == 'windows'}
>  summary_info += {'Audio drivers':     config_host['CONFIG_AUDIO_DRIVERS']}
>  summary_info += {'Block whitelist (rw)':
> config_host['CONFIG_BDRV_RW_WHITELIST']}
> diff --git a/meson_options.txt b/meson_options.txt
> index 62efe96a91..2b845ac62b 100644
> --- a/meson_options.txt
> +++ b/meson_options.txt
> @@ -44,6 +44,8 @@ option('brlapi', type : 'feature', value : 'auto',
>         description: 'brlapi character device driver')
>  option('cocoa', type : 'feature', value : 'auto',
>         description: 'Cocoa user interface (macOS only)')
> +option('curl', type : 'feature', value : 'auto',
> +       description: 'CURL block device driver')
>  option('mpath', type : 'feature', value : 'auto',
>         description: 'Multipath persistent reservation passthrough')
>  option('iconv', type : 'feature', value : 'auto',
> --
> 2.29.2
>
>
>
Re: [PATCH 03/18] curl: convert to meson
Posted by Marc-André Lureau 5 years, 1 month ago
On Thu, Dec 17, 2020 at 3:59 PM Marc-André Lureau <
marcandre.lureau@redhat.com> wrote:

> Hi
>
> On Thu, Dec 17, 2020 at 1:40 PM Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>>
> ---
>>  configure                   | 31 ++++---------------------------
>>  contrib/elf2dmp/meson.build |  2 +-
>>  meson.build                 | 11 +++++++----
>>  meson_options.txt           |  2 ++
>>  4 files changed, 14 insertions(+), 32 deletions(-)
>>
>> diff --git a/configure b/configure
>> index c0a3e1556b..71196b1fe7 100755
>> --- a/configure
>> +++ b/configure
>> @@ -307,7 +307,7 @@ for opt do
>>  done
>>
>>  brlapi="auto"
>> -curl="$default_feature"
>> +curl="auto"
>>
>
> What about default_feature=no ?
>

Oh got it:
        $(if test "$default_features" = no; then echo
"-Dauto_features=disabled"; fi) \

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>


>  iconv="auto"
>>  curses="auto"
>>  docs="auto"
>> @@ -1216,9 +1216,9 @@ for opt do
>>    ;;
>>    --enable-iconv) iconv="enabled"
>>    ;;
>> -  --disable-curl) curl="no"
>> +  --disable-curl) curl="disabled"
>>    ;;
>> -  --enable-curl) curl="yes"
>> +  --enable-curl) curl="enabled"
>>    ;;
>>    --disable-fdt) fdt="disabled"
>>    ;;
>> @@ -3425,25 +3425,6 @@ for drv in $audio_drv_list; do
>>      esac
>>  done
>>
>> -##########################################
>> -# curl probe
>> -if test "$curl" != "no" ; then
>> -  cat > $TMPC << EOF
>> -#include <curl/curl.h>
>> -int main(void) { curl_easy_init(); curl_multi_setopt(0, 0, 0); return 0;
>> }
>> -EOF
>> -  curl_cflags=$($pkg_config libcurl --cflags 2>/dev/null)
>> -  curl_libs=$($pkg_config libcurl --libs 2>/dev/null)
>> -  if compile_prog "$curl_cflags" "$curl_libs" ; then
>> -    curl=yes
>> -  else
>> -    if test "$curl" = "yes" ; then
>> -      feature_not_found "curl" "Install libcurl devel"
>> -    fi
>> -    curl=no
>> -  fi
>> -fi # test "$curl"
>> -
>>  ##########################################
>>  # glib support probe
>>
>> @@ -6104,11 +6085,6 @@ fi
>>  if test "$bswap_h" = "yes" ; then
>>    echo "CONFIG_MACHINE_BSWAP_H=y" >> $config_host_mak
>>  fi
>> -if test "$curl" = "yes" ; then
>> -  echo "CONFIG_CURL=y" >> $config_host_mak
>> -  echo "CURL_CFLAGS=$curl_cflags" >> $config_host_mak
>> -  echo "CURL_LIBS=$curl_libs" >> $config_host_mak
>> -fi
>>  if test "$gtk" = "yes" ; then
>>    echo "CONFIG_GTK=y" >> $config_host_mak
>>    echo "GTK_CFLAGS=$gtk_cflags" >> $config_host_mak
>> @@ -6943,6 +6919,7 @@ NINJA=$ninja $meson setup \
>>          -Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg
>> -Dvnc_png=$vnc_png \
>>          -Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f
>> -Dvirtiofsd=$virtiofsd \
>>          -Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt -Dbrlapi=$brlapi \
>> +        -Dcurl=$curl \
>>          -Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
>>          -Ddocs=$docs -Dsphinx_build=$sphinx_build -Dinstall_blobs=$blobs
>> \
>>          -Dvhost_user_blk_server=$vhost_user_blk_server \
>> diff --git a/contrib/elf2dmp/meson.build b/contrib/elf2dmp/meson.build
>> index b3de173316..4d86cb390a 100644
>> --- a/contrib/elf2dmp/meson.build
>> +++ b/contrib/elf2dmp/meson.build
>> @@ -1,4 +1,4 @@
>> -if 'CONFIG_CURL' in config_host
>> +if curl.found()
>>    executable('elf2dmp', files('main.c', 'addrspace.c', 'download.c',
>> 'pdb.c', 'qemu_elf.c'),
>>               dependencies: [glib, curl],
>>               install: true)
>> diff --git a/meson.build b/meson.build
>> index 70f81121d7..83dbc61acd 100644
>> --- a/meson.build
>> +++ b/meson.build
>> @@ -392,9 +392,11 @@ if 'CONFIG_VIRGL' in config_host
>>                               link_args:
>> config_host['VIRGL_LIBS'].split())
>>  endif
>>  curl = not_found
>> -if 'CONFIG_CURL' in config_host
>> -  curl = declare_dependency(compile_args:
>> config_host['CURL_CFLAGS'].split(),
>> -                            link_args: config_host['CURL_LIBS'].split())
>> +if not get_option('curl').auto() or have_block
>> +  curl = dependency('libcurl', version: '>=7.29.0',
>> +                    method: 'pkg-config',
>> +                    required: get_option('curl'),
>> +                    static: enable_static)
>>  endif
>>  libudev = not_found
>>  if targetos == 'linux' and (have_system or have_tools)
>> @@ -872,6 +874,7 @@ config_host_data.set('CONFIG_COCOA', cocoa.found())
>>  config_host_data.set('CONFIG_LIBUDEV', libudev.found())
>>  config_host_data.set('CONFIG_MPATH', mpathpersist.found())
>>  config_host_data.set('CONFIG_MPATH_NEW_API', mpathpersist_new_api)
>> +config_host_data.set('CONFIG_CURL', curl.found())
>>  config_host_data.set('CONFIG_CURSES', curses.found())
>>  config_host_data.set('CONFIG_SDL', sdl.found())
>>  config_host_data.set('CONFIG_SDL_IMAGE', sdl_image.found())
>> @@ -2160,7 +2163,7 @@ summary_info += {'iconv support':     iconv.found()}
>>  summary_info += {'curses support':    curses.found()}
>>  # TODO: add back version
>>  summary_info += {'virgl support':
>>  config_host.has_key('CONFIG_VIRGL')}
>> -summary_info += {'curl support':      config_host.has_key('CONFIG_CURL')}
>> +summary_info += {'curl support':      curl.found()}
>>  summary_info += {'mingw32 support':   targetos == 'windows'}
>>  summary_info += {'Audio drivers':
>>  config_host['CONFIG_AUDIO_DRIVERS']}
>>  summary_info += {'Block whitelist (rw)':
>> config_host['CONFIG_BDRV_RW_WHITELIST']}
>> diff --git a/meson_options.txt b/meson_options.txt
>> index 62efe96a91..2b845ac62b 100644
>> --- a/meson_options.txt
>> +++ b/meson_options.txt
>> @@ -44,6 +44,8 @@ option('brlapi', type : 'feature', value : 'auto',
>>         description: 'brlapi character device driver')
>>  option('cocoa', type : 'feature', value : 'auto',
>>         description: 'Cocoa user interface (macOS only)')
>> +option('curl', type : 'feature', value : 'auto',
>> +       description: 'CURL block device driver')
>>  option('mpath', type : 'feature', value : 'auto',
>>         description: 'Multipath persistent reservation passthrough')
>>  option('iconv', type : 'feature', value : 'auto',
>> --
>> 2.29.2
>>
>>
>>
Re: [PATCH 03/18] curl: convert to meson
Posted by Paolo Bonzini 5 years, 1 month ago
On 17/12/20 13:00, Marc-André Lureau wrote:
> 
>         -curl="$default_feature"
>         +curl="auto"
> 
> 
>     What about default_feature=no ?
> 
> 
> Oh got it:
>          $(if test "$default_features" = no; then echo 
> "-Dauto_features=disabled"; fi) \

Yeah, Meson has that feature natively.  The plan is to:

1) remove xxx="$default_features" altogether by moving all options to meson

2) possibly remove xxx="auto" by resurrecting the introspection-based 
command line option parsing script.

Paolo