Support building with older glib versions
authorMike Hommey <mh@glandium.org>
Fri, 30 Sep 2016 09:15:37 +0000 (18:15 +0900)
committerBehdad Esfahbod <behdad@behdad.org>
Sun, 18 Dec 2016 07:37:07 +0000 (01:37 -0600)
It is desirable to be able to build against older versions of glib.

fd7a245 changed the configure check to require glib > 2.38 for
G_TEST_DIST. Before that, version 2.16 was required, but in fact,
since aafe395, G_PASTE is being used, which was introduced in 2.19.1.
And since 0ef179e2, hb-glib uses GBytes, which were introduced in
2.31.10.

2.19.1 is rather old, but 2.38 is rather new. For Firefox, building
against 2.22 is still supported, although we could probably get away
with bumping that to 2.28. Either way, GBytes is not available.

Arguably, if you build against a glib that doesn't support GBytes,
you're not going to use the hb_glib_blob_create function, so we hide
the function when building against such a glib.

As for G_TEST_DIST, when building against versions of glib that don't
support it, we can fallback to the previous behavior, which, AIUI, was
just making the test not work when building in a separate directory.

configure.ac
src/hb-glib.cc
src/hb-glib.h
test/api/test-ot-math.c

index 6948aa6..f985e10 100644 (file)
@@ -147,7 +147,7 @@ AC_ARG_WITH(glib,
                        [Use glib @<:@default=auto@:>@])],,
        [with_glib=auto])
 have_glib=false
-GLIB_DEPS="glib-2.0 >= 2.38"
+GLIB_DEPS="glib-2.0 >= 2.19.1"
 AC_SUBST(GLIB_DEPS)
 if test "x$with_glib" = "xyes" -o "x$with_glib" = "xauto"; then
        PKG_CHECK_MODULES(GLIB, $GLIB_DEPS, have_glib=true, :)
index e203524..2b91b5b 100644 (file)
@@ -382,6 +382,7 @@ hb_glib_get_unicode_funcs (void)
   return const_cast<hb_unicode_funcs_t *> (&_hb_glib_unicode_funcs);
 }
 
+#if GLIB_CHECK_VERSION(2,31,10)
 /**
  * hb_glib_blob_create:
  *
@@ -398,3 +399,4 @@ hb_glib_blob_create (GBytes *gbytes)
                         g_bytes_ref (gbytes),
                         (hb_destroy_func_t) g_bytes_unref);
 }
+#endif
index 12c3e3b..5f04183 100644 (file)
@@ -46,9 +46,10 @@ hb_glib_script_from_script (hb_script_t script);
 HB_EXTERN hb_unicode_funcs_t *
 hb_glib_get_unicode_funcs (void);
 
+#if GLIB_CHECK_VERSION(2,31,10)
 HB_EXTERN hb_blob_t *
 hb_glib_blob_create (GBytes *gbytes);
-
+#endif
 
 HB_END_DECLS
 
index 5f4ccb7..049656a 100644 (file)
@@ -54,7 +54,11 @@ cleanupFreeType (void)
 static void
 openFont(const char* fontFile)
 {
+#if GLIB_CHECK_VERSION(2,37,2)
   gchar* path = g_test_build_filename(G_TEST_DIST, fontFile, NULL);
+#else
+  gchar* path = g_strdup(fontFile);
+#endif
 
   FT_Error ft_error;
   if ((ft_error = FT_New_Face (ft_library, path, 0, &ft_face))) {