[glib-networking] Allow static build of modules



commit 293b10ce2834559f7fe08586b336d8c6672bab96
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Fri Dec 1 16:03:18 2017 -0500

    Allow static build of modules
    
    To be able to static link all modules into an executable,
    g_io_module_load/unload/query() symbols needs to be renamed to the new
    naming scheme supported by glib 2.56. Those functions should also
    support receiving NULL GIOModule, and register the extension point
    manually since they won't be pre-discovered by reading giomodule.cache.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=791100

 glib-networking.map                |    6 +++---
 meson.build                        |    2 +-
 proxy/gnome/gnome-proxy-module.c   |    6 +++---
 proxy/gnome/gproxyresolvergnome.c  |    2 ++
 proxy/libproxy/glibproxyresolver.c |    2 ++
 proxy/libproxy/libproxy-module.c   |    6 +++---
 tls/gnutls/gnutls-module.c         |    6 +++---
 tls/gnutls/gtlsbackend-gnutls.c    |    8 +++++++-
 8 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/glib-networking.map b/glib-networking.map
index 43ed5a7..354a941 100644
--- a/glib-networking.map
+++ b/glib-networking.map
@@ -1,8 +1,8 @@
 {
 global:
-  g_io_module_load;
-  g_io_module_unload;
-  g_io_module_query;
+  g_io_*_load;
+  g_io_*_unload;
+  g_io_*_query;
 local:
   *;
 };
diff --git a/meson.build b/meson.build
index a0b769a..af40c44 100644
--- a/meson.build
+++ b/meson.build
@@ -42,7 +42,7 @@ if host_machine.system().contains('linux')
 endif
 
 # *** Check GLib GIO        ***
-glib_dep = dependency('glib-2.0', version: '>= 2.46.0')
+glib_dep = dependency('glib-2.0', version: '>= 2.55.0')
 gio_dep = dependency('gio-2.0')
 
 gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir')
diff --git a/proxy/gnome/gnome-proxy-module.c b/proxy/gnome/gnome-proxy-module.c
index dc623ae..7c624a6 100644
--- a/proxy/gnome/gnome-proxy-module.c
+++ b/proxy/gnome/gnome-proxy-module.c
@@ -25,7 +25,7 @@
 
 
 void
-g_io_module_load (GIOModule *module)
+g_io_gnomeproxy_load (GIOModule *module)
 {
   gchar *locale_dir;
 #ifdef G_OS_WIN32
@@ -48,12 +48,12 @@ g_io_module_load (GIOModule *module)
 }
 
 void
-g_io_module_unload (GIOModule *module)
+g_io_gnomeproxy_unload (GIOModule *module)
 {
 }
 
 gchar **
-g_io_module_query (void)
+g_io_gnomeproxy_query (void)
 {
   gchar *eps[] = {
     G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
diff --git a/proxy/gnome/gproxyresolvergnome.c b/proxy/gnome/gproxyresolvergnome.c
index 6a3be57..e72a2a1 100644
--- a/proxy/gnome/gproxyresolvergnome.c
+++ b/proxy/gnome/gproxyresolvergnome.c
@@ -537,6 +537,8 @@ void
 g_proxy_resolver_gnome_register (GIOModule *module)
 {
   g_proxy_resolver_gnome_register_type (G_TYPE_MODULE (module));
+  if (module == NULL)
+    g_io_extension_point_register (G_PROXY_RESOLVER_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
                                  g_proxy_resolver_gnome_get_type(),
                                  "gnome",
diff --git a/proxy/libproxy/glibproxyresolver.c b/proxy/libproxy/glibproxyresolver.c
index c46e4ae..4d28b57 100644
--- a/proxy/libproxy/glibproxyresolver.c
+++ b/proxy/libproxy/glibproxyresolver.c
@@ -231,6 +231,8 @@ void
 g_libproxy_resolver_register (GIOModule *module)
 {
   g_libproxy_resolver_register_type (G_TYPE_MODULE (module));
+  if (module == NULL)
+    g_io_extension_point_register (G_PROXY_RESOLVER_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
                                  g_libproxy_resolver_get_type(),
                                  "libproxy",
diff --git a/proxy/libproxy/libproxy-module.c b/proxy/libproxy/libproxy-module.c
index 20697ed..b6feace 100644
--- a/proxy/libproxy/libproxy-module.c
+++ b/proxy/libproxy/libproxy-module.c
@@ -27,7 +27,7 @@
 
 
 void
-g_io_module_load (GIOModule *module)
+g_io_libproxy_load (GIOModule *module)
 {
   gchar *locale_dir;
 #ifdef G_OS_WIN32
@@ -50,12 +50,12 @@ g_io_module_load (GIOModule *module)
 }
 
 void
-g_io_module_unload (GIOModule *module)
+g_io_libproxy_unload (GIOModule *module)
 {
 }
 
 gchar **
-g_io_module_query (void)
+g_io_libproxy_query (void)
 {
   gchar *eps[] = {
     G_PROXY_RESOLVER_EXTENSION_POINT_NAME,
diff --git a/tls/gnutls/gnutls-module.c b/tls/gnutls/gnutls-module.c
index 21d8b81..663f8c5 100644
--- a/tls/gnutls/gnutls-module.c
+++ b/tls/gnutls/gnutls-module.c
@@ -30,7 +30,7 @@
 
 
 void
-g_io_module_load (GIOModule *module)
+g_io_gnutls_load (GIOModule *module)
 {
   gchar *locale_dir;
 #ifdef G_OS_WIN32
@@ -56,12 +56,12 @@ g_io_module_load (GIOModule *module)
 }
 
 void
-g_io_module_unload (GIOModule *module)
+g_io_gnutls_unload (GIOModule *module)
 {
 }
 
 gchar **
-g_io_module_query (void)
+g_io_gnutls_query (void)
 {
   gchar *eps[] = {
     G_TLS_BACKEND_EXTENSION_POINT_NAME,
diff --git a/tls/gnutls/gtlsbackend-gnutls.c b/tls/gnutls/gtlsbackend-gnutls.c
index f8e357b..6324563 100644
--- a/tls/gnutls/gtlsbackend-gnutls.c
+++ b/tls/gnutls/gtlsbackend-gnutls.c
@@ -57,6 +57,8 @@ gtls_log_func (int level, const char *msg)
 static gpointer
 gtls_gnutls_init (gpointer data)
 {
+  GTypePlugin *plugin;
+
   gnutls_global_init ();
 
 #ifdef GTLS_GNUTLS_DEBUG
@@ -65,7 +67,9 @@ gtls_gnutls_init (gpointer data)
 #endif
 
   /* Leak the module to keep it from being unloaded. */
-  g_type_plugin_use (g_type_get_plugin (G_TYPE_TLS_BACKEND_GNUTLS));
+  plugin = g_type_get_plugin (G_TYPE_TLS_BACKEND_GNUTLS);
+  if (plugin != NULL)
+    g_type_plugin_use (plugin);
   return NULL;
 }
 
@@ -312,6 +316,8 @@ void
 g_tls_backend_gnutls_register (GIOModule *module)
 {
   g_tls_backend_gnutls_register_type (G_TYPE_MODULE (module));
+  if (module == NULL)
+    g_io_extension_point_register (G_TLS_BACKEND_EXTENSION_POINT_NAME);
   g_io_extension_point_implement (G_TLS_BACKEND_EXTENSION_POINT_NAME,
                                  g_tls_backend_gnutls_get_type(),
                                  "gnutls",


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