[libgit2-glib/wip/inigomartinez/meson: 4/12] meson: Applied meson guidelines for SSH option



commit 1ae2a7013a58a573f9c7948d69d2cbb6b36bf1df
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Fri Jan 19 11:43:01 2018 +0100

    meson: Applied meson guidelines for SSH option
    
    Following the meson porting guidelines[0], the `ssh` option has been
    changed to be a boolean option.
    
    The options behaviour has also been slightly simplified by moving
    the configuration object to the libgit2-glib where the `ggit.h.in`
    actually resides.
    
    An auxiliary variable has also been set to avoid writing the file
    name twice which can be error prone.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792699
    
    [0] https://wiki.gnome.org/Initiatives/GnomeGoals/MesonPorting

 libgit2-glib/meson.build |   25 +++++++++++++++++++++----
 meson.build              |   27 +++++----------------------
 meson_options.txt        |    2 +-
 3 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/libgit2-glib/meson.build b/libgit2-glib/meson.build
index 6a09bd2..1d002b8 100644
--- a/libgit2-glib/meson.build
+++ b/libgit2-glib/meson.build
@@ -154,10 +154,27 @@ if enable_ssh
   ]
 endif
 
-configure_file(input : 'ggit.h.in',
-               output : 'ggit.h',
-               configuration : ggit_h_data,
-               install_dir: libgit2_glib_pkgincludedir)
+if enable_ssh
+  ssh_includes = '''
+#include <libgit2-glib/ggit-cred-ssh-key-from-agent.h>
+#include <libgit2-glib/ggit-cred-ssh-interactive.h>
+'''
+
+  extra_args += [ '-DGIT_SSH=1' ]
+else
+  ssh_includes = ''
+endif
+
+ggit_h_conf = configuration_data()
+ggit_h_conf.set('GGIT_SSH_INCLUDES', ssh_includes)
+
+ggit_h = 'ggit.h'
+
+sources += configure_file(
+  input: ggit_h + '.in',
+  output: ggit_h,
+  configuration: ggit_h_conf,
+  install_dir: libgit2_glib_pkgincludedir)
 
 enum_types = gnome.mkenums('ggit-enum-types',
   sources : headers,
diff --git a/meson.build b/meson.build
index 9288562..897b669 100644
--- a/meson.build
+++ b/meson.build
@@ -140,14 +140,10 @@ if enable_gir
   enable_gir = find_program('g-ir-scanner', required: false).found() and not meson.is_cross_build()
 endif
 
-ggit_h_data = configuration_data()
-ggit_h_data.set('GGIT_SSH_INCLUDES', '')
-
 # Check for libgit2 ssh support
-enable_ssh_opt = get_option('ssh')
-enable_ssh = false
-if enable_ssh_opt != 'no'
-  have_libgit2_ssh = cc.compiles('''
+enable_ssh = get_option('ssh')
+if enable_ssh
+  libgit2_ssh_src = '''
     #include <git2.h>
     int
     main(int argc, const char *argv[])
@@ -155,22 +151,9 @@ if enable_ssh_opt != 'no'
             git_libgit2_init ();
             return ((git_libgit2_features() & GIT_FEATURE_SSH) != 0) ? 0 : 1;
     }
-  ''',
-  name: 'libgit2 supports SSH')
-
-  if enable_ssh_opt == 'yes' and not have_libgit2_ssh
-    error('libgit2 ssh support was requested, but not found')
-  endif
+  '''
 
-  if have_libgit2_ssh
-    ssh_includes = '''
-#include <libgit2-glib/ggit-cred-ssh-key-from-agent.h>
-#include <libgit2-glib/ggit-cred-ssh-interactive.h>
-'''
-    ggit_h_data.set('GGIT_SSH_INCLUDES', ssh_includes)
-    extra_args += [ '-DGIT_SSH=1' ]
-    enable_ssh = true
-  endif
+  assert(cc.compiles(libgit2_ssh_src, name: 'libgit2 supports SSH'), 'libgit2 ssh support was requested, but 
not found. Use -Dssh=false to build without it.')
 endif
 
 gnome = import('gnome')
diff --git a/meson_options.txt b/meson_options.txt
index 599b943..6d93e07 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,4 @@
 option('gtk-doc', type: 'boolean', value: false, description: 'Enable generating the API reference (depends 
on GTK-Doc)')
 option('introspection', type: 'boolean', value: true, description: 'Enable GObject Introspection')
 option('debug', type: 'combo', choices: [ 'auto', 'yes', 'minimum', 'no' ], value: 'yes', description: 
'Enable debugging level')
-option('ssh', type: 'combo', choices: [ 'auto', 'yes', 'no' ], value: 'auto', description: 'Build with 
libgit2 ssh support')
+option('ssh', type: 'boolean', value: true, description: 'Build with libgit2 ssh support')


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