qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Subject: [PATCH 11/34] meson, configure: move libgio test to meson
Date: Wed, 20 Apr 2022 17:33:44 +0200	[thread overview]
Message-ID: <20220420153407.73926-12-pbonzini@redhat.com> (raw)
In-Reply-To: <20220420153407.73926-1-pbonzini@redhat.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 backends/meson.build          |  2 +-
 configure                     | 58 -----------------------------------
 meson.build                   | 32 ++++++++++++++++---
 meson_options.txt             |  2 ++
 scripts/meson-buildoptions.sh |  3 ++
 tests/qtest/meson.build       |  5 ++-
 ui/meson.build                |  7 ++---
 util/meson.build              |  2 +-
 8 files changed, 39 insertions(+), 72 deletions(-)

diff --git a/backends/meson.build b/backends/meson.build
index 6e68945528..535c3ca7dd 100644
--- a/backends/meson.build
+++ b/backends/meson.build
@@ -15,7 +15,7 @@ softmmu_ss.add(when: 'CONFIG_LINUX', if_true: files('hostmem-memfd.c'))
 softmmu_ss.add(when: ['CONFIG_VHOST_USER', 'CONFIG_VIRTIO'], if_true: files('vhost-user.c'))
 softmmu_ss.add(when: 'CONFIG_VIRTIO_CRYPTO', if_true: files('cryptodev-vhost.c'))
 softmmu_ss.add(when: ['CONFIG_VIRTIO_CRYPTO', 'CONFIG_VHOST_CRYPTO'], if_true: files('cryptodev-vhost-user.c'))
-softmmu_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus-vmstate.c'), gio])
+softmmu_ss.add(when: gio, if_true: files('dbus-vmstate.c'))
 softmmu_ss.add(when: 'CONFIG_SGX', if_true: files('hostmem-epc.c'))
 
 subdir('tpm')
diff --git a/configure b/configure
index d4d7c001f6..75e8b1e7aa 100755
--- a/configure
+++ b/configure
@@ -325,7 +325,6 @@ plugins="$default_feature"
 meson=""
 meson_args=""
 ninja=""
-gio="$default_feature"
 skip_meson=no
 
 # The following Meson options are handled manually (still they
@@ -1008,10 +1007,6 @@ for opt do
   ;;
   --gdb=*) gdb_bin="$optarg"
   ;;
-  --enable-gio) gio=yes
-  ;;
-  --disable-gio) gio=no
-  ;;
   # backwards compatibility options
   --enable-trace-backend=*) meson_option_parse "--enable-trace-backends=$optarg" "$optarg"
   ;;
@@ -1236,7 +1231,6 @@ cat << EOF
   vhost-kernel    vhost kernel backend support
   vhost-user      vhost-user backend support
   vhost-vdpa      vhost-vdpa kernel backend support
-  gio             libgio support
 
 NOTE: The object files are built at the place where configure is launched
 EOF
@@ -2047,50 +2041,6 @@ if test "$static" = yes && test "$mingw32" = yes; then
     glib_cflags="-DGLIB_STATIC_COMPILATION $glib_cflags"
 fi
 
-if ! test "$gio" = "no"; then
-    pass=no
-    if $pkg_config --atleast-version=$glib_req_ver gio-2.0; then
-        gio_cflags=$($pkg_config --cflags gio-2.0)
-        gio_libs=$($pkg_config --libs gio-2.0)
-        gdbus_codegen=$($pkg_config --variable=gdbus_codegen gio-2.0)
-        if ! has "$gdbus_codegen"; then
-            gdbus_codegen=
-        fi
-        # Check that the libraries actually work -- Ubuntu 18.04 ships
-        # with pkg-config --static --libs data for gio-2.0 that is missing
-        # -lblkid and will give a link error.
-        cat > $TMPC <<EOF
-#include <gio/gio.h>
-int main(void)
-{
-    g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
-    return 0;
-}
-EOF
-        if compile_prog "$gio_cflags" "$gio_libs" ; then
-            pass=yes
-        else
-            pass=no
-        fi
-
-        if test "$pass" = "yes" &&
-            $pkg_config --atleast-version=$glib_req_ver gio-unix-2.0; then
-            gio_cflags="$gio_cflags $($pkg_config --cflags gio-unix-2.0)"
-            gio_libs="$gio_libs $($pkg_config --libs gio-unix-2.0)"
-        fi
-    fi
-
-    if test "$pass" = "no"; then
-        if test "$gio" = "yes"; then
-            feature_not_found "gio" "Install libgio >= 2.0"
-        else
-            gio=no
-        fi
-    else
-        gio=yes
-    fi
-fi
-
 # Sanity check that the current size_t matches the
 # size that glib thinks it should be. This catches
 # problems on multi-arch where people try to build
@@ -2616,14 +2566,6 @@ fi
 if test "$module_upgrades" = "yes"; then
   echo "CONFIG_MODULE_UPGRADES=y" >> $config_host_mak
 fi
-if test "$gio" = "yes" ; then
-    echo "CONFIG_GIO=y" >> $config_host_mak
-    echo "GIO_CFLAGS=$gio_cflags" >> $config_host_mak
-    echo "GIO_LIBS=$gio_libs" >> $config_host_mak
-fi
-if test "$gdbus_codegen" != "" ; then
-    echo "GDBUS_CODEGEN=$gdbus_codegen" >> $config_host_mak
-fi
 echo "CONFIG_TLS_PRIORITY=\"$tls_priority\"" >> $config_host_mak
 
 if test "$xen" = "enabled" ; then
diff --git a/meson.build b/meson.build
index c0b2838d2e..b8046efcf1 100644
--- a/meson.build
+++ b/meson.build
@@ -448,11 +448,32 @@ glib = declare_dependency(compile_args: config_host['GLIB_CFLAGS'].split(),
 meson.override_dependency('glib-2.0', glib)
 
 gio = not_found
-if 'CONFIG_GIO' in config_host
-  gio = declare_dependency(compile_args: config_host['GIO_CFLAGS'].split(),
-                           link_args: config_host['GIO_LIBS'].split(),
-                           version: config_host['GLIB_VERSION'])
+gdbus_codegen = not_found
+if not get_option('gio').auto() or have_system
+  gio = dependency('gio-2.0', required: get_option('gio'),
+                   method: 'pkg-config', kwargs: static_kwargs)
+  if gio.found() and not cc.links('''
+    #include <gio/gio.h>
+    int main(void)
+    {
+      g_dbus_proxy_new_sync(0, 0, 0, 0, 0, 0, 0, 0);
+      return 0;
+    }''', dependencies: [glib, gio])
+    if get_option('gio').enabled()
+      error('The installed libgio is broken for static linking')
+    endif
+    gio = not_found
+  endif
+  if gio.found()
+    gdbus_codegen = find_program(gio.get_variable('gdbus_codegen'),
+                                 required: get_option('gio'))
+    gio_unix = dependency('gio-unix-2.0', required: get_option('gio'),
+                          method: 'pkg-config', kwargs: static_kwargs)
+    gio = declare_dependency(dependencies: [gio, gio_unix],
+                             version: gio.version())
+  endif
 endif
+
 lttng = not_found
 if 'ust' in get_option('trace_backends')
   lttng = dependency('lttng-ust', required: true, version: '>= 2.1',
@@ -1478,7 +1499,7 @@ dbus_display = get_option('dbus_display') \
            error_message: '-display dbus requires glib>=2.64') \
   .require(enable_modules,
            error_message: '-display dbus requires --enable-modules') \
-  .require(config_host.has_key('GDBUS_CODEGEN'),
+  .require(gdbus_codegen.found(),
            error_message: '-display dbus requires gdbus-codegen') \
   .allowed()
 
@@ -1540,6 +1561,7 @@ 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_GBM', gbm.found())
+config_host_data.set('CONFIG_GIO', gio.found())
 config_host_data.set('CONFIG_GLUSTERFS', glusterfs.found())
 if glusterfs.found()
   config_host_data.set('CONFIG_GLUSTERFS_XLATOR_OPT', glusterfs.version().version_compare('>=4'))
diff --git a/meson_options.txt b/meson_options.txt
index d58c69315c..d140c0ef89 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -109,6 +109,8 @@ option('cocoa', type : 'feature', value : 'auto',
        description: 'Cocoa user interface (macOS only)')
 option('curl', type : 'feature', value : 'auto',
        description: 'CURL block device driver')
+option('gio', type : 'feature', value : 'auto',
+       description: 'use libgio for D-Bus support')
 option('glusterfs', type : 'feature', value : 'auto',
        description: 'Glusterfs block device driver')
 option('libiscsi', type : 'feature', value : 'auto',
diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh
index 0daeb11fd3..92be3e6187 100644
--- a/scripts/meson-buildoptions.sh
+++ b/scripts/meson-buildoptions.sh
@@ -59,6 +59,7 @@ meson_options_help() {
   printf "%s\n" '  fuse-lseek      SEEK_HOLE/SEEK_DATA support for FUSE exports'
   printf "%s\n" '  gcrypt          libgcrypt cryptography support'
   printf "%s\n" '  gettext         Localization of the GTK+ user interface'
+  printf "%s\n" '  gio             use libgio for D-Bus support'
   printf "%s\n" '  glusterfs       Glusterfs block device driver'
   printf "%s\n" '  gnutls          GNUTLS cryptography support'
   printf "%s\n" '  gtk             GTK+ user interface'
@@ -208,6 +209,8 @@ _meson_option_parse() {
     --disable-gcrypt) printf "%s" -Dgcrypt=disabled ;;
     --enable-gettext) printf "%s" -Dgettext=enabled ;;
     --disable-gettext) printf "%s" -Dgettext=disabled ;;
+    --enable-gio) printf "%s" -Dgio=enabled ;;
+    --disable-gio) printf "%s" -Dgio=disabled ;;
     --enable-glusterfs) printf "%s" -Dglusterfs=enabled ;;
     --disable-glusterfs) printf "%s" -Dglusterfs=disabled ;;
     --enable-gnutls) printf "%s" -Dgnutls=enabled ;;
diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build
index d25f82bb5a..69f97b8992 100644
--- a/tests/qtest/meson.build
+++ b/tests/qtest/meson.build
@@ -99,14 +99,13 @@ if dbus_display
 endif
 
 dbus_daemon = find_program('dbus-daemon', required: false)
-if dbus_daemon.found() and config_host.has_key('GDBUS_CODEGEN')
+if dbus_daemon.found() and gdbus_codegen.found()
   # Temporarily disabled due to Patchew failures:
   #qtests_i386 += ['dbus-vmstate-test']
   dbus_vmstate1 = custom_target('dbus-vmstate description',
                                 output: ['dbus-vmstate1.h', 'dbus-vmstate1.c'],
                                 input: meson.project_source_root() / 'backends/dbus-vmstate1.xml',
-                                command: [config_host['GDBUS_CODEGEN'],
-                                          '@INPUT@',
+                                command: [gdbus_codegen, '@INPUT@',
                                           '--interface-prefix', 'org.qemu',
                                           '--generate-c-code', '@BASENAME@']).to_list()
 else
diff --git a/ui/meson.build b/ui/meson.build
index b21d3d1534..eba93b41e3 100644
--- a/ui/meson.build
+++ b/ui/meson.build
@@ -74,14 +74,13 @@ if dbus_display
   dbus_display1 = custom_target('dbus-display gdbus-codegen',
                                 output: ['dbus-display1.h', 'dbus-display1.c'],
                                 input: files('dbus-display1.xml'),
-                                command: [config_host['GDBUS_CODEGEN'],
-                                          '@INPUT@',
+                                command: [gdbus_codegen, '@INPUT@',
                                           '--glib-min-required', '2.64',
                                           '--output-directory', meson.current_build_dir(),
                                           '--interface-prefix', 'org.qemu.',
                                           '--c-namespace', 'QemuDBus',
                                           '--generate-c-code', '@BASENAME@'])
-  dbus_ss.add(when: [gio, pixman, opengl, 'CONFIG_GIO'],
+  dbus_ss.add(when: [gio, pixman, opengl],
               if_true: [files(
                 'dbus-chardev.c',
                 'dbus-clipboard.c',
@@ -128,7 +127,7 @@ if spice.found()
   ui_modules += {'spice-core' : spice_core_ss}
 endif
 
-if spice.found() and config_host.has_key('CONFIG_GIO')
+if spice.found() and gio.found()
   spice_ss = ss.source_set()
   spice_ss.add(spice, gio, pixman, files('spice-app.c'))
   ui_modules += {'spice-app': spice_ss}
diff --git a/util/meson.build b/util/meson.build
index 82eec004e2..8f16018cd4 100644
--- a/util/meson.build
+++ b/util/meson.build
@@ -61,7 +61,7 @@ endif
 
 if have_system
   util_ss.add(files('crc-ccitt.c'))
-  util_ss.add(when: 'CONFIG_GIO', if_true: [files('dbus.c'), gio])
+  util_ss.add(when: gio, if_true: files('dbus.c'))
   util_ss.add(when: 'CONFIG_LINUX', if_true: files('userfaultfd.c'))
 endif
 
-- 
2.35.1




  parent reply	other threads:[~2022-04-20 15:49 UTC|newest]

Thread overview: 74+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-20 15:33 [PATCH 00/34] Misc meson conversions for QEMU 7.1 Paolo Bonzini
2022-04-20 15:33 ` [PATCH 01/34] meson: show final set of compiler flags Paolo Bonzini
2022-04-20 15:57   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 02/34] configure: remove dead code Paolo Bonzini
2022-04-20 16:04   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 03/34] qga: wixl: get path to sysroot from pkg-config as intended Paolo Bonzini
2022-04-20 15:47   ` Marc-André Lureau
2022-04-21 14:18   ` Konstantin Kostiuk
2022-04-20 15:33 ` [PATCH 04/34] configure: pc-bios/qemu-icon.bmp does not exist Paolo Bonzini
2022-04-20 15:47   ` Thomas Huth
2022-04-20 16:05   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 05/34] configure: gcov should not exclude fortify-source Paolo Bonzini
2022-04-20 16:06   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 06/34] configure: move --enable/--disable-debug-info to second option parsing pass Paolo Bonzini
2022-04-20 15:42   ` Thomas Huth
2022-04-20 16:08   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 07/34] configure, meson: move OpenGL check to meson Paolo Bonzini
2022-04-20 16:13   ` Marc-André Lureau
2022-04-20 19:17     ` Paolo Bonzini
2022-04-20 15:33 ` [PATCH 08/34] meson, configure: move RDMA options " Paolo Bonzini
2022-04-20 16:24   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 09/34] meson, configure: move keyctl test " Paolo Bonzini
2022-04-20 16:27   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 10/34] meson, configure: move usbfs " Paolo Bonzini
2022-04-20 16:35   ` Marc-André Lureau
2022-04-20 15:33 ` Paolo Bonzini [this message]
2022-04-20 16:40   ` [PATCH 11/34] meson, configure: move libgio " Marc-André Lureau
2022-04-20 15:33 ` [PATCH 12/34] meson: move CONFIG_XEN_PCI_PASSTHROUGH to config-host.h Paolo Bonzini
2022-04-20 16:45   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 13/34] meson, configure: move --enable-module-upgrades to meson Paolo Bonzini
2022-04-20 18:05   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 14/34] meson, configure: move Xen detection " Paolo Bonzini
2022-04-20 15:33 ` [PATCH 15/34] meson-buildoptions: add support for string options Paolo Bonzini
2022-04-20 18:14   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 16/34] configure, meson: move iasl detection to meson Paolo Bonzini
2022-04-20 18:17   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 17/34] configure: move Windows flags " Paolo Bonzini
2022-04-20 18:20   ` Marc-André Lureau
2022-04-20 19:15     ` Paolo Bonzini
2022-04-20 15:33 ` [PATCH 18/34] configure: switch string options to automatic parsing Paolo Bonzini
2022-04-20 18:23   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 19/34] meson, configure: move --tls-priority to meson Paolo Bonzini
2022-04-20 18:25   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 20/34] meson, configure: move bdrv whitelists " Paolo Bonzini
2022-04-20 18:28   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 21/34] meson, configure: move --with-pkgversion, CONFIG_STAMP " Paolo Bonzini
2022-04-20 18:34   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 22/34] meson, configure: move --interp-prefix " Paolo Bonzini
2022-04-20 18:40   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 23/34] meson: always combine directories with prefix Paolo Bonzini
2022-04-20 18:43   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 24/34] configure: switch directory options to automatic parsing Paolo Bonzini
2022-04-21  9:48   ` Marc-André Lureau
2022-04-21 12:02     ` Paolo Bonzini
2022-04-20 15:33 ` [PATCH 25/34] meson: pass more options directly as -D Paolo Bonzini
2022-04-21  9:52   ` Marc-André Lureau
2022-04-20 15:33 ` [PATCH 26/34] configure: omit options with default values from meson command line Paolo Bonzini
2022-04-21 10:04   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 27/34] meson, virtio: place all virtio-pci devices under virtio_pci_ss Paolo Bonzini
2022-04-21 10:05   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 28/34] configure: simplify vhost-net-{user, vdpa} configuration Paolo Bonzini
2022-04-21 10:08   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 29/34] build: move vhost-vsock configuration to Kconfig Paolo Bonzini
2022-04-21 11:38   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 30/34] build: move vhost-scsi " Paolo Bonzini
2022-04-21 11:47   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 31/34] build: move vhost-user-fs " Paolo Bonzini
2022-04-21 11:48   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 32/34] meson: create have_vhost_* variables Paolo Bonzini
2022-04-21 12:01   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 33/34] meson: use have_vhost_* variables to pick sources Paolo Bonzini
2022-04-21 12:08   ` Marc-André Lureau
2022-04-20 15:34 ` [PATCH 34/34] configure, meson: move vhost options to Meson Paolo Bonzini
2022-04-21 12:13   ` Marc-André Lureau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420153407.73926-12-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).