[libvirt PATCH v2 19/21] meson: use runtime binaries to only resolve features with "auto" value

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

 



This way meson will try to do the right thing by default but we will
allow users to change this behavior by using -Dname=enabled. This comes
with two benefits compared to the previous behavior:

  - no need to install the binaries if developers would like to check
    that the code compiles correctly

  - package maintainers can drop some build dependencies

Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 meson.build | 102 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 63 insertions(+), 39 deletions(-)

diff --git a/meson.build b/meson.build
index 5d8eb7f95c..a7d402cd31 100644
--- a/meson.build
+++ b/meson.build
@@ -1072,12 +1072,6 @@ endif
 
 libparted_version = '1.8.0'
 libparted_dep = dependency('libparted', version: '>=' + libparted_version, required: false)
-if libparted_dep.found()
-  parted_prog = find_program('parted', required: false, dirs: libvirt_sbin_path)
-  if not parted_prog.found()
-    libparted_dep = dependency('', required: false)
-  endif
-endif
 
 libpcap_version = '1.5.0'
 if not get_option('libpcap').disabled()
@@ -1480,11 +1474,17 @@ if not get_option('driver_libvirtd').disabled()
 endif
 
 if not get_option('driver_bhyve').disabled() and host_machine.system() == 'freebsd'
-  bhyve_prog = find_program('bhyve', required: get_option('driver_bhyve'))
-  bhyvectl_prog = find_program('bhyvectl', required: get_option('driver_bhyve'))
-  bhyveload_prog = find_program('bhyveload', required: get_option('driver_bhyve'))
+  bhyve_enable = true
 
-  if bhyve_prog.found() and bhyvectl_prog.found() and bhyveload_prog.found()
+  if get_option('driver_bhyve').auto()
+    bhyve_prog = find_program('bhyve', required: false)
+    bhyvectl_prog = find_program('bhyvectl', required: false)
+    bhyveload_prog = find_program('bhyveload', required: false)
+
+    bhyve_enable = bhyve_prog.found() and bhyvectl_prog.found() and bhyveload_prog.found()
+  endif
+
+  if bhyve_enable
     conf.set('WITH_BHYVE', 1)
   endif
 elif get_option('driver_bhyve').enabled()
@@ -1740,8 +1740,17 @@ if conf.has('WITH_LIBVIRTD')
   endif
 
   if not get_option('storage_disk').disabled() and devmapper_dep.found() and libparted_dep.found()
-    use_storage = true
-    conf.set('WITH_STORAGE_DISK', 1)
+    disk_enable = true
+
+    if get_option('storage_disk').auto()
+      parted_prog = find_program('parted', required: false, dirs: libvirt_sbin_path)
+      disk_enable = parted_prog.found()
+    endif
+
+    if disk_enable
+      use_storage = true
+      conf.set('WITH_STORAGE_DISK', 1)
+    endif
   elif get_option('storage_disk').enabled()
     error('You must install libparted and libdevmapper to compile libvirt with disk storage driver')
   endif
@@ -1762,10 +1771,10 @@ if conf.has('WITH_LIBVIRTD')
       endif
     endif
 
-    if fs_enable
-      mount_prog = find_program('mount', required: get_option('storage_fs'), dirs: libvirt_sbin_path)
-      umount_prog = find_program('umount', required: get_option('storage_fs'), dirs: libvirt_sbin_path)
-      mkfs_prog = find_program('mkfs', required: get_option('storage_fs'), dirs: libvirt_sbin_path)
+    if fs_enable and get_option('storage_fs').auto()
+      mount_prog = find_program('mount', required: false, dirs: libvirt_sbin_path)
+      umount_prog = find_program('umount', required: false, dirs: libvirt_sbin_path)
+      mkfs_prog = find_program('mkfs', required: false, dirs: libvirt_sbin_path)
 
       if not mount_prog.found() or not umount_prog.found() or not mkfs_prog.found()
         fs_enable = false
@@ -1787,14 +1796,11 @@ if conf.has('WITH_LIBVIRTD')
 
   if not get_option('storage_iscsi').disabled()
     iscsi_enable = true
-    iscsiadm_prog = find_program('iscsiadm', required: false, dirs: libvirt_sbin_path)
 
-    if not iscsiadm_prog.found()
-      if get_option('storage_iscsi').enabled()
-        error('We need iscsiadm for iSCSI storage driver')
-      else
-        iscsi_enable = false
-      endif
+    if get_option('storage_iscsi').auto()
+      iscsiadm_prog = find_program('iscsiadm', required: false, dirs: libvirt_sbin_path)
+
+      iscsi_enable = iscsiadm_prog.found()
     endif
 
     if iscsi_enable
@@ -1818,12 +1824,15 @@ if conf.has('WITH_LIBVIRTD')
       'lvchange', 'vgchange', 'vgscan',
       'pvs', 'vgs', 'lvs',
     ]
-    foreach name : lvm_progs
-      lvm_prog = find_program(name, required: get_option('storage_lvm'), dirs: libvirt_sbin_path)
-      if not lvm_prog.found()
-        lvm_enable = false
-      endif
-    endforeach
+
+    if get_option('storage_lvm').auto()
+      foreach name : lvm_progs
+        lvm_prog = find_program(name, required: false, dirs: libvirt_sbin_path)
+        if not lvm_prog.found()
+          lvm_enable = false
+        endif
+      endforeach
+    endif
 
     if lvm_enable
       use_storage = true
@@ -1851,9 +1860,15 @@ if conf.has('WITH_LIBVIRTD')
   endif
 
   if not get_option('storage_sheepdog').disabled()
-    sheepdogcli_prog = find_program('dog', required: get_option('storage_sheepdog'), dirs: libvirt_sbin_path)
+    sheepdog_enable = true
 
-    if sheepdogcli_prog.found()
+    if get_option('storage_sheepdog').auto()
+      sheepdogcli_prog = find_program('dog', required: false, dirs: libvirt_sbin_path)
+
+      sheepdog_enable = sheepdogcli_prog.found()
+    endif
+
+    if sheepdog_enable
       use_storage = true
       conf.set('WITH_STORAGE_SHEEPDOG', 1)
     endif
@@ -1877,12 +1892,15 @@ if conf.has('WITH_LIBVIRTD')
 
   if not get_option('storage_zfs').disabled()
     zfs_enable = true
-    foreach name : ['zfs', 'zpool']
-      zfs_prog = find_program(name, required: get_option('storage_zfs'), dirs: libvirt_sbin_path)
-      if not zfs_prog.found()
-        zfs_enable = false
-      endif
-    endforeach
+
+    if get_option('storage_zfs').auto()
+      foreach name : ['zfs', 'zpool']
+        zfs_prog = find_program(name, required: false, dirs: libvirt_sbin_path)
+        if not zfs_prog.found()
+          zfs_enable = false
+        endif
+      endforeach
+    endif
 
     if zfs_enable
       use_storage = true
@@ -1997,8 +2015,14 @@ if not get_option('nss').disabled()
 endif
 
 if not get_option('numad').disabled() and numactl_dep.found()
-  numad_prog = find_program('numad', required: get_option('numad'), dirs: libvirt_sbin_path)
-  if numad_prog.found()
+  numad_enable = true
+
+  if get_option('numad').auto()
+    numad_prog = find_program('numad', required: false, dirs: libvirt_sbin_path)
+    numad_enable = numad_prog.found()
+  endif
+
+  if numad_enable
     conf.set('WITH_NUMAD', 1)
   endif
 elif get_option('numad').enabled()
-- 
2.30.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux