Bug 847568 - (WIP) Allow building against system-wide graphite2. draft
authorJan Beich <jbeich@FreeBSD.org>
Sun, 13 Mar 2016 10:24:04 +0000
changeset 494511 75362993630e679a8105a41c6f489740c7cffebc
parent 494510 17212b7ae88f7b228dfa73dc2765070df92d42fc
child 548111 50f4bd0a0d1ce28589a33e0cd3f8fac983fb5c09
push id48043
push userbmo:jbeich@FreeBSD.org
push dateTue, 07 Mar 2017 06:46:06 +0000
bugs847568
milestone55.0a1
Bug 847568 - (WIP) Allow building against system-wide graphite2. MozReview-Commit-ID: 9JWIgcAwQnM
config/Makefile.in
config/system-headers
gfx/graphite2/moz-gr-update.sh
gfx/moz.build
gfx/thebes/moz.build
old-configure.in
toolkit/library/moz.build
toolkit/moz.configure
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -36,16 +36,17 @@ ifdef WRAP_SYSTEM_INCLUDES
 export-preqs = \
   $(call mkdir_deps,system_wrappers) \
   $(NULL)
 
 export:: $(export-preqs)
 	$(PYTHON) -m mozbuild.action.preprocessor $(DEFINES) $(ACDEFINES) \
 		-DMOZ_TREE_CAIRO=$(MOZ_TREE_CAIRO) \
 		-DMOZ_TREE_PIXMAN=$(MOZ_TREE_PIXMAN) \
+		-DMOZ_SYSTEM_GRAPHITE2=$(MOZ_SYSTEM_GRAPHITE2) \
 		-DMOZ_SYSTEM_HARFBUZZ=$(MOZ_SYSTEM_HARFBUZZ) \
 		-DMOZ_SYSTEM_HUNSPELL=$(MOZ_SYSTEM_HUNSPELL) \
 		-DMOZ_SYSTEM_BZ2=$(MOZ_SYSTEM_BZ2) \
 		-DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \
 		-DMOZ_SYSTEM_PNG=$(MOZ_SYSTEM_PNG) \
 		-DMOZ_SYSTEM_JPEG=$(MOZ_SYSTEM_JPEG) \
 		-DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \
 		-DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \
--- a/config/system-headers
+++ b/config/system-headers
@@ -1263,16 +1263,20 @@ zlib.h
 #ifdef MOZ_ENABLE_STARTUP_NOTIFICATION
 libsn/sn.h
 libsn/sn-common.h
 libsn/sn-launchee.h
 libsn/sn-launcher.h
 libsn/sn-monitor.h
 libsn/sn-util.h
 #endif
+#if MOZ_SYSTEM_GRAPHITE2==1
+graphite2/Font.h
+graphite2/Segment.h
+#endif
 #if MOZ_SYSTEM_HARFBUZZ==1
 harfbuzz/hb-glib.h
 harfbuzz/hb-ot.h
 harfbuzz/hb.h
 #endif
 #if MOZ_SYSTEM_HUNSPELL==1
 hunspell.hxx
 #endif
--- a/gfx/graphite2/moz-gr-update.sh
+++ b/gfx/graphite2/moz-gr-update.sh
@@ -1,11 +1,12 @@
 #!/bin/bash
 
 # Script used to update the Graphite2 library in the mozilla source tree
+# and bump version for --with-system-graphite2
 
 # This script lives in gfx/graphite2, along with the library source,
 # but must be run from the top level of the mozilla-central tree.
 
 # Run as
 #
 #    ./gfx/graphite2/moz-gr-update.sh RELEASE
 #
@@ -32,22 +33,26 @@ echo "This directory contains the Graphi
 echo "$TARBALL" >> gfx/graphite2/README.mozilla
 echo ""
 echo "See" $0 "for update procedure." >> gfx/graphite2/README.mozilla
 
 # fix up includes because of bug 721839 (cstdio) and bug 803066 (Windows.h)
 #find gfx/graphite2/ -name "*.cpp" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
 #find gfx/graphite2/ -name "*.h" -exec perl -p -i -e "s/<cstdio>/<stdio.h>/;s/Windows.h/windows.h/;" {} \;
 
+# chase version for --with-system-graphite2
+perl -p -i -e "s/[0-9]+\,[0-9]+\,[0-9]+/$RELEASE/ and tr/./,/ \
+  if /GR2_VERSION_REQUIRE/" old-configure.in
+
 # summarize what's been touched
 echo Updated to $RELEASE.
 echo Here is what changed in the gfx/graphite2 directory:
 echo
 
-hg stat gfx/graphite2
+hg stat old-configure.in gfx/graphite2
 
 echo
 echo If gfx/graphite2/src/files.mk has changed, please make corresponding
 echo changes to gfx/graphite2/src/moz.build
 echo
 
 echo
 echo Now use hg commands to create a patch for the mozilla tree.
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -5,28 +5,30 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files('**'):
     BUG_COMPONENT = ('Core', 'Graphics')
 
 if CONFIG['MOZ_TREE_CAIRO']:
     DIRS += ['cairo']
 
+if not CONFIG['MOZ_SYSTEM_GRAPHITE2']:
+    DIRS += ['graphite2/src' ]
+
 if not CONFIG['MOZ_SYSTEM_HARFBUZZ']:
     DIRS += ['harfbuzz/src']
 
 DIRS += [
     '2d',
     'ycbcr',
     'angle',
     'src',
     'qcms',
     'gl',
     'layers',
-    'graphite2/src',
     'ots/src',
     'thebes',
     'ipc',
     'vr',
     'config',
     'webrender_bindings',
 ]
 
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -268,16 +268,19 @@ CFLAGS += CONFIG['TK_CFLAGS']
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android'):
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
-DEFINES['GRAPHITE2_STATIC'] = True
+if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
+    CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
+else:
+    DEFINES['GRAPHITE2_STATIC'] = True
 
 if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
     CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
 
 if CONFIG['CLANG_CXX']:
     # Suppress warnings from Skia header files.
     SOURCES['gfxPlatform.cpp'].flags += ['-Wno-implicit-fallthrough']
--- a/old-configure.in
+++ b/old-configure.in
@@ -4813,16 +4813,37 @@ fi
 
 dnl ========================================================
 dnl Check if we need the 32-bit Linux SSE2 error dialog
 dnl ========================================================
 
 AC_SUBST(MOZ_LINUX_32_SSE2_STARTUP_ERROR)
 
 dnl ========================================================
+dnl Check for graphite2
+dnl ========================================================
+if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
+    dnl graphite2.pc has bogus version, check manually
+    _SAVE_CFLAGS=$CFLAGS
+    CFLAGS="$CFLAGS $MOZ_GRAPHITE2_CFLAGS"
+    AC_TRY_COMPILE([ #include <graphite2/Font.h>
+                     #define GR2_VERSION_REQUIRE(major,minor,bugfix)  \
+                             ( GR2_VERSION_MAJOR * 10000 + GR2_VERSION_MINOR \
+                               * 100 + GR2_VERSION_BUGFIX >= \
+                               (major) * 10000 + (minor) * 100 + (bugfix) )
+                   ], [
+                     #if !GR2_VERSION_REQUIRE(1,3,9)
+                     #error "Insufficient graphite2 version."
+                     #endif
+                   ], [],
+                   [AC_MSG_ERROR([--with-system-graphite2 requested but no working libgraphite2 found])])
+    CFLAGS=$_SAVE_CFLAGS
+fi
+
+dnl ========================================================
 dnl Check for pixman and cairo
 dnl ========================================================
 
 MOZ_TREE_CAIRO=1
 MOZ_ARG_ENABLE_BOOL(system-cairo,
 [  --enable-system-cairo   Use system cairo (located with pkgconfig)],
 MOZ_TREE_CAIRO=,
 MOZ_TREE_CAIRO=1 )
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -223,16 +223,19 @@ if CONFIG['SERVO_TARGET_DIR']:
         OS_LIBS += ['-L%s' % CONFIG['SERVO_TARGET_DIR'], '-lgeckoservo']
 
 if CONFIG['MOZ_SYSTEM_JPEG']:
     OS_LIBS += CONFIG['MOZ_JPEG_LIBS']
 
 if CONFIG['MOZ_SYSTEM_PNG']:
     OS_LIBS += CONFIG['MOZ_PNG_LIBS']
 
+if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
+    OS_LIBS += CONFIG['MOZ_GRAPHITE2_LIBS']
+
 if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
     OS_LIBS += CONFIG['MOZ_HARFBUZZ_LIBS']
 
 if CONFIG['MOZ_SYSTEM_HUNSPELL']:
     OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS']
 
 if CONFIG['MOZ_SYSTEM_LIBEVENT']:
     OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -338,16 +338,26 @@ def ft2_info(freetype2_combined_info, tr
         return freetype2_combined_info
 
 set_config('FT2_LIBS', delayed_getattr(ft2_info, 'libs'))
 add_old_configure_assignment('FT2_LIBS',
                              delayed_getattr(ft2_info, 'libs'))
 add_old_configure_assignment('FT2_CFLAGS',
                              delayed_getattr(ft2_info, 'cflags'))
 
+# Graphite2
+# ==============================================================
+option('--with-system-graphite2',
+       help="Use system graphite2 (located with pkgconfig)")
+
+system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2',
+                                     when='--with-system-graphite2')
+
+set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True))
+
 # HarfBuzz
 # ==============================================================
 option('--with-system-harfbuzz',
        help="Use system harfbuzz (located with pkgconfig)")
 
 system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 1.4.2',
                                     when='--with-system-harfbuzz')