[glib/wip/symbol-visibility: 3/6] buildsystem: Prepare _G*_API internal macros for symbol visibility



commit ecaf96567c6575365c8ca828e4a148132c160af5
Author: Colin Walters <walters verbum org>
Date:   Thu Nov 29 09:26:01 2012 -0500

    buildsystem: Prepare _G*_API internal macros for symbol visibility
    
    To switch GLib to have private-by-default symbols, we need to have a
    macro which expands to G_PUBLIC_API only when compiling a particular
    "sublibrary" in GLib (e.g. gmodule, gio).
    
    This patch implements that with a two-level scheme.  First, each
    sublibrary has its own preprocessor macro e.g. _GTHREAD_API.  Then,
    the Makefiles are modified to define this to G_PUBLIC_API only when
    building that library - so when building libgthread, _GMODULE_API is
    left undefined.
    
    Now, we could simply add _G*_API to every entry point, but because
    we've already been annotating all the headers with
    GLIB_AVAILABLE_IN_XX, let's modify those macros to automatically
    depend on a new "_G_API".  Then the Makefiles further define _G_API to
    the target such as _GTHREAD_API.  This indirection avoids a
    (glib version)*(sublibrary) explosion of preprocessor definitions in
    gversionmacros.h.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=688681

 gio/Makefile.am       |    2 ++
 glib/Makefile.am      |    2 ++
 glib/gmacros.h        |   31 +++++++++++++++++++++++++------
 glib/gversionmacros.h |   36 ++++++++++++++++++------------------
 gmodule/Makefile.am   |    2 ++
 gobject/Makefile.am   |    5 ++++-
 gthread/Makefile.am   |    2 ++
 7 files changed, 55 insertions(+), 25 deletions(-)
---
diff --git a/gio/Makefile.am b/gio/Makefile.am
index 683ff07..a3cf1ed 100644
--- a/gio/Makefile.am
+++ b/gio/Makefile.am
@@ -38,6 +38,8 @@ AM_CPPFLAGS = \
 	$(gmodule_INCLUDES)				\
 	$(GLIB_DEBUG_FLAGS)				\
 	-DGIO_COMPILATION				\
+	-D_GIO_API=G_PUBLIC_API				\
+	-D_G_API=_GIO_API				\
 	-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"	
 
 lib_LTLIBRARIES = libgio-2.0.la
diff --git a/glib/Makefile.am b/glib/Makefile.am
index 3168b1a..4249de2 100644
--- a/glib/Makefile.am
+++ b/glib/Makefile.am
@@ -47,6 +47,8 @@ AM_CPPFLAGS = 				\
 	-DG_LOG_DOMAIN=\"GLib\" 	\
 	$(GLIB_DEBUG_FLAGS) 		\
 	-DGLIB_COMPILATION 		\
+	-D_GLIB_API=G_PUBLIC_API	\
+	-D_G_API=_GLIB_API 		\
 	-DPCRE_STATIC
 
 glib.def: glib.symbols
diff --git a/glib/gmacros.h b/glib/gmacros.h
index 4ad57da..9ef6335 100644
--- a/glib/gmacros.h
+++ b/glib/gmacros.h
@@ -324,6 +324,25 @@
 #define G_UNAVAILABLE(maj,min)
 #endif
 
+#ifndef _G_API
+#define _G_API
+#endif
+#ifndef _GLIB_API
+#define _GLIB_API
+#endif
+#ifndef _GTHREAD_API
+#define _GTHREAD_API
+#endif
+#ifndef _GMODULE_API
+#define _GMODULE_API
+#endif
+#ifndef _GOBJECT_API
+#define _GOBJECT_API
+#endif
+#ifndef _GIO_API
+#define _GIO_API
+#endif
+
 /* These macros are used to mark deprecated functions in GLib headers,
  * and thus have to be exposed in installed headers. But please
  * do *not* use them in other projects. Instead, use G_DEPRECATED
@@ -331,13 +350,13 @@
  */
 
 #ifdef GLIB_DISABLE_DEPRECATION_WARNINGS
-#define GLIB_DEPRECATED
-#define GLIB_DEPRECATED_FOR(f)
-#define GLIB_UNAVAILABLE(maj,min)
+#define GLIB_DEPRECATED _G_API
+#define GLIB_DEPRECATED_FOR(f) _G_API
+#define GLIB_UNAVAILABLE(maj,min) _G_API
 #else
-#define GLIB_DEPRECATED G_DEPRECATED
-#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
-#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min)
+#define GLIB_DEPRECATED _G_API G_DEPRECATED
+#define GLIB_DEPRECATED_FOR(f) _G_API G_DEPRECATED_FOR(f)
+#define GLIB_UNAVAILABLE(maj,min) _G_API G_UNAVAILABLE(maj,min)
 #endif
 
 #endif /* __G_MACROS_H__ */
diff --git a/glib/gversionmacros.h b/glib/gversionmacros.h
index 04718ce..60ad55c 100644
--- a/glib/gversionmacros.h
+++ b/glib/gversionmacros.h
@@ -191,84 +191,84 @@
 # define GLIB_DEPRECATED_IN_2_26                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_26_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_26
-# define GLIB_DEPRECATED_IN_2_26_FOR(f)
+# define GLIB_DEPRECATED_IN_2_26                _G_API
+# define GLIB_DEPRECATED_IN_2_26_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
 # define GLIB_AVAILABLE_IN_2_26                 GLIB_UNAVAILABLE(2, 26)
 #else
-# define GLIB_AVAILABLE_IN_2_26
+# define GLIB_AVAILABLE_IN_2_26                 _G_API
 #endif
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
 # define GLIB_DEPRECATED_IN_2_28                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_28_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_28
-# define GLIB_DEPRECATED_IN_2_28_FOR(f)
+# define GLIB_DEPRECATED_IN_2_28                _G_API
+# define GLIB_DEPRECATED_IN_2_28_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
 # define GLIB_AVAILABLE_IN_2_28                 GLIB_UNAVAILABLE(2, 28)
 #else
-# define GLIB_AVAILABLE_IN_2_28
+# define GLIB_AVAILABLE_IN_2_28                 _G_API
 #endif
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
 # define GLIB_DEPRECATED_IN_2_30                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_30_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_30
-# define GLIB_DEPRECATED_IN_2_30_FOR(f)
+# define GLIB_DEPRECATED_IN_2_30                _G_API
+# define GLIB_DEPRECATED_IN_2_30_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
 # define GLIB_AVAILABLE_IN_2_30                 GLIB_UNAVAILABLE(2, 30)
 #else
-# define GLIB_AVAILABLE_IN_2_30
+# define GLIB_AVAILABLE_IN_2_30                 _G_API
 #endif
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
 # define GLIB_DEPRECATED_IN_2_32                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_32_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_32
-# define GLIB_DEPRECATED_IN_2_32_FOR(f)
+# define GLIB_DEPRECATED_IN_2_32                _G_API
+# define GLIB_DEPRECATED_IN_2_32_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
 # define GLIB_AVAILABLE_IN_2_32                 GLIB_UNAVAILABLE(2, 32)
 #else
-# define GLIB_AVAILABLE_IN_2_32
+# define GLIB_AVAILABLE_IN_2_32                 _G_API
 #endif
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
 # define GLIB_DEPRECATED_IN_2_34                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_34_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_34
-# define GLIB_DEPRECATED_IN_2_34_FOR(f)
+# define GLIB_DEPRECATED_IN_2_34                _G_API
+# define GLIB_DEPRECATED_IN_2_34_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
 # define GLIB_AVAILABLE_IN_2_34                 GLIB_UNAVAILABLE(2, 34)
 #else
-# define GLIB_AVAILABLE_IN_2_34
+# define GLIB_AVAILABLE_IN_2_34                 _G_API
 #endif
 
 #if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36
 # define GLIB_DEPRECATED_IN_2_36                GLIB_DEPRECATED
 # define GLIB_DEPRECATED_IN_2_36_FOR(f)         GLIB_DEPRECATED_FOR(f)
 #else
-# define GLIB_DEPRECATED_IN_2_36
-# define GLIB_DEPRECATED_IN_2_36_FOR(f)
+# define GLIB_DEPRECATED_IN_2_36                _G_API
+# define GLIB_DEPRECATED_IN_2_36_FOR(f)         _G_API
 #endif
 
 #if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36
 # define GLIB_AVAILABLE_IN_2_36                 GLIB_UNAVAILABLE(2, 36)
 #else
-# define GLIB_AVAILABLE_IN_2_36
+# define GLIB_AVAILABLE_IN_2_36                 _G_API
 #endif
 
 #endif /*  __G_VERSION_MACROS_H__ */
diff --git a/gmodule/Makefile.am b/gmodule/Makefile.am
index 5e08c11..6496863 100644
--- a/gmodule/Makefile.am
+++ b/gmodule/Makefile.am
@@ -4,6 +4,8 @@ include $(top_srcdir)/Makefile.decl
 AM_CPPFLAGS = 				\
 	$(glib_INCLUDES) 		\
 	-DG_LOG_DOMAIN=\"GModule\" 	\
+	-D_GMODULE_API=G_PUBLIC_API	\
+	-D_G_API=_GMODULE_API 		\
 	@GLIB_DEBUG_FLAGS@ 		\
 	-DG_DISABLE_DEPRECATED
 
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index d7c15d1..6976e8a 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -16,7 +16,10 @@ AM_CPPFLAGS = 					\
 	-DG_LOG_DOMAIN=\"GLib-GObject\"		\
 	$(glib_INCLUDES)			\
 	$(GLIB_DEBUG_FLAGS)			\
-	-DGOBJECT_COMPILATION
+	-DGOBJECT_COMPILATION			\
+	-D_GOBJECT_API=G_PUBLIC_API		\
+	-D_G_API=_GOBJECT_API			\
+	$(NULL)
 
 gobject.def: gobject.symbols
 	$(AM_V_GEN) (echo EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DINCLUDE_INTERNAL_SYMBOLS -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gobject.symbols | $(SED) -e '/^$$/d' -e 's/^/	/' -e 's/G_GNUC_[^ ]*//g' | sort) > $(builddir)/gobject.def
diff --git a/gthread/Makefile.am b/gthread/Makefile.am
index 325fec4..e2916b8 100644
--- a/gthread/Makefile.am
+++ b/gthread/Makefile.am
@@ -4,6 +4,8 @@ include $(top_srcdir)/Makefile.decl
 AM_CPPFLAGS = 				\
 	$(glib_INCLUDES) 		\
 	-DG_LOG_DOMAIN=\"GThread\" 	\
+	-D_GTHREAD_API=G_PUBLIC_API	\
+	-D_G_API=_GTHREAD_API 		\
 	@GTHREAD_COMPILE_IMPL_DEFINES@ 	\
 	@GLIB_DEBUG_FLAGS@
 



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