[glib: 5/7] Do not define GIO_COMPILATION for executables




commit 8733d172a39a890f87f61579872c1aeba7c5e4c4
Author: Xavier Claessens <xavier claessens collabora com>
Date:   Wed Oct 5 17:45:07 2022 -0400

    Do not define GIO_COMPILATION for executables
    
    It must only be defined when building libgio. This requires some
    workaround to allow include of some gio private headers.
    
    When GIO_COMPILATION is not defined we cannot include individual gio
    headers. We workaround that by defining __GIO_GIO_H_INSIDE__ in some
    places. Also gdbusprivate.h is not an installed header, so it's fine to
    include it directly.

 gio/gdbusprivate.h           | 4 ----
 gio/gio-querymodules.c       | 3 ++-
 gio/giomodule-priv.c         | 2 ++
 gio/glib-compile-resources.c | 4 ++--
 gio/inotify/meson.build      | 2 +-
 gio/kqueue/meson.build       | 2 +-
 gio/meson.build              | 9 ++++++---
 gio/win32/meson.build        | 2 +-
 8 files changed, 15 insertions(+), 13 deletions(-)
---
diff --git a/gio/gdbusprivate.h b/gio/gdbusprivate.h
index 6a4c8e099c..e7a5bfa4f1 100644
--- a/gio/gdbusprivate.h
+++ b/gio/gdbusprivate.h
@@ -23,10 +23,6 @@
 #ifndef __G_DBUS_PRIVATE_H__
 #define __G_DBUS_PRIVATE_H__
 
-#if !defined (GIO_COMPILATION)
-#error "gdbusprivate.h is a private header file."
-#endif
-
 #include <gio/giotypes.h>
 
 G_BEGIN_DECLS
diff --git a/gio/gio-querymodules.c b/gio/gio-querymodules.c
index faddbcfb86..7e69206272 100644
--- a/gio/gio-querymodules.c
+++ b/gio/gio-querymodules.c
@@ -21,7 +21,8 @@
  */
 
 #include "config.h"
-#include "giomodule.h"
+
+#include <gio/gio.h>
 #include "giomodule-priv.h"
 
 #include <gstdio.h>
diff --git a/gio/giomodule-priv.c b/gio/giomodule-priv.c
index 3dbbd0f291..92bde60697 100644
--- a/gio/giomodule-priv.c
+++ b/gio/giomodule-priv.c
@@ -21,6 +21,8 @@
  */
 
 #include "config.h"
+
+#define __GIO_GIO_H_INSIDE__
 #include "giomodule.h"
 #include "giomodule-priv.h"
 
diff --git a/gio/glib-compile-resources.c b/gio/glib-compile-resources.c
index df7f9f2a49..0f873d4863 100644
--- a/gio/glib-compile-resources.c
+++ b/gio/glib-compile-resources.c
@@ -24,8 +24,6 @@
 #include <glib.h>
 #include <gstdio.h>
 #include <gi18n.h>
-#include <gioenums.h>
-
 #include <string.h>
 #include <stdio.h>
 #include <locale.h>
@@ -37,6 +35,8 @@
 #include <io.h>
 #endif
 
+#define __GIO_GIO_H_INSIDE__
+#include <gio/gioenums.h>
 #include <gio/gmemoryoutputstream.h>
 #include <gio/gzlibcompressor.h>
 #include <gio/gconverteroutputstream.h>
diff --git a/gio/inotify/meson.build b/gio/inotify/meson.build
index 9b0c7ab300..a1d542a247 100644
--- a/gio/inotify/meson.build
+++ b/gio/inotify/meson.build
@@ -12,4 +12,4 @@ inotify_lib = static_library('inotify',
   include_directories : [configinc, glibinc, gmoduleinc],
   dependencies : [gioenumtypes_dep, libglib_dep, libgobject_dep],
   pic : true,
-  c_args : gio_c_args)
+  c_args : [gio_c_args, gio_c_args_internal])
diff --git a/gio/kqueue/meson.build b/gio/kqueue/meson.build
index d389b06f70..c800ce3c38 100644
--- a/gio/kqueue/meson.build
+++ b/gio/kqueue/meson.build
@@ -10,4 +10,4 @@ kqueue_lib = static_library('kqueue',
   include_directories : [configinc, glibinc, gmoduleinc],
   dependencies : [gioenumtypes_dep],
   pic : true,
-  c_args : gio_c_args)
+  c_args : [gio_c_args, gio_c_args_internal])
diff --git a/gio/meson.build b/gio/meson.build
index afe865f453..33b46324e1 100644
--- a/gio/meson.build
+++ b/gio/meson.build
@@ -1,11 +1,14 @@
 gio_c_args = [
   '-DG_LOG_DOMAIN="GLib-GIO"',
-  '-DGIO_COMPILATION',
   '-DGIO_LAUNCH_DESKTOP="@0@"'.format(glib_prefix / multiarch_libexecdir / 'gio-launch-desktop'),
   '-DGIO_MODULE_DIR="@0@"'.format(glib_giomodulesdir),
   '-DLOCALSTATEDIR="@0@"'.format(glib_localstatedir),
 ]
 
+gio_c_args_internal = [
+  '-DGIO_COMPILATION',
+]
+
 # FIXME: Install empty glib_giomodulesdir
 
 gnetworking_h_conf = configuration_data()
@@ -837,8 +840,8 @@ libgio = library('gio-2.0',
                   libgobject_dep, libgmodule_dep, selinux_dep, xattr_dep,
                   platform_deps, network_libs, libsysprof_capture_dep,
                   gioenumtypes_dep, gvdb_dep],
-  c_args : gio_c_args,
-  objc_args : gio_c_args,
+  c_args : [gio_c_args, gio_c_args_internal],
+  objc_args : [gio_c_args, gio_c_args_internal],
   gnu_symbol_visibility : 'hidden',
   # intl.lib is not compatible with SAFESEH
   link_args : [noseh_link_args, glib_link_flags],
diff --git a/gio/win32/meson.build b/gio/win32/meson.build
index 8d589989b2..c44bb8195a 100644
--- a/gio/win32/meson.build
+++ b/gio/win32/meson.build
@@ -12,4 +12,4 @@ giowin32_lib = static_library('giowin32',
   include_directories : [configinc, glibinc, gioinc, gmoduleinc],
   dependencies : [libintl, gioenumtypes_dep],
   pic : true,
-  c_args : gio_c_args)
+  c_args : [gio_c_args, gio_c_args_internal])


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