Bug 847568 - Allow building against system-wide graphite2/harfbuzz. r?jfkthame r?glandium draft
authorJan Beich <jbeich@FreeBSD.org>
Sun, 13 Mar 2016 10:24:04 +0000
changeset 339847 1240830f5bf734456496cb8bddcdc84a2f9655fb
parent 339846 bd503f57d6ce867e0ce927e4f5aa85268bd049a0
child 339848 13e8c5082ff3f1803e2eb4a75819c485ed9a4c19
push id12805
push userjbeich@FreeBSD.org
push dateSun, 13 Mar 2016 10:57:20 +0000
reviewersjfkthame, glandium
bugs847568
milestone48.0a1
Bug 847568 - Allow building against system-wide graphite2/harfbuzz. r?jfkthame r?glandium MozReview-Commit-ID: 9JWIgcAwQnM
build/moz.configure/old.configure
config/Makefile.in
config/system-headers
dom/base/moz.build
gfx/graphite2/moz-gr-update.sh
gfx/harfbuzz/README-mozilla
gfx/moz.build
gfx/skia/generate_mozbuild.py
gfx/skia/moz.build
gfx/thebes/moz.build
intl/unicharutil/util/moz.build
netwerk/dns/moz.build
old-configure.in
toolkit/library/moz.build
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -333,16 +333,18 @@ def old_configure_options(*options):
     '--with-nspr-libs',
     '--with-pthreads',
     '--with-qemu-exe',
     '--with-qtdir',
     '--with-servo',
     '--with-sixgill',
     '--with-soft-float',
     '--with-system-bz2',
+    '--with-system-graphite2',
+    '--with-system-harfbuzz',
     '--with-system-icu',
     '--with-system-jpeg',
     '--with-system-libevent',
     '--with-system-libvpx',
     '--with-system-nspr',
     '--with-system-nss',
     '--with-system-png',
     '--with-system-zlib',
--- a/config/Makefile.in
+++ b/config/Makefile.in
@@ -44,16 +44,18 @@ export:: $(export-preqs)
 		-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) \
 		-DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \
+		-DMOZ_SYSTEM_GRAPHITE2=$(MOZ_SYSTEM_GRAPHITE2) \
+		-DMOZ_SYSTEM_HARFBUZZ=$(MOZ_SYSTEM_HARFBUZZ) \
 		$(srcdir)/system-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers
 	$(INSTALL) system_wrappers $(DIST)
 
 GARBAGE_DIRS += system_wrappers
 endif
 
 ifdef WRAP_STL_INCLUDES
 ifdef GNU_CXX
--- a/config/system-headers
+++ b/config/system-headers
@@ -1339,8 +1339,16 @@ unicode/udatpg.h
 unicode/uenum.h
 unicode/unorm.h
 unicode/unum.h
 unicode/ustring.h
 unicode/utypes.h
 #endif
 libutil.h
 unwind.h
+#if MOZ_SYSTEM_GRAPHITE2==1
+graphite2/Font.h
+graphite2/Segment.h
+#endif
+#if MOZ_SYSTEM_HARFBUZZ==1
+harfbuzz/hb-ot.h
+harfbuzz/hb.h
+#endif
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -392,16 +392,19 @@ SOURCES += [
 ]
 
 # Are we targeting x86-32 or x86-64?  If so, we want to include SSE2 code for
 # nsTextFragment.cpp
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES += ['nsTextFragmentSSE2.cpp']
     SOURCES['nsTextFragmentSSE2.cpp'].flags += CONFIG['SSE2_FLAGS']
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    SOURCES['nsContentUtils.cpp'].flags += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 EXTRA_COMPONENTS += [
     'ConsoleAPI.manifest',
     'ConsoleAPIStorage.js',
     'contentAreaDropListener.js',
     'contentAreaDropListener.manifest',
     'messageWakeupService.js',
     'messageWakeupService.manifest',
     'SlowScriptDebug.js',
--- 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/harfbuzz/README-mozilla
+++ b/gfx/harfbuzz/README-mozilla
@@ -13,8 +13,13 @@ this files when updating harfbuzz, and c
 The normal approach to updating harfbuzz, therefore, is to pull the latest HB
 source into a scratch directory and do a local build; then copy the original
 sources AND the generated headers mentioned above from the build directory into
 the mozilla tree.
 
 In addition, the src/Makefile.in file here is NOT from upstream, nor is it
 generated from src/Makefile.am (the original harfbuzz version); it is a mozilla-
 specific makefile that is maintained by hand.
+
+The in-tree copy may be omitted during build by --with-system-harfbuzz.
+Make sure to keep pkg-config version check within old-configure.in in sync
+with checkout version or increment latest tag by one if it's not based
+on upstream release.
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -2,26 +2,30 @@
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 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',
-    'harfbuzz/src',
     'ots/src',
     'thebes',
     'ipc',
     'vr',
 ]
 
 if CONFIG['MOZ_ENABLE_SKIA']:
     DIRS += ['skia']
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -129,16 +129,19 @@ if CONFIG['GNU_CXX'] and not CONFIG['CLA
 if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
     CXXFLAGS += [
         '-Wno-implicit-fallthrough',
         '-Wno-inconsistent-missing-override',
         '-Wno-macro-redefined',
         '-Wno-unused-private-field',
     ]
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
     CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 """
 
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -747,14 +747,17 @@ if CONFIG['GNU_CXX'] and not CONFIG['CLA
 if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
     CXXFLAGS += [
         '-Wno-implicit-fallthrough',
         '-Wno-inconsistent-missing-override',
         '-Wno-macro-redefined',
         '-Wno-unused-private-field',
     ]
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'android', 'gonk', 'qt'):
     CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -302,13 +302,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'andr
     # top of the android java runtime.
     DEFINES['MOZ_USING_ANDROID_JAVA_WIDGETS'] = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3', 'qt'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 
-DEFINES['GRAPHITE2_STATIC'] = True
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
+if CONFIG['MOZ_SYSTEM_GRAPHITE2']:
+    CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
+else:
+    DEFINES['GRAPHITE2_STATIC'] = True
 
 if CONFIG['CLANG_CXX']:
     # Suppress warnings from Skia header files.
     SOURCES['gfxPlatform.cpp'].flags += ['-Wno-implicit-fallthrough']
--- a/intl/unicharutil/util/moz.build
+++ b/intl/unicharutil/util/moz.build
@@ -39,9 +39,12 @@ if CONFIG['_MSC_VER']:
     CFLAGS += ['-Zl']
     CXXFLAGS += ['-Zl']
 
 if CONFIG['ENABLE_INTL_API']:
     CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
     LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
     USE_LIBS += ['icu']
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 DIST_INSTALL = True
--- a/netwerk/dns/moz.build
+++ b/netwerk/dns/moz.build
@@ -61,16 +61,19 @@ etld_data = GENERATED_FILES['etld_data.i
 etld_data.script = 'prepare_tlds.py'
 etld_data.inputs = ['effective_tld_names.dat']
 
 # need to include etld_data.inc
 LOCAL_INCLUDES += [
     '/netwerk/base',
 ]
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' and CONFIG['ANDROID_VERSION'] > '19':
     LOCAL_INCLUDES += ['%' + '%s/bionic/libc/dns/include' % CONFIG['ANDROID_SOURCE']]
 
 if CONFIG['ENABLE_INTL_API']:
     DEFINES['IDNA2008'] = True
     CXXFLAGS += CONFIG['MOZ_ICU_CFLAGS']
     CFLAGS += CONFIG['MOZ_ICU_CFLAGS']
     LOCAL_INCLUDES += CONFIG['MOZ_ICU_INCLUDES']
--- a/old-configure.in
+++ b/old-configure.in
@@ -7859,16 +7859,59 @@ if test "$USE_FC_FREETYPE"; then
         else
             FT2_CFLAGS="$FT2_CFLAGS $_FONTCONFIG_CFLAGS"
             FT2_LIBS="$FT2_LIBS $_FONTCONFIG_LIBS"
         fi
     ])
 fi
 
 dnl ========================================================
+dnl Check for harfbuzz
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-harfbuzz,
+[  --with-system-harfbuzz  Use system harfbuzz (located with pkgconfig)],
+MOZ_SYSTEM_HARFBUZZ=1,
+MOZ_SYSTEM_HARFBUZZ=)
+
+if test -n "$MOZ_SYSTEM_HARFBUZZ"; then
+    PKG_CHECK_MODULES(MOZ_HARFBUZZ, harfbuzz >= 1.2.2)
+fi
+
+AC_SUBST(MOZ_SYSTEM_HARFBUZZ)
+
+dnl ========================================================
+dnl Check for graphite2
+dnl ========================================================
+
+MOZ_ARG_WITH_BOOL(system-graphite2,
+[  --with-system-graphite2 Use system graphite2 (located with pkgconfig)],
+MOZ_SYSTEM_GRAPHITE2=1,
+MOZ_SYSTEM_GRAPHITE2=)
+
+if test -n "$MOZ_SYSTEM_GRAPHITE2"; then
+    PKG_CHECK_MODULES(MOZ_GRAPHITE2, graphite2)
+
+    dnl graphite2.pc has bogus version, check manually
+    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,6)
+                     #error "Insufficient graphite2 version."
+                     #endif
+                   ], [],
+                   [AC_MSG_ERROR([--with-system-graphite2 requested but no working libgraphite2 found])])
+fi
+
+AC_SUBST(MOZ_SYSTEM_GRAPHITE2)
+
+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
@@ -227,16 +227,22 @@ if CONFIG['MOZ_SYSTEM_LIBEVENT']:
     OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS']
 
 if CONFIG['MOZ_SYSTEM_LIBVPX']:
     OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS']
 
 if not CONFIG['MOZ_TREE_PIXMAN']:
     OS_LIBS += CONFIG['MOZ_PIXMAN_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_ALSA']:
     OS_LIBS += CONFIG['MOZ_ALSA_LIBS']
 
 if CONFIG['HAVE_CLOCK_MONOTONIC']:
     OS_LIBS += CONFIG['REALTIME_LIBS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     OS_LIBS += [