commit:     9e5d8576d295164bc6dc9873e68ed94fd46968cf
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 10 05:13:32 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Nov 10 05:14:03 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=9e5d8576

media-libs/harfbuzz: backport fix for icu/freetype detection

Bug: https://bugs.gentoo.org/830966
Closes: https://bugs.gentoo.org/880405
Closes: https://bugs.gentoo.org/880479
Thanks-to: Eli Schwartz <eschwartz93 <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 .../files/harfbuzz-5.3.1-meson-freetype-icu.patch  | 120 +++++++++++++++++++++
 media-libs/harfbuzz/harfbuzz-5.3.1-r1.ebuild       | 104 ++++++++++++++++++
 2 files changed, 224 insertions(+)

diff --git a/media-libs/harfbuzz/files/harfbuzz-5.3.1-meson-freetype-icu.patch 
b/media-libs/harfbuzz/files/harfbuzz-5.3.1-meson-freetype-icu.patch
new file mode 100644
index 000000000000..3e0a7beece9c
--- /dev/null
+++ b/media-libs/harfbuzz/files/harfbuzz-5.3.1-meson-freetype-icu.patch
@@ -0,0 +1,120 @@
+https://bugs.gentoo.org/880479
+https://bugs.gentoo.org/880405
+https://github.com/harfbuzz/harfbuzz/pull/3870
+
+From 2c14943fb06ffd6de4e270454501ff5d305ede6e Mon Sep 17 00:00:00 2001
+From: Eli Schwartz <[email protected]>
+Date: Tue, 8 Nov 2022 16:24:08 -0500
+Subject: [PATCH] meson: fix regression in detecting freetype2/icu-uc when
+ explicitly disabled
+
+In #3811 / commit 53a194aa3f5f7de0b40e879e41fcbe0de6e9fefe a broken and
+half-implemented approach to kind of sort of handling the detection of
+both pkg-config and cmake names for dependencies, was implemented. It
+just checked for both versions with required: false, but when the build
+was configured with *disabled* options, it was still found because it
+was treated as auto.
+
+Really, the problem here is trying to outsmart Meson, which handles a
+lot of edge cases correctly. But it's possible, albeit very wordy, to
+manually implement Meson's internal logic via if/else fallbacks. Do so
+here.
+--- a/meson.build
++++ b/meson.build
+@@ -83,20 +83,35 @@ check_funcs = [
+ 
+ m_dep = cpp.find_library('m', required: false)
+ 
+-
+-# Try pkgconfig name
+-freetype_dep = dependency('freetype2', required: false)
+-if not freetype_dep.found()
+-  # Try cmake name
+-  freetype_dep = dependency('freetype', required: false)
+-endif
+-if not freetype_dep.found()
+-  # Subproject fallback, `allow_fallback: true` means the fallback will be
+-  # tried even if the freetype option is set to `auto`.
+-  freetype_dep = dependency('freetype2',
++if meson.version().version_compare('>=0.60.0')
++  # pkg-config: freetype2, cmake: Freetype
++  freetype_dep = dependency('freetype2', 'Freetype',
+                             required: get_option('freetype'),
+                             default_options: ['harfbuzz=disabled'],
+                             allow_fallback: true)
++else
++  # painful hack to handle multiple dependencies but also respect options
++  freetype_opt = get_option('freetype')
++  # we want to handle enabled manually after fallbacks, but also handle 
disabled normally
++  if freetype_opt.enabled()
++    freetype_opt = false
++  endif
++  # try pkg-config name
++  freetype_dep = dependency('freetype2', method: 'pkg-config', required: 
freetype_opt)
++  # when disabled, leave it not-found
++  if not freetype_dep.found() and not get_option('freetype').disabled()
++    # Try cmake name
++    freetype_dep = dependency('Freetype', method: 'cmake', required: false)
++    # Subproject fallback, `allow_fallback: true` means the fallback will be
++    # tried even if the freetype option is set to `auto`.
++    if not freetype_dep.found()
++      freetype_dep = dependency('freetype2',
++                                method: 'pkg-config',
++                                required: get_option('freetype'),
++                                default_options: ['harfbuzz=disabled'],
++                                allow_fallback: true)
++    endif
++  endif
+ endif
+ 
+ glib_dep = dependency('glib-2.0', required: get_option('glib'))
+@@ -104,18 +119,36 @@ gobject_dep = dependency('gobject-2.0', required: 
get_option('gobject'))
+ graphite2_dep = dependency('graphite2', required: get_option('graphite2'))
+ graphite_dep = dependency('graphite2', required: get_option('graphite'))
+ 
+-# Try pkgconfig name
+-icu_dep = dependency('icu-uc', required: false)
+-if not icu_dep.found()
+-  # Try cmake name
+-  icu_dep = dependency('ICU',
+-                       required: false,
+-                       components: 'uc',
+-                       method: 'cmake')
+-endif
+-if not icu_dep.found()
+-  # Subproject fallback if icu option is enabled
+-  icu_dep = dependency('icu-uc', required: get_option('icu'))
++if meson.version().version_compare('>=0.60.0')
++  # pkg-config: icu-uc, cmake: ICU but with components
++  icu_dep = dependency('icu-uc', 'ICU',
++                            components: 'uc',
++                            required: get_option('icu'),
++                            default_options: ['harfbuzz=disabled'],
++                            allow_fallback: true)
++else
++  # painful hack to handle multiple dependencies but also respect options
++  icu_opt = get_option('icu')
++  # we want to handle enabled manually after fallbacks, but also handle 
disabled normally
++  if icu_opt.enabled()
++    icu_opt = false
++  endif
++  # try pkg-config name
++  icu_dep = dependency('icu-uc', method: 'pkg-config', required: icu_opt)
++  # when disabled, leave it not-found
++  if not icu_dep.found() and not get_option('icu').disabled()
++    # Try cmake name
++    icu_dep = dependency('ICU', method: 'cmake', components: 'uc', required: 
false)
++    # Try again with subproject fallback. `allow_fallback: true` means the
++    # fallback will be tried even if the icu option is set to `auto`, but
++    # we cannot pass this option until Meson 0.59.0, because no wrap file
++    # is checked into git.
++    if not icu_dep.found()
++      icu_dep = dependency('icu-uc',
++                           method: 'pkg-config',
++                           required: get_option('icu'))
++    endif
++  endif
+ endif
+ 
+ if icu_dep.found() and icu_dep.type_name() == 'pkgconfig'
+

diff --git a/media-libs/harfbuzz/harfbuzz-5.3.1-r1.ebuild 
b/media-libs/harfbuzz/harfbuzz-5.3.1-r1.ebuild
new file mode 100644
index 000000000000..fe93f48bc581
--- /dev/null
+++ b/media-libs/harfbuzz/harfbuzz-5.3.1-r1.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{8..11} )
+
+inherit flag-o-matic meson-multilib python-any-r1 xdg-utils
+
+DESCRIPTION="An OpenType text shaping engine"
+HOMEPAGE="https://www.freedesktop.org/wiki/Software/HarfBuzz";
+
+if [[ ${PV} = 9999 ]] ; then
+       EGIT_REPO_URI="https://github.com/harfbuzz/harfbuzz.git";
+       inherit git-r3
+else
+       
SRC_URI="https://github.com/harfbuzz/harfbuzz/releases/download/${PV}/${P}.tar.xz";
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~loong ~m68k ~mips ~ppc 
~ppc64 ~riscv ~s390 ~sparc ~x86 ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos 
~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+fi
+
+LICENSE="Old-MIT ISC icu"
+# 0.9.18 introduced the harfbuzz-icu split; bug #472416
+# 3.0.0 dropped some unstable APIs; bug #813705
+SLOT="0/4.0.0"
+
+IUSE="+cairo debug doc experimental +glib +graphite icu +introspection test 
+truetype"
+RESTRICT="!test? ( test )"
+REQUIRED_USE="introspection? ( glib )"
+
+RDEPEND="
+       cairo? ( x11-libs/cairo:= )
+       glib? ( >=dev-libs/glib-2.38:2[${MULTILIB_USEDEP}] )
+       graphite? ( >=media-gfx/graphite2-1.2.1:=[${MULTILIB_USEDEP}] )
+       icu? ( >=dev-libs/icu-51.2-r1:=[${MULTILIB_USEDEP}] )
+       introspection? ( >=dev-libs/gobject-introspection-1.34:= )
+       truetype? ( >=media-libs/freetype-2.5.0.1:2=[${MULTILIB_USEDEP}] )
+"
+DEPEND="${RDEPEND}
+       >=dev-libs/gobject-introspection-common-1.34
+"
+BDEPEND="
+       ${PYTHON_DEPS}
+       virtual/pkgconfig
+       doc? ( dev-util/gtk-doc )
+       introspection? ( dev-util/glib-utils )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-meson-freetype-icu.patch
+)
+
+pkg_setup() {
+       python-any-r1_pkg_setup
+       if ! use debug ; then
+               append-cppflags -DHB_NDEBUG
+       fi
+}
+
+src_prepare() {
+       default
+
+       xdg_environment_reset
+
+       # bug #726120
+       sed -i \
+               -e '/tests\/macos\.tests/d' \
+               test/shape/data/in-house/Makefile.sources \
+               || die
+
+       # bug #618772
+       append-cxxflags -std=c++14
+
+       # bug #790359
+       filter-flags -fexceptions -fthreadsafe-statics
+
+       # bug #762415
+       local pyscript
+       for pyscript in $(find -type f -name "*.py") ; do
+               python_fix_shebang -q "${pyscript}"
+       done
+}
+
+multilib_src_configure() {
+       # harfbuzz-gobject only used for introspection, bug #535852
+       local emesonargs=(
+               -Dcoretext="disabled"
+               -Dchafa="disabled"
+
+               $(meson_feature glib)
+               $(meson_feature graphite graphite2)
+               $(meson_feature icu)
+               $(meson_feature introspection gobject)
+               $(meson_feature test tests)
+               $(meson_feature truetype freetype)
+
+               $(meson_native_use_feature cairo)
+               $(meson_native_use_feature doc docs)
+               $(meson_native_use_feature introspection)
+
+               $(meson_use experimental experimental_api)
+       )
+
+       meson_src_configure
+}

Reply via email to