From 31a9726506668184e0a3b0044cf74a08fe219c0e Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 28 Nov 2013 12:34:45 +0000 Subject: [PATCH] build: fix building introspection data This fixes the build with --enable-introspection. I'm not sure why g-ir-scanner seems to parse all public headers in isolation instead of being able take a more limited list of top-level public headers and automatically parse all necessary #include directives but this means we have to special case how we define and undefine __COGL_H_INSIDE__ to subvert the guards we have in place for detecting misuse of the headers. Reviewed-by: Neil Roberts (cherry picked from commit e0b2255876c1cf11d124d5ae37cbe9a6e43777f1) --- cogl/Makefile.am | 2 +- cogl/cogl-gles2.h | 20 ++++++++++++++++++++ cogl/cogl-wayland-client.h | 19 +++++++++++++++++++ cogl/cogl-wayland-server.h | 20 ++++++++++++++++++++ cogl/cogl-xlib-renderer.h | 21 +++++++++++++++++++++ cogl/cogl-xlib.h | 27 ++++++++++++++++++++++++++- cogl/cogl.h | 16 ++++++++++++++++ cogl/winsys/cogl-texture-pixmap-x11.h | 20 ++++++++++++++++++++ 8 files changed, 143 insertions(+), 2 deletions(-) diff --git a/cogl/Makefile.am b/cogl/Makefile.am index 9e8483642..90c0c2eb3 100644 --- a/cogl/Makefile.am +++ b/cogl/Makefile.am @@ -673,7 +673,7 @@ Cogl_1_0_gir_FILES += \ $(top_srcdir)/cogl-path/cogl-path-types.h \ $(top_srcdir)/cogl-path/cogl1-path-functions.h endif -Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API +Cogl_1_0_gir_CFLAGS = $(AM_CPPFLAGS) $(COGL_DEP_CFLAGS) -UCOGL_ENABLE_EXPERIMENTAL_API -UCOGL_ENABLE_EXPERIMENTAL_2_0_API -UCOGL_COMPILATION -D__COGL_H_INSIDE__ -D__COGL_XLIB_H_INSIDE__ Cogl_1_0_gir_INCLUDES = GL-1.0 GObject-2.0 Cogl_1_0_gir_EXPORT_PACKAGES = cogl-1.0 Cogl_1_0_gir_SCANNERFLAGS = --warn-all --c-include='cogl/cogl.h' diff --git a/cogl/cogl-gles2.h b/cogl/cogl-gles2.h index 1fc4bc43d..265db4668 100644 --- a/cogl/cogl-gles2.h +++ b/cogl/cogl-gles2.h @@ -36,9 +36,16 @@ * api definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#endif /* COGL_COMPILATION */ + #include #include #include @@ -379,5 +386,18 @@ cogl_is_gles2_context (void *object); COGL_END_DECLS +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ +#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif + #endif /* __COGL_GLES2_H__ */ diff --git a/cogl/cogl-wayland-client.h b/cogl/cogl-wayland-client.h index a211a1f01..095d82936 100644 --- a/cogl/cogl-wayland-client.h +++ b/cogl/cogl-wayland-client.h @@ -31,9 +31,28 @@ * definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#endif /* COGL_COMPILATION */ #include +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ +#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif + #endif /* __COGL_WAYLAND_CLIENT_H */ diff --git a/cogl/cogl-wayland-server.h b/cogl/cogl-wayland-server.h index a8897b28b..39da86c55 100644 --- a/cogl/cogl-wayland-server.h +++ b/cogl/cogl-wayland-server.h @@ -33,9 +33,16 @@ * definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#endif /* COGL_COMPILATION */ + #include #include @@ -98,4 +105,17 @@ cogl_wayland_texture_2d_update_area (CoglTexture2D *texture, COGL_END_DECLS +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ +#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif + #endif /* __COGL_WAYLAND_SERVER_H */ diff --git a/cogl/cogl-xlib-renderer.h b/cogl/cogl-xlib-renderer.h index 569beaa87..e5b25dd12 100644 --- a/cogl/cogl-xlib-renderer.h +++ b/cogl/cogl-xlib-renderer.h @@ -37,8 +37,16 @@ * definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_XLIB_RENDERER_H_MUST_UNDEF_COGL_H_INSIDE__ #endif + +#endif /* COGL_COMPILATION */ + #include COGL_BEGIN_DECLS @@ -158,4 +166,17 @@ cogl_xlib_renderer_get_display (CoglRenderer *renderer); COGL_END_DECLS +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_XLIB_RENDERER_H_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ +#undef __COGL_XLIB_RENDERER_H_MUST_UNDEF_COGL_H_INSIDE__ +#endif + #endif /* __COGL_XLIB_RENDERER_H__ */ diff --git a/cogl/cogl-xlib.h b/cogl/cogl-xlib.h index 53f4b5f55..d94a0e086 100644 --- a/cogl/cogl-xlib.h +++ b/cogl/cogl-xlib.h @@ -33,10 +33,22 @@ * definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_XLIB_H_INSIDE__ */ +#ifndef __COGL_XLIB_H_INSIDE__ #define __COGL_XLIB_H_INSIDE__ -#define __COGL_H_INSIDE__ #endif +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ +#define __COGL_H_INSIDE__ +#define __COGL_XLIB_H_MUST_UNDEF_COGL_H_INSIDE__ +#endif + +#endif /* COGL_COMPILATION */ + #include #include #include @@ -97,6 +109,19 @@ cogl_xlib_handle_event (XEvent *xevent); COGL_END_DECLS + +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_XLIB_H_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ #undef __COGL_XLIB_H_INSIDE__ +#undef __COGL_XLIB_H_MUST_UNDEF_COGL_H_INSIDE__ +#endif #endif /* __COGL_XLIB_H__ */ diff --git a/cogl/cogl.h b/cogl/cogl.h index bb9b7ec74..940b7ddc2 100644 --- a/cogl/cogl.h +++ b/cogl/cogl.h @@ -29,7 +29,12 @@ #error " shouldn't be included internally" #endif +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif #ifdef COGL_ENABLE_EXPERIMENTAL_2_0_API #ifndef COGL_ENABLE_EXPERIMENTAL_API @@ -159,6 +164,17 @@ * General utility functions for COGL. */ +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__ #undef __COGL_H_INSIDE__ +#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif #endif /* __COGL_H__ */ diff --git a/cogl/winsys/cogl-texture-pixmap-x11.h b/cogl/winsys/cogl-texture-pixmap-x11.h index 6f0daf549..babf596e3 100644 --- a/cogl/winsys/cogl-texture-pixmap-x11.h +++ b/cogl/winsys/cogl-texture-pixmap-x11.h @@ -31,9 +31,16 @@ * definitions */ #ifndef COGL_COMPILATION + +/* Note: When building Cogl .gir we explicitly define + * __COGL_H_INSIDE__ */ +#ifndef __COGL_H_INSIDE__ #define __COGL_H_INSIDE__ +#define __COGL_MUST_UNDEF_COGL_H_INSIDE__ #endif +#endif /* COGL_COMPILATION */ + #include COGL_BEGIN_DECLS @@ -195,4 +202,17 @@ cogl_is_texture_pixmap_x11 (void *object); COGL_END_DECLS +/* The gobject introspection scanner seems to parse public headers in + * isolation which means we need to be extra careful about how we + * define and undefine __COGL_H_INSIDE__ used to detect when internal + * headers are incorrectly included by developers. In the gobject + * introspection case we have to manually define __COGL_H_INSIDE__ as + * a commandline argument for the scanner which means we must be + * careful not to undefine it in a header... + */ +#ifdef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#undef __COGL_H_INSIDE__ +#undef __COGL_MUST_UNDEF_COGL_H_INSIDE__ +#endif + #endif /* __COGL_TEXTURE_PIXMAP_X11_H */