[gjs] build: If cairo isn't found, don't build the tests with it



commit df1bc34cbade66c03c2e07d17191ab1501e74f6e
Author: Colin Walters <walters verbum org>
Date:   Mon Jan 7 13:47:53 2013 -0500

    build: If cairo isn't found, don't build the tests with it
    
    This is a followup to the previous work which allowed us to build
    without cairo - now we can run the tests too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=691307

 Makefile-test.am |   28 ++++++++++++++++++----------
 configure.ac     |    3 ---
 test/gjs-unit.c  |    2 ++
 3 files changed, 20 insertions(+), 13 deletions(-)
---
diff --git a/Makefile-test.am b/Makefile-test.am
index 8b36024..286b100 100644
--- a/Makefile-test.am
+++ b/Makefile-test.am
@@ -2,9 +2,7 @@ RUN_WITH_DBUS = ${top_srcdir}/test/run-with-dbus --session --system
 GTESTER = ${TESTS_ENVIRONMENT} ${RUN_WITH_DBUS} gtester
 
 ########################################################################
-if ENABLE_TESTS
 TEST_PROGS += gjs-tests
-endif
 
 gjs_tests_CFLAGS =				\
 	$(AM_CFLAGS)				\
@@ -22,9 +20,7 @@ gjs_tests_LDADD =		\
 gjs_tests_SOURCES =		\
 	test/gjs-tests.c
 
-if ENABLE_TESTS
 TEST_PROGS += gjs-unit
-endif
 
 gjs_unit_CPPFLAGS =		\
 	$(AM_CPPFLAGS)          \
@@ -41,15 +37,22 @@ gjs_unit_SOURCES =	\
 	test/gjs-unit.c
 
 # noinst_ always builds a static library
-if ENABLE_TESTS
 testlib_LTLIBRARIES = libregress.la libwarnlib.la libgimarshallingtests.la
 testlibdir = $(prefix)/unused
 install-testlibLTLIBRARIES: # prevent it from being installed
-endif
 
 nodist_libregress_la_SOURCES = $(GI_DATADIR)/tests/regress.c $(GI_DATADIR)/tests/regress.h
-libregress_la_CFLAGS = $(GJS_CFLAGS) $(GJS_CAIRO_CFLAGS)
-libregress_la_LDFLAGS = -avoid-version $(GJS_LIBS) $(GJS_CAIRO_LIBS)
+libregress_la_CPPFLAGS =
+libregress_la_CFLAGS = $(GJS_CFLAGS)
+libregress_la_LDFLAGS = -avoid-version $(GJS_LIBS)
+libregress_scannerflags_includes = --include=Gio-2.0
+if ENABLE_CAIRO
+libregress_la_CFLAGS += $(GJS_CAIRO_CFLAGS)
+libregress_la_LDFLAGS +=  $(GJS_CAIRO_LIBS)
+libregress_scannerflags_includes += --include=cairo-1.0
+else
+libregress_la_CPPFLAGS += -D_GI_DISABLE_CAIRO
+endif
 nodist_libwarnlib_la_SOURCES = $(GI_DATADIR)/tests/warnlib.c $(GI_DATADIR)/tests/warnlib.h
 libwarnlib_la_CFLAGS = $(GJS_CFLAGS)
 libwarnlib_la_LDFLAGS = -avoid-version $(GJS_LIBS)
@@ -59,7 +62,8 @@ libgimarshallingtests_la_LDFLAGS = -avoid-version $(GJS_LIBS)
 
 # g-i doesn't ship these as shared libraries anymore; we build them here
 Regress-1.0.gir: libregress.la Makefile
-	$(AM_V_GEN) LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(FIREFOX_JS_LIBDIR)" g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \
+	$(AM_V_GEN) LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(FIREFOX_JS_LIBDIR)" g-ir-scanner $(libregress_scannerflags_includes) \
+	$(libregress_la_CPPFLAGS) \
 	--namespace=Regress --nsversion=1.0 \
 	--warn-all --warn-error \
 	--library=libregress.la \
@@ -73,7 +77,7 @@ CLEANFILES += Regress-1.0.gir Regress-1.0.typelib
 
 # g-i doesn't ship these as shared libraries anymore; we build them here
 WarnLib-1.0.gir: libwarnlib.la Makefile
-	$(AM_V_GEN) g-ir-scanner --include=cairo-1.0 --include=Gio-2.0 \
+	$(AM_V_GEN) g-ir-scanner --include=Gio-2.0 \
 	--namespace=WarnLib --nsversion=1.0 \
 	--identifier-prefix=WarnLib_ \
 	--symbol-prefix=warnlib_ \
@@ -112,6 +116,10 @@ TESTS_ENVIRONMENT =							\
 	LD_LIBRARY_PATH="$(LD_LIBRARY_PATH):$(FIREFOX_JS_LIBDIR)"	\
 	G_FILENAME_ENCODING=latin1	# ensure filenames are not utf8
 
+if !ENABLE_CAIRO
+TESTS_ENVIRONMENT += GJS_TEST_SKIP_CAIRO=1
+endif
+
 tests_dependencies = $(gjsnative_LTLIBRARIES) ${TEST_PROGS} Regress-1.0.typelib WarnLib-1.0.typelib GIMarshallingTests-1.0.typelib
 
 test: $(tests_dependencies)
diff --git a/configure.ac b/configure.ac
index b4a9fd9..72e946a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,9 +117,6 @@ AS_IF([test x$with_cairo = xyes], [
 AM_CONDITIONAL(ENABLE_CAIRO, test x$with_cairo = xyes)
 PKG_CHECK_MODULES([GJS_GDBUS], [$gjs_gdbus_packages])
 
-AC_ARG_ENABLE(tests,[  --disable-tests           disable test libraries ], enable_tests=$enableval,enable_tests=yes)
-AM_CONDITIONAL(ENABLE_TESTS, test x$with_cairo = xyes && test x$enable_tests = xyes)
-
 PKG_CHECK_MODULES([GJSTESTS], [$gjstests_packages])
 
 GI_DATADIR=$($PKG_CONFIG --variable=gidatadir gobject-introspection-1.0)
diff --git a/test/gjs-unit.c b/test/gjs-unit.c
index b70a0da..3ae68ba 100644
--- a/test/gjs-unit.c
+++ b/test/gjs-unit.c
@@ -266,6 +266,8 @@ main(int argc, char **argv)
             g_free(name);
             continue;
         }
+        if (g_str_has_prefix (name, "testCairo") && g_getenv ("GJS_TEST_SKIP_CAIRO"))
+            continue;
 
         /* pretty print, drop 'test' prefix and '.js' suffix from test name */
         test_name = g_strconcat("/js/", name + 4, NULL);



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