File 0020-Bug-847568-Support-system-graphite2.patch of Package MozillaFirefox

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Thomas Deutschmann <whissi@gentoo.org>
Date: Mon, 6 Apr 2020 19:34:44 +0200
Subject: [PATCH] Bug 847568 -  Support system graphite2

Allow building against system-wide graphite2.

Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=847568
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
---
 config/system-headers.mozbuild     |  6 ++++++
 gfx/graphite2/geckoextra/moz.build | 21 +++++++++++++++++++++
 gfx/moz.build                      |  6 +++++-
 gfx/thebes/moz.build               |  5 ++++-
 toolkit/library/moz.build          |  3 +++
 toolkit/moz.configure              | 13 +++++++++++++
 6 files changed, 52 insertions(+), 2 deletions(-)
 create mode 100644 gfx/graphite2/geckoextra/moz.build

diff --git a/config/system-headers.mozbuild b/config/system-headers.mozbuild
index 2e23b36d2eb2b291cdc6baac4896c22db87b60b8..74e4a2fb02dd368ac79e2043d1963669aa066138 100644
--- a/config/system-headers.mozbuild
+++ b/config/system-headers.mozbuild
@@ -1279,6 +1279,12 @@ if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
         "harfbuzz/hb.h",
     ]
 
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    system_headers += [
+        "graphite2/Font.h",
+        "graphite2/Segment.h",
+    ]
+
 if CONFIG["MOZ_JACK"]:
     system_headers += [
         "jack/jack.h",
diff --git a/gfx/graphite2/geckoextra/moz.build b/gfx/graphite2/geckoextra/moz.build
new file mode 100644
index 0000000000000000000000000000000000000000..ed0323eba9d5b2b4afa24d0cccd9138fe5d25b62
--- /dev/null
+++ b/gfx/graphite2/geckoextra/moz.build
@@ -0,0 +1,21 @@
+# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# 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/.
+
+EXPORTS.graphite2 += [
+    'include/GraphiteExtra.h',
+    'include/GraphiteStructsForRLBox.h',
+]
+
+UNIFIED_SOURCES += [
+    '../geckoextra/src/GraphiteExtra.cpp',
+]
+
+CXXFLAGS += CONFIG['MOZ_GRAPHITE2_CFLAGS']
+
+# Match bundled graphite2 configuration
+AllowCompilerWarnings()
+
+FINAL_LIBRARY = 'xul'
diff --git a/gfx/moz.build b/gfx/moz.build
index 6cc19f84709bbe3be4ff830e3a6dd29189048c6f..14b08dbac3e3f5d3df421d5dd6840673046d0486 100644
--- a/gfx/moz.build
+++ b/gfx/moz.build
@@ -10,6 +10,11 @@ with Files("**"):
 with Files("wr/**"):
     BUG_COMPONENT = ("Core", "Graphics: WebRender")
 
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    DIRS += ["graphite2/geckoextra"]
+else:
+    DIRS += ["graphite2/src"]
+
 if not CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
     DIRS += ["harfbuzz/src"]
 
@@ -22,7 +27,6 @@ DIRS += [
     "qcms",
     "gl",
     "layers",
-    "graphite2/src",
     "ots/src",
     "thebes",
     "ipc",
diff --git a/gfx/thebes/moz.build b/gfx/thebes/moz.build
index 13886d3babf52cbd6ecd88f3a4c388d2aa298475..4219986abdb513b522c4c01d9a9ce03ba8535106 100644
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -298,7 +298,10 @@ 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"]
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index feff2f6448f1c146c613ffba04e0b6d309d889f9..3763ec421fca6db9dad6729712eb88408c14478d 100644
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -289,6 +289,9 @@ if CONFIG["MOZ_ANDROID_GOOGLE_VR"]:
         "-lgvr",
     ]
 
+if CONFIG["MOZ_SYSTEM_GRAPHITE2"]:
+    OS_LIBS += CONFIG["MOZ_GRAPHITE2_LIBS"]
+
 if CONFIG["MOZ_SYSTEM_HARFBUZZ"]:
     OS_LIBS += CONFIG["MOZ_HARFBUZZ_LIBS"]
 
diff --git a/toolkit/moz.configure b/toolkit/moz.configure
index 521325d7ddd659357a49961b5fcebef952eba087..29e7d4cdde50cfb57d2a9a5900cd6cb928549d54 100644
--- a/toolkit/moz.configure
+++ b/toolkit/moz.configure
@@ -831,6 +831,19 @@ def freetype2_combined_info(fontconfig_info, freetype2_info):
 
 set_define("MOZ_HAVE_FREETYPE2", depends_if(freetype2_info)(lambda _: True))
 
+# Graphite2
+# ==============================================================
+option('--with-system-graphite2', help="Use system graphite2 (located with pkgconfig)")
+
+@depends('--with-system-graphite2')
+def check_for_graphite2(value):
+    return bool(value)
+
+system_graphite2 = pkg_check_modules('MOZ_GRAPHITE2', 'graphite2',
+                                     when=check_for_graphite2)
+
+set_config('MOZ_SYSTEM_GRAPHITE2', depends_if(system_graphite2)(lambda _: True))
+
 # HarfBuzz
 # ==============================================================
 option('--with-system-harfbuzz', help="Use system harfbuzz (located with pkgconfig)")
openSUSE Build Service is sponsored by