# Maintariner: Rocket Aaron <rocka@archlinuxcn.org>
# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>
# Contributor: Igor Saric <karabaja4 at gmail dot com>

_pkgname=gdk-pixbuf
pkgname=gdk-pixbuf2-noglycin
pkgver=2.44.7
pkgrel=1
pkgdesc="An image loading library (without glycin)"
url="https://wiki.gnome.org/Projects/GdkPixbuf"
arch=(x86_64)
license=(LGPL-2.0-or-later)
depends=(
  glib2
  glibc
  libjpeg-turbo
  libpng
  libtiff
  shared-mime-info
)
makedepends=(
  gi-docgen
  glib2-devel
  gobject-introspection
  meson
  python-docutils
)
optdepends=(
  "libheif: Load .avif, .heic and .heif"
  "libjxl: Load .jxl"
  "libopenraw: Load .arw, .cr2, .crw, .dng, .erf, .mrw, .nef, .orf, .pef and .raf"
  "librsvg-pixbuf-loader: Load .svg, .svgz and .svg.gz"
  "libwmf: Load .apm and .wmf"
  "webp-pixbuf-loader: Load .webp"
)
provides=(
  libgdk_pixbuf-2.0.so
  gdk-pixbuf2
)
conflicts=(
  gdk-pixbuf2
)
install=gdk-pixbuf2-noglycin.install
source=(
  "https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/archive/${pkgver}/${_pkgname}-${pkgver}.tar.gz"
  gdk-pixbuf2-noglycin.install
  gdk-pixbuf-query-loaders.hook
)
sha256sums=('797537333e783843ac150f4251de60bf0ddcfad4fa34a292e892bfed58d8d5ef'
            'a92b5437b664c293a709c418abd455a7878b4c0adf3ea2f6fcf7439300c3d1e9'
            '9fb71d95e6a212779eb0f88dde5a3cee0df7f4d9183f8f9ce286f8cdc14428f0')

prepare() {
  cd "${_pkgname}-${pkgver}"
  #patch -Np1 -i
}

build() {
  local meson_options=(
    -D android=disabled
    -D builtin_loaders=all
    -D documentation=false
    -D gif=enabled
    -D glycin=disabled
    -D gtk_doc=false
    -D installed_tests=false
    -D introspection=enabled
    -D jpeg=enabled
    -D man=false
    -D others=enabled
    -D png=enabled
    -D thumbnailer=disabled
    -D tiff=enabled
  )

  arch-meson "${_pkgname}-${pkgver}" build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs || :
}

package() {
  meson install -C build --destdir "$pkgdir"
  install -Dt "$pkgdir/usr/share/libalpm/hooks" -m644 "${srcdir}/gdk-pixbuf-query-loaders.hook"
}
