From 8e64027b6b188d4c016fc8ca427965d1a2560687 Mon Sep 17 00:00:00 2001 From: AwesomeAdam54321 Date: Wed, 21 Dec 2022 14:37:57 +0800 Subject: [PATCH 2/3] icecat-use-system-graphite2+harfbuzz Allow building against system-wide graphite2/harfbuzz. See Based on: https://svnweb.freebsd.org/ports/head/www/firefox-esr/files/patch-bug847568?revision=472833&view=co Modified for use with patch -p1, and to apply cleanly to GNU IceCat. --- config/system-headers.mozbuild | 13 +++++++++++++ dom/base/moz.build | 3 +++ gfx/graphite2/moz-gr-update.sh | 7 ++++++- gfx/moz.build | 8 ++++++-- gfx/skia/generate_mozbuild.py | 3 +++ gfx/skia/moz.build | 3 +++ gfx/thebes/moz.build | 8 +++++++- intl/unicharutil/util/moz.build | 3 +++ netwerk/dns/moz.build | 3 +++ old-configure.in | 21 +++++++++++++++++++++ toolkit/library/moz.build | 6 ++++++ toolkit/moz.configure | 28 ++++++++++++++++++++++++++++ 12 files changed, 102 insertions(+), 4 deletions(-) diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild index 9c07dba2..5594d659 100644 --- a/config/system-headers.mozbuild +++ b/config/system-headers.mozbuild @@ -1293,6 +1293,19 @@ if CONFIG['MOZ_ENABLE_LIBPROXY']: 'proxy.h', ] +if CONFIG['MOZ_SYSTEM_GRAPHITE2']: + system_headers += [ + 'graphite2/Font.h', + 'graphite2/Segment.h', + ] + +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + system_headers += [ + 'harfbuzz/hb-glib.h', + 'harfbuzz/hb-ot.h', + 'harfbuzz/hb.h', + ] + if CONFIG['MOZ_SYSTEM_LIBVPX']: system_headers += [ 'vpx_mem/vpx_mem.h', diff --git a/dom/base/moz.build b/dom/base/moz.build index 229e06a5..64961efc 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -577,6 +577,9 @@ FINAL_LIBRARY = "xul" if CONFIG["MOZ_WIDGET_TOOLKIT"] == "gtk": CXXFLAGS += CONFIG["MOZ_GTK3_CFLAGS"] +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] + GeneratedFile( "UseCounterList.h", script="gen-usecounters.py", diff --git a/gfx/graphite2/moz-gr-update.sh b/gfx/graphite2/moz-gr-update.sh index b91d9c16..a97e6eb2 100755 --- a/gfx/graphite2/moz-gr-update.sh +++ b/gfx/graphite2/moz-gr-update.sh @@ -1,6 +1,7 @@ #!/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. @@ -37,12 +38,16 @@ echo "See" $0 "for update procedure." >> gfx/graphite2/README.mozilla #find gfx/graphite2/ -name "*.cpp" -exec perl -p -i -e "s///;s/Windows.h/windows.h/;" {} \; #find gfx/graphite2/ -name "*.h" -exec perl -p -i -e "s///;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 diff --git a/gfx/moz.build b/gfx/moz.build index 4d6d63da..41017975 100644 --- a/gfx/moz.build +++ b/gfx/moz.build @@ -19,8 +19,6 @@ DIRS += [ "qcms", "gl", "layers", - "graphite2/src", - "harfbuzz/src", "ots/src", "thebes", "ipc", @@ -34,6 +32,12 @@ DIRS += [ if CONFIG["ENABLE_TESTS"]: DIRS += ["tests/gtest"] +if not CONFIG['MOZ_SYSTEM_GRAPHITE2']: + DIRS += ['graphite2/src' ] + +if not CONFIG['MOZ_SYSTEM_HARFBUZZ']: + DIRS += ['harfbuzz/src'] + TEST_DIRS += ["tests"] SPHINX_TREES["/gfx"] = "docs" diff --git a/gfx/skia/generate_mozbuild.py b/gfx/skia/generate_mozbuild.py index 5e0fd17d..860b80af 100755 --- a/gfx/skia/generate_mozbuild.py +++ b/gfx/skia/generate_mozbuild.py @@ -96,6 +96,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): '-Wno-unused-private-field', ] +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] + if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'android'): LOCAL_INCLUDES += [ "/gfx/cairo/cairo/src", diff --git a/gfx/skia/moz.build b/gfx/skia/moz.build index 524bd28d..615c93b2 100755 --- a/gfx/skia/moz.build +++ b/gfx/skia/moz.build @@ -488,6 +488,9 @@ if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'): '-Wno-unused-private-field', ] +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] + if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'android'): LOCAL_INCLUDES += [ "/gfx/cairo/cairo/src", diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build index 248aa36b..83233c10 100644 --- a/gfx/thebes/moz.build +++ b/gfx/thebes/moz.build @@ -284,7 +284,13 @@ if CONFIG["MOZ_WAYLAND"]: 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["CC_TYPE"] in ("clang", "clang-cl"): # Suppress warnings from Skia header files. diff --git a/intl/unicharutil/util/moz.build b/intl/unicharutil/util/moz.build index b5292072..c19632eb 100644 --- a/intl/unicharutil/util/moz.build +++ b/intl/unicharutil/util/moz.build @@ -34,6 +34,9 @@ GeneratedFile( GeneratedFile("IsCombiningDiacritic.h", script="is_combining_diacritic.py", force=True) +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] + FINAL_LIBRARY = "xul" REQUIRES_UNIFIED_BUILD = True diff --git a/netwerk/dns/moz.build b/netwerk/dns/moz.build index 5d81059e..746d69d1 100644 --- a/netwerk/dns/moz.build +++ b/netwerk/dns/moz.build @@ -96,6 +96,9 @@ IPDL_SOURCES = [ include("/ipc/chromium/chromium-config.mozbuild") +if CONFIG['MOZ_SYSTEM_HARFBUZZ']: + CXXFLAGS += CONFIG['MOZ_HARFBUZZ_CFLAGS'] + FINAL_LIBRARY = "xul" GeneratedFile( diff --git a/old-configure.in b/old-configure.in index ab6f435b..46723226 100644 --- a/old-configure.in +++ b/old-configure.in @@ -1136,6 +1136,27 @@ 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 + #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,10) + #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 cairo dnl ======================================================== diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index 51af6bcd..3e46b99e 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -297,6 +297,12 @@ if CONFIG["MOZ_SYSTEM_JPEG"]: 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_WEBP"]: OS_LIBS += CONFIG["MOZ_WEBP_LIBS"] diff --git a/toolkit/moz.configure b/toolkit/moz.configure index cc6e3c3f..f376fc95 100644 --- a/toolkit/moz.configure +++ b/toolkit/moz.configure @@ -568,6 +568,34 @@ def fc_freetype(value, toolkit): add_old_configure_assignment("USE_FC_FREETYPE", fc_freetype) set_define("USE_FC_FREETYPE", fc_freetype) +# Graphite2 +# ============================================================== +option('--with-system-graphite2', + help="Use system graphite2 (located with pkgconfig)") + +@depends("--with-system-graphite2") +def graphite2(value): + return bool(value) + +system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2', + when=graphite2) + +set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True)) + +# HarfBuzz +# ============================================================== +option('--with-system-harfbuzz', + help="Use system harfbuzz (located with pkgconfig)") + +@depends("--with-system-harfbuzz") +def harfbuzz(value): + return bool(value) + +system_harfbuzz = pkg_check_modules('MOZ_HARFBUZZ', 'harfbuzz >= 1.7.4', + when=harfbuzz) + +set_config('MOZ_SYSTEM_HARFBUZZ', depends_if(system_harfbuzz)(lambda _: True)) + # Pango # ============================================================== pkg_check_modules("MOZ_PANGO", "pango >= 1.22.0", when=toolkit_gtk) -- 2.38.1