# Description: An OpenType text shaping engine
# URL: https://github.com/harfbuzz/harfbuzz
# Maintainer: CRUX System Team, core-ports at crux dot nu
# Depends on: freetype glib-introspection
# Optional: cairo chafa glib glib-introspection graphite2 icu

name=harfbuzz
version=14.2.1
release=1
source=(https://github.com/harfbuzz/harfbuzz/releases/download/$version/$name-$version.tar.xz)

build() {
    prt-get isinst cairo || PKGMK_HARFBUZZ+=' -D cairo=disabled -D raster=disabled'
    prt-get isinst chafa || PKGMK_HARFBUZZ+=' -D chafa=disabled'
    prt-get isinst graphite2 && PKGMK_HARFBUZZ+=' -D graphite2=enabled'
    prt-get isinst icu || PKGMK_HARFBUZZ+=' -D icu=disabled'

    sed -i '/# include/s/chafa.h/chafa\/chafa.h/' \
      $name-$version/util/hb-info.cc $name-$version/util/helper-image-output.hh \
      $name-$version/util/helper-cairo-ansi.hh

    meson setup build $name-$version $PKGMK_HARFBUZZ \
        --prefix=/usr \
        --buildtype=plain \
        --wrap-mode nodownload \
        -D b_lto=true \
        -D b_pie=true \
        -D cpp_std=c++17 \
        -D benchmark=disabled \
        -D docs=disabled \
        -D tests=disabled \
        -D graphite=auto
    meson compile -C build -j ${JOBS:-1}
    DESTDIR=$PKG meson install -C build
}
