Support building with older glib versions

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.
This commit is contained in:
Mike Hommey 2016-09-30 18:15:37 +09:00 committed by Behdad Esfahbod
parent ad273881c5
commit 1c98ff87c7
4 changed files with 9 additions and 2 deletions

View 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, :)

View 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

View 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

View 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))) {