mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
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
This commit is contained in:
parent
216d4d619d
commit
b390e41325
@ -32,6 +32,8 @@ AM_CPPFLAGS = \
|
|||||||
$(gmodule_INCLUDES) \
|
$(gmodule_INCLUDES) \
|
||||||
$(GLIB_DEBUG_FLAGS) \
|
$(GLIB_DEBUG_FLAGS) \
|
||||||
-DGIO_COMPILATION \
|
-DGIO_COMPILATION \
|
||||||
|
-D_GIO_API=G_PUBLIC_API \
|
||||||
|
-D_G_API=_GIO_API \
|
||||||
-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"
|
-DGIO_MODULE_DIR=\"$(GIO_MODULE_DIR)\"
|
||||||
|
|
||||||
lib_LTLIBRARIES = libgio-2.0.la
|
lib_LTLIBRARIES = libgio-2.0.la
|
||||||
|
@ -47,6 +47,8 @@ AM_CPPFLAGS = \
|
|||||||
-DG_LOG_DOMAIN=\"GLib\" \
|
-DG_LOG_DOMAIN=\"GLib\" \
|
||||||
$(GLIB_DEBUG_FLAGS) \
|
$(GLIB_DEBUG_FLAGS) \
|
||||||
-DGLIB_COMPILATION \
|
-DGLIB_COMPILATION \
|
||||||
|
-D_GLIB_API=G_PUBLIC_API \
|
||||||
|
-D_G_API=_GLIB_API \
|
||||||
-DPCRE_STATIC
|
-DPCRE_STATIC
|
||||||
|
|
||||||
glib.def: glib.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
|
glib.def: glib.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
|
||||||
|
@ -324,6 +324,25 @@
|
|||||||
#define G_UNAVAILABLE(maj,min)
|
#define G_UNAVAILABLE(maj,min)
|
||||||
#endif
|
#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,
|
/* These macros are used to mark deprecated functions in GLib headers,
|
||||||
* and thus have to be exposed in installed headers. But please
|
* and thus have to be exposed in installed headers. But please
|
||||||
* do *not* use them in other projects. Instead, use G_DEPRECATED
|
* do *not* use them in other projects. Instead, use G_DEPRECATED
|
||||||
@ -331,13 +350,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS
|
#ifdef GLIB_DISABLE_DEPRECATION_WARNINGS
|
||||||
#define GLIB_DEPRECATED
|
#define GLIB_DEPRECATED _G_API
|
||||||
#define GLIB_DEPRECATED_FOR(f)
|
#define GLIB_DEPRECATED_FOR(f) _G_API
|
||||||
#define GLIB_UNAVAILABLE(maj,min)
|
#define GLIB_UNAVAILABLE(maj,min) _G_API
|
||||||
#else
|
#else
|
||||||
#define GLIB_DEPRECATED G_DEPRECATED
|
#define GLIB_DEPRECATED _G_API G_DEPRECATED
|
||||||
#define GLIB_DEPRECATED_FOR(f) G_DEPRECATED_FOR(f)
|
#define GLIB_DEPRECATED_FOR(f) _G_API G_DEPRECATED_FOR(f)
|
||||||
#define GLIB_UNAVAILABLE(maj,min) G_UNAVAILABLE(maj,min)
|
#define GLIB_UNAVAILABLE(maj,min) _G_API G_UNAVAILABLE(maj,min)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __G_MACROS_H__ */
|
#endif /* __G_MACROS_H__ */
|
||||||
|
@ -191,84 +191,84 @@
|
|||||||
# define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_26 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_26_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_26
|
# define GLIB_DEPRECATED_IN_2_26 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_26_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_26_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_26
|
||||||
# define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE(2, 26)
|
# define GLIB_AVAILABLE_IN_2_26 GLIB_UNAVAILABLE(2, 26)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_26
|
# define GLIB_AVAILABLE_IN_2_26 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
|
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_28
|
||||||
# define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_28 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_28_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_28
|
# define GLIB_DEPRECATED_IN_2_28 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_28_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_28_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_28
|
||||||
# define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE(2, 28)
|
# define GLIB_AVAILABLE_IN_2_28 GLIB_UNAVAILABLE(2, 28)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_28
|
# define GLIB_AVAILABLE_IN_2_28 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
|
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_30
|
||||||
# define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_30 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_30_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_30
|
# define GLIB_DEPRECATED_IN_2_30 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_30_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_30_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_30
|
||||||
# define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE(2, 30)
|
# define GLIB_AVAILABLE_IN_2_30 GLIB_UNAVAILABLE(2, 30)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_30
|
# define GLIB_AVAILABLE_IN_2_30 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
|
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_32
|
||||||
# define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_32 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_32_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_32
|
# define GLIB_DEPRECATED_IN_2_32 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_32_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_32_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_32
|
||||||
# define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE(2, 32)
|
# define GLIB_AVAILABLE_IN_2_32 GLIB_UNAVAILABLE(2, 32)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_32
|
# define GLIB_AVAILABLE_IN_2_32 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
|
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_34
|
||||||
# define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_34 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_34_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_34
|
# define GLIB_DEPRECATED_IN_2_34 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_34_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_34_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_34
|
||||||
# define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE(2, 34)
|
# define GLIB_AVAILABLE_IN_2_34 GLIB_UNAVAILABLE(2, 34)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_34
|
# define GLIB_AVAILABLE_IN_2_34 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36
|
#if GLIB_VERSION_MIN_REQUIRED >= GLIB_VERSION_2_36
|
||||||
# define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED
|
# define GLIB_DEPRECATED_IN_2_36 GLIB_DEPRECATED
|
||||||
# define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_36_FOR(f) GLIB_DEPRECATED_FOR(f)
|
||||||
#else
|
#else
|
||||||
# define GLIB_DEPRECATED_IN_2_36
|
# define GLIB_DEPRECATED_IN_2_36 _G_API
|
||||||
# define GLIB_DEPRECATED_IN_2_36_FOR(f)
|
# define GLIB_DEPRECATED_IN_2_36_FOR(f) _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36
|
#if GLIB_VERSION_MAX_ALLOWED < GLIB_VERSION_2_36
|
||||||
# define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE(2, 36)
|
# define GLIB_AVAILABLE_IN_2_36 GLIB_UNAVAILABLE(2, 36)
|
||||||
#else
|
#else
|
||||||
# define GLIB_AVAILABLE_IN_2_36
|
# define GLIB_AVAILABLE_IN_2_36 _G_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* __G_VERSION_MACROS_H__ */
|
#endif /* __G_VERSION_MACROS_H__ */
|
||||||
|
@ -6,6 +6,8 @@ BUILT_SOURCES =
|
|||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
$(glib_INCLUDES) \
|
$(glib_INCLUDES) \
|
||||||
-DG_LOG_DOMAIN=\"GModule\" \
|
-DG_LOG_DOMAIN=\"GModule\" \
|
||||||
|
-D_GMODULE_API=G_PUBLIC_API \
|
||||||
|
-D_G_API=_GMODULE_API \
|
||||||
@GLIB_DEBUG_FLAGS@ \
|
@GLIB_DEBUG_FLAGS@ \
|
||||||
-DG_DISABLE_DEPRECATED
|
-DG_DISABLE_DEPRECATED
|
||||||
|
|
||||||
|
@ -16,7 +16,10 @@ AM_CPPFLAGS = \
|
|||||||
-DG_LOG_DOMAIN=\"GLib-GObject\" \
|
-DG_LOG_DOMAIN=\"GLib-GObject\" \
|
||||||
$(glib_INCLUDES) \
|
$(glib_INCLUDES) \
|
||||||
$(GLIB_DEBUG_FLAGS) \
|
$(GLIB_DEBUG_FLAGS) \
|
||||||
-DGOBJECT_COMPILATION
|
-DGOBJECT_COMPILATION \
|
||||||
|
-D_GOBJECT_API=G_PUBLIC_API \
|
||||||
|
-D_G_API=_GOBJECT_API \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
gobject.def: gobject.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
|
gobject.def: gobject.symbols $(top_builddir)/glib/glibconfig.h $(top_srcdir)/glib/process-symbol-file.sh Makefile
|
||||||
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
|
$(AM_V_GEN) env GLIB_DEBUG_FLAGS="$(GLIB_DEBUG_FLAGS)" $(top_srcdir)/glib/process-symbol-file.sh $< $@
|
||||||
|
@ -4,6 +4,8 @@ include $(top_srcdir)/Makefile.decl
|
|||||||
AM_CPPFLAGS = \
|
AM_CPPFLAGS = \
|
||||||
$(glib_INCLUDES) \
|
$(glib_INCLUDES) \
|
||||||
-DG_LOG_DOMAIN=\"GThread\" \
|
-DG_LOG_DOMAIN=\"GThread\" \
|
||||||
|
-D_GTHREAD_API=G_PUBLIC_API \
|
||||||
|
-D_G_API=_GTHREAD_API \
|
||||||
@GTHREAD_COMPILE_IMPL_DEFINES@ \
|
@GTHREAD_COMPILE_IMPL_DEFINES@ \
|
||||||
@GLIB_DEBUG_FLAGS@
|
@GLIB_DEBUG_FLAGS@
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user