[gobject-introspection] Clean up cairo handling somewhat



commit f5631640751b5a998b3616db78dd5dcd9ee62126
Author: Colin Walters <walters verbum org>
Date:   Mon Jan 7 12:57:17 2013 -0500

    Clean up cairo handling somewhat
    
    I'm building on RHEL6 which doesn't have cairo-gobject.  Now, we
    tried to support this in that 'make' would succeed, but 'make check'
    would blow up.
    
    This patch allows more of 'make check' to succeed - I just need to
    figure out how to make the diff against the -expected.gir work.
    
    What's more important though, is this will allow gjs to also #define
    _GI_DISABLE_CAIRO.

 configure.ac              |   24 ++++++++++--------------
 tests/scanner/Makefile.am |   21 +++++++++++++++++----
 tests/scanner/regress.c   |    7 ++++++-
 tests/scanner/regress.h   |    6 +++++-
 4 files changed, 38 insertions(+), 20 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 37380be..96b3675 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,24 +131,20 @@ PKG_CHECK_MODULES(GIO, [gio-2.0])
 PKG_CHECK_MODULES(GIO_UNIX, [gio-unix-2.0], have_gio_unix=true, have_gio_unix=false)
 AM_CONDITIONAL(HAVE_GIO_UNIX, test x$have_gio_unix = xtrue)
 
-AC_ARG_ENABLE(tests,
-	AS_HELP_STRING([--disable-tests], [disable test libraries]),
-	enable_tests=$enableval,
-	enable_tests=maybe)
+# Prefer cairo-gobject if we have it
+AC_ARG_WITH(cairo,
+	    AS_HELP_STRING([--with-cairo], [Use cairo @<:@default=maybe@:>@]),
+	    [], [with_cairo=maybe])
 
-AS_IF([test x${enable_tests} != xno], [
+AS_IF([test x${with_cairo} != xno], [
   PKG_CHECK_MODULES(CAIRO, [cairo cairo-gobject], have_cairo=yes, have_cairo=no)
-  AS_IF([test x$have_cairo != xyes], [
-    AS_IF([ test x$enable_tests = xmaybe ], [
-      enable_tests=no
-    ], [
-      AC_MSG_ERROR([Tests enabled but cairo not found; pass --disable-tests or install cairo])
-    ])
-  ], [
-    enable_tests=yes
+  AS_IF([ test x$have_cairo = xyes && test x$with_cairo = xmaybe ], [
+    have_cairo=no
+  ], [ test x$have_cairo = xno && test x$with_cairo = xyes ], [
+    AC_MSG_ERROR([cairo enabled but not found])
   ])
 ])
-AM_CONDITIONAL(BUILD_TESTS, test x$enable_tests != xno)
+AM_CONDITIONAL(HAVE_CAIRO, test x$have_cairo = xyes)
 
 case "$host" in
   *-*-darwin*)
diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am
index e600146..2753c50 100644
--- a/tests/scanner/Makefile.am
+++ b/tests/scanner/Makefile.am
@@ -36,7 +36,10 @@ libfoo_la_LIBADD = $(top_builddir)/libgirepository-1.0.la
 libutility_la_SOURCES = $(srcdir)/utility.c $(srcdir)/utility.h
 libgtkfrob_la_SOURCES = $(srcdir)/gtkfrob.c $(srcdir)/gtkfrob.h
 libregress_la_SOURCES = $(srcdir)/regress.c $(srcdir)/regress.h
-libregress_la_LIBADD = $(GIO_LIBS) $(CAIRO_LIBS)
+libregress_la_LIBADD = $(GIO_LIBS)
+if HAVE_CAIRO
+libregress_la_LIBADD += $(CAIRO_LIBS)
+endif
 libwarnlib_la_CFLAGS = $(AM_CFLAGS)
 libwarnlib_la_SOURCES = $(srcdir)/warnlib.c $(srcdir)/warnlib.h
 libwarnlib_la_LIBADD = $(GIO_LIBS)
@@ -46,7 +49,14 @@ libgettype_la_SOURCES = $(srcdir)/gettype.c $(srcdir)/gettype.h
 testsdir = $(datadir)/gobject-introspection-1.0/tests
 tests_DATA = $(libregress_la_SOURCES) $(libwarnlib_la_SOURCES)
 
-libregress_la_CFLAGS = $(AM_CFLAGS) $(CAIRO_CFLAGS)
+libregress_la_CPPFLAGS =
+if !HAVE_CAIRO
+libregress_la_CPPFLAGS += -D_GI_DISABLE_CAIRO
+endif
+libregress_la_CFLAGS = $(AM_CFLAGS)
+if HAVE_CAIRO
+libregress_la_CFLAGS += $(CAIRO_CFLAGS)
+endif
 libregress_la_LDFLAGS = $(AM_LDFLAGS)
 
 
@@ -72,9 +82,12 @@ GIRS += SLetter-1.0.gir
 
 Regress-1.0.gir: $(top_builddir)/Gio-2.0.gir libregress.la
 Regress_1_0_gir_LIBS = libregress.la
-Regress_1_0_gir_INCLUDES = cairo-1.0 Gio-2.0
+Regress_1_0_gir_INCLUDES = Gio-2.0
+if HAVE_CAIRO
+Regress_1_0_gir_INCLUDES += cairo-1.0 
+endif
 Regress_1_0_gir_FILES = $(libregress_la_SOURCES)
-Regress_1_0_gir_SCANNERFLAGS = --c-include="regress.h" --warn-error
+Regress_1_0_gir_SCANNERFLAGS = --c-include="regress.h" --warn-error $(libregress_la_CPPFLAGS)
 GIRS += Regress-1.0.gir
 
 WarnLib-1.0.gir: $(top_builddir)/Gio-2.0.gir libwarnlib.la
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 06089c3..89dc873 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -3,7 +3,6 @@
 #include <stdlib.h>
 #include <glib-object.h>
 #include <gobject/gvaluecollector.h>
-#include <cairo-gobject.h>
 
 #include "regress.h"
 
@@ -285,6 +284,7 @@ regress_test_value_return(int i)
 /************************************************************************/
 /* foreign structs */
 
+#ifndef _GI_DISABLE_CAIRO
 /**
  * regress_test_cairo_context_full_return:
  *
@@ -365,6 +365,7 @@ regress_test_cairo_surface_full_out (cairo_surface_t **surface)
 {
   *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 10, 10);
 }
+#endif
 
 /**
  * regress_test_gvariant_i:
@@ -2298,6 +2299,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
 		  1,
 		  G_TYPE_OBJECT);
 
+#ifndef _GI_DISABLE_CAIRO
    /**
    * RegressTestObj::sig-with-foreign-struct:
    * @self: an object
@@ -2314,6 +2316,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
 		  G_TYPE_NONE,
 		  1,
 		  CAIRO_GOBJECT_TYPE_CONTEXT);
+#endif
 
   regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_FIRST] =
     g_signal_new ("first",
@@ -2620,6 +2623,7 @@ regress_test_obj_emit_sig_with_obj (RegressTestObj *obj)
     g_object_unref (obj_param);
 }
 
+#ifndef _GI_DISABLE_CAIRO
 void
 regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj)
 {
@@ -2627,6 +2631,7 @@ regress_test_obj_emit_sig_with_foreign_struct (RegressTestObj *obj)
   g_signal_emit_by_name (obj, "sig-with-foreign-struct", cr);
   cairo_destroy (cr);
 }
+#endif
 
 void
 regress_test_obj_emit_sig_with_int64 (RegressTestObj *obj)
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index d8a3002..f243a14 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -1,7 +1,9 @@
 #ifndef __GITESTTYPES_H__
 #define __GITESTTYPES_H__
 
-#include <cairo.h>
+#ifndef _GI_DISABLE_CAIRO
+#include <cairo-gobject.h>
+#endif
 #include <glib-object.h>
 #include <gio/gio.h>
 #include <time.h>
@@ -129,6 +131,7 @@ int regress_test_int_value_arg(const GValue *v);
 const GValue *regress_test_value_return(int i);
 
 /* foreign structs */
+#ifndef _GI_DISABLE_CAIRO
 cairo_t *regress_test_cairo_context_full_return (void);
 void regress_test_cairo_context_none_in (cairo_t *context);
 
@@ -136,6 +139,7 @@ cairo_surface_t *regress_test_cairo_surface_none_return (void);
 cairo_surface_t *regress_test_cairo_surface_full_return (void);
 void regress_test_cairo_surface_none_in (cairo_surface_t *surface);
 void regress_test_cairo_surface_full_out (cairo_surface_t **surface);
+#endif
 
 /* versioning (deprecated, since, stability) */
 void regress_test_versioning (void);



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