pkgname=harfbuzz
pkgver=12.2.0
pkgdesc="OpenType text shaping engine"
homepage="https://harfbuzz.github.io/"
arch=(x86_64)
license=(MIT)
depends=(
  freetype
  glib
  glibc
  graphite
)
makedepends=(
  gobject-introspection
  help2man
  icu
  meson
  python
)
sources=("${pkgname}-${pkgver}.tar.xz")
urls=("https://github.com/harfbuzz/harfbuzz/releases/download/${pkgver}/${sources[0]}")
md5sums=("d9c0c102a1595e718fd5bbb0e4497594")

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
}

src_build() {
  local meson_args=(
    --prefix=/usr
    --buildtype=release
    --wrap-mode=nodownload
    -D cpp_std=c++17
    -D coretext=disabled
    -D chafa=disabled
    -D fontations=disabled
    -D wasm=disabled
    -D graphite2=enabled
    -D cairo=disabled
    -D glib=enabled
    -D icu=enabled
    -D gobject=enabled
    -D tests=disabled
    -D freetype=enabled
    -D docs=disabled
    -D introspection=enabled
    -D experimental_api=false
  )

  # Harfbuzz wants no exceptions
  CFLAGS="${CFLAGS/-fexceptions/}"
  CXXFLAGS="${CXXFLAGS/-fexceptions/}"

  meson setup build "${meson_args[@]}"

  meson compile -C build
}

src_install() {
  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 COPYING
}

# vim:ft=sh syn=sh et sw=2:
