[glib-networking/wip/nacho/gnutls-optional: 6/9] meson: use the new feature option type for options



commit 8629f3d5a58bd12d2b6818b6ca8ff1231375a2fb
Author: Ignacio Casal Quinteiro <qignacio amazon com>
Date:   Tue Sep 11 12:17:48 2018 +0200

    meson: use the new feature option type for options

 meson.build            | 43 ++++++++++++++++++-------------------------
 meson_options.txt      |  8 ++++----
 tls/gnutls/meson.build |  2 +-
 tls/tests/meson.build  |  4 ++--
 4 files changed, 25 insertions(+), 32 deletions(-)
---
diff --git a/meson.build b/meson.build
index c3ec364..cc1c1fa 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@ project(
   'glib-networking', 'c',
   version: '2.58.0',
   license: 'LGPL2.1+',
-  meson_version: '>= 0.46.0',
+  meson_version: '>= 0.47.0',
   default_options: ['c_std=c11']
 )
 
@@ -63,32 +63,25 @@ endif
 assert(gio_module_dir != '', 'GIO_MODULE_DIR is missing from gio-2.0.pc')
 
 # *** Checks for LibProxy   ***
-enable_libproxy_support = get_option('libproxy_support')
-if enable_libproxy_support
-  libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1')
-endif
+libproxy_dep = dependency('libproxy-1.0', version: '>= 0.3.1', required: get_option('libproxy'))
 
 # *** Checks for GNOME      ***
-enable_gnome_proxy_support = get_option('gnome_proxy_support')
-if enable_gnome_proxy_support
-  gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas')
-endif
+gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas', required: get_option('gnome_proxy'))
 
 backends = []
 
 # *** Checks for GnuTLS     ***
-enable_gnutls_support = get_option('gnutls_support')
-if enable_gnutls_support
-  gnutls_dep = dependency('gnutls', version: '>= 3.4.4')
+gnutls_dep = dependency('gnutls', version: '>= 3.4.4', required: get_option('gnutls'))
+
+if gnutls_dep.found()
   backends += ['gnutls']
 endif
 
 # *** Checks for p11-kit  ***
-enable_pkcs11_support = get_option('pkcs11_support')
-if enable_pkcs11_support
-  pkcs11_dep = dependency('p11-kit-1', version: '>= 0.20')
+pkcs11_dep = dependency('p11-kit-1', version: '>= 0.20', required: get_option('pkcs11'))
 
-  config_h.set('HAVE_PKCS11', enable_pkcs11_support,
+if pkcs11_dep.found()
+  config_h.set('HAVE_PKCS11', 1,
                description: 'Building with PKCS#11 support')
 endif
 
@@ -118,25 +111,25 @@ if ['darwin', 'ios'].contains(host_system)
   module_suffix = 'so'
 endif
 
-if enable_libproxy_support or enable_gnome_proxy_support
+if libproxy_dep.found() or gsettings_desktop_schemas_dep.found()
   proxy_test_programs = []
 
-  if enable_libproxy_support
+  if libproxy_dep.found()
     subdir('proxy/libproxy')
   endif
 
-  if enable_gnome_proxy_support
+  if gsettings_desktop_schemas_dep.found()
     subdir('proxy/gnome')
   endif
 
   subdir('proxy/tests')
 endif
 
-if enable_pkcs11_support
+if pkcs11_dep.found()
   subdir('tls/pkcs11')
 endif
 
-if enable_gnutls_support
+if gnutls_dep.found()
   subdir('tls/gnutls')
 endif
 
@@ -148,8 +141,8 @@ if gio_querymodules.found()
   meson.add_install_script('meson_post_install.py', gio_querymodules.path(), gio_module_dir)
 endif
 
-output = '\n\n gnutls support:    ' + enable_gnutls_support.to_string() + '\n'
-output += '  libproxy support:    ' + enable_libproxy_support.to_string() + '\n'
-output += '  GNOME proxy support: ' + enable_gnome_proxy_support.to_string() + '\n'
-output += '  PKCS#11 support:     ' + enable_pkcs11_support.to_string() + '\n'
+output = '\n\n gnutls support:    ' + libproxy_dep.found().to_string() + '\n'
+output += '  libproxy support:    ' + libproxy_dep.found().to_string() + '\n'
+output += '  GNOME proxy support: ' + gsettings_desktop_schemas_dep.found().to_string() + '\n'
+output += '  PKCS#11 support:     ' + pkcs11_dep.found().to_string() + '\n'
 message(output)
diff --git a/meson_options.txt b/meson_options.txt
index 8089860..9ae11ed 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,6 @@
-option('gnutls_support', type: 'boolean', value: true, description: 'support for GnuTLS networking 
configration')
-option('libproxy_support', type: 'boolean', value: true, description: 'support for libproxy proxy 
configration')
-option('gnome_proxy_support', type: 'boolean', value: true, description: 'support for GNOME desktop proxy 
configuration')
-option('pkcs11_support', type: 'boolean', value: false, description: 'support for PKCS#11 using p11-kit')
+option('gnutls', type: 'feature', value: 'auto', description: 'support for GnuTLS networking configration')
+option('libproxy', type: 'feature', value: 'auto', description: 'support for libproxy proxy configration')
+option('gnome_proxy', type: 'feature', value: 'auto', description: 'support for GNOME desktop proxy 
configuration')
+option('pkcs11', type: 'feature', value: 'disabled', description: 'support for PKCS#11 using p11-kit')
 option('installed_tests', type: 'boolean', value: false, description: 'enable installed tests')
 option('static_modules', type: 'boolean', value: false, description: 'build static modules')
diff --git a/tls/gnutls/meson.build b/tls/gnutls/meson.build
index b0a7e2c..55280c9 100644
--- a/tls/gnutls/meson.build
+++ b/tls/gnutls/meson.build
@@ -21,7 +21,7 @@ deps = [
   gnutls_dep
 ]
 
-if enable_pkcs11_support
+if pkcs11_dep.found()
   sources += files(
     'gtlsbackend-gnutls-pkcs11.c',
     'gtlscertificate-gnutls-pkcs11.c',
diff --git a/tls/tests/meson.build b/tls/tests/meson.build
index 60890c6..656b0e8 100644
--- a/tls/tests/meson.build
+++ b/tls/tests/meson.build
@@ -10,7 +10,7 @@ deps = [
   gobject_dep,
 ]
 
-if enable_gnutls_support
+if gnutls_dep.found()
   deps += [
     gnutls_dep
   ]
@@ -33,7 +33,7 @@ test_programs = [
   ['dtls-connection', ['mock-interaction.c'], deps],
 ]
 
-if enable_pkcs11_support
+if pkcs11_dep.found()
   pkcs11_deps = deps + [
     libgiopkcs11_dep,
     pkcs11_dep


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