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 422757 b5f24e0c0373ec9b29acf2033a61be133ca1c2fd
parent 422670 a835589ae0c63a2d91be150d80b5fc600e44b447
child 533343 7492a34d59ebbeabff1c58a4443b6d4fdc87ada6
push id31779
push userbmo:jbeich@FreeBSD.org
push dateSat, 08 Oct 2016 17:51:46 +0000
reviewersjfkthame, glandium
bugs847568
milestone52.0a1
Bug 847568 - Allow building against system-wide graphite2/harfbuzz. r=jfkthame r?glandium MozReview-Commit-ID: 9JWIgcAwQnM
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
moz.configure
netwerk/dns/moz.build
old-configure.in
toolkit/library/moz.build
--- 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 $(srcdir)/stl-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
@@ -1328,8 +1328,17 @@ unicode/uenum.h
 unicode/unorm.h
 unicode/unum.h
 unicode/ustring.h
 unicode/utypes.h
 #endif
 libutil.h
 unwind.h
 fenv.h
+#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
--- a/dom/base/moz.build
+++ b/dom/base/moz.build
@@ -455,16 +455,19 @@ for var in ('MOZ_B2G_RIL', 'MOZ_B2G_FM')
         DEFINES[var] = True
 
 if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
     DEFINES['HAVE_SIDEBAR'] = True
 
 if CONFIG['MOZ_X11']:
     CXXFLAGS += CONFIG['TK_CFLAGS']
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 GENERATED_FILES += [
     'PropertyUseCounterMap.inc',
     'UseCounterList.h',
 ]
 
 countermap = GENERATED_FILES['PropertyUseCounterMap.inc']
 countermap.script = 'gen-usecounters.py:property_map'
 countermap.inputs = ['UseCounters.conf']
--- 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
@@ -17,8 +17,13 @@ this file when updating harfbuzz, and ch
 
 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 header mentioned above from the build directory into
 the mozilla tree.
 
 If the collection of source files changes, manual updates to moz.build may be
 needed, as we don't use the upstream makefiles.
+
+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',
     'config',
 ]
 
 if CONFIG['MOZ_ENABLE_SKIA']:
--- a/gfx/skia/generate_mozbuild.py
+++ b/gfx/skia/generate_mozbuild.py
@@ -136,16 +136,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'):
     CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 """
 
--- a/gfx/skia/moz.build
+++ b/gfx/skia/moz.build
@@ -668,14 +668,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'):
     CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -281,13 +281,19 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('and
     CXXFLAGS += CONFIG['CAIRO_FT_CFLAGS']
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk2', 'gtk3'):
     CXXFLAGS += CONFIG['MOZ_PANGO_CFLAGS']
 
 LOCAL_INCLUDES += CONFIG['SKIA_INCLUDES']
 LOCAL_INCLUDES += ['/media/libyuv/include']
 
-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
@@ -37,9 +37,12 @@ if CONFIG['_MSC_VER']:
     DEFINES['_USE_ANSI_CPP'] = True
     # Don't include directives about which CRT to use
     CFLAGS += ['-Zl']
     CXXFLAGS += ['-Zl']
 
 if CONFIG['ENABLE_INTL_API']:
     USE_LIBS += ['icu']
 
+if CONFIG['MOZ_SYSTEM_HARFBUZZ']:
+    CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS']
+
 DIST_INSTALL = True
--- a/moz.configure
+++ b/moz.configure
@@ -260,16 +260,40 @@ def extra_programs(target):
 
 check_prog('DSYMUTIL', delayed_getattr(extra_programs, 'DSYMUTIL'),
            allow_missing=True)
 check_prog('GENISOIMAGE', delayed_getattr(extra_programs, 'GENISOIMAGE'),
            allow_missing=True)
 check_prog('RPMBUILD', delayed_getattr(extra_programs, 'RPMBUILD'),
            allow_missing=True)
 
+option('--with-system-graphite2',
+       help="Use system graphite2 (located with pkgconfig)")
+
+@depends('--with-system-graphite2', compile_environment)
+def check_for_graphite2(value, compile_env):
+    return value and compile_env
+
+system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2',
+                                    check_for_graphite2)
+
+set_config('MOZ_SYSTEM_GRAPHITE2', system_graphite2)
+
+option('--with-system-harfbuzz',
+       help="Use system harfbuzz (located with pkgconfig)")
+
+@depends('--with-system-harfbuzz', compile_environment)
+def check_for_harfbuzz(value, compile_env):
+    return value and compile_env
+
+system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 1.2.6',
+                                    check_for_harfbuzz)
+
+set_config('MOZ_SYSTEM_HARFBUZZ', system_harfbuzz)
+
 option('--enable-system-hunspell',
        help="Use system hunspell (located with pkgconfig)")
 
 @depends('--enable-system-hunspell', compile_environment)
 def check_for_hunspell(value, compile_env):
     return value and compile_env
 
 system_hunspell = pkg_check_modules('MOZ_HUNSPELL', 'hunspell',
--- 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['ENABLE_INTL_API']:
     DEFINES['IDNA2008'] = True
     USE_LIBS += ['icu']
 else:
     UNIFIED_SOURCES += [
         'nameprep.c',
     ]
 
--- a/old-configure.in
+++ b/old-configure.in
@@ -5203,16 +5203,37 @@ 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 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,8)
+                     #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
@@ -226,16 +226,22 @@ 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']
 
 if CONFIG['MOZ_SYSTEM_LIBVPX']:
     OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS']