pkgname=librsvg
pkgver=2.61.0
_ver=${pkgver%.*}
pkgdesc="SVG rendering library"
homepage="https://wiki.gnome.org/Projects/LibRsvg"
arch=(x86_64)
license=(LGPL-2.1-or-later)
depends=(
  cairo
  freetype
  gcc
  gdk-pixbuf
  glib
  glibc
  harfbuzz
  libxml2
  pango
)
makedepends=(
  cargo-c
  gobject-introspection
  meson
  python-docutils
  rust
)
checkdepends=(ttf-dejavu)
_patches=("librsvg-2.60.0-libxml2-2.15.0-tests.patch")
_patch_sums=("0c0495867924d9121db39b7f3cf14eff")
sources=("${pkgname}-${pkgver}.tar.xz"
  ${_patches[@]}
)
urls=("https://download.gnome.org/sources/librsvg/${_ver}/${sources[0]}"
  ${_patches[@]}
)
md5sums=("7ed4ffdee87e0d7f356fedfea77744ca"
  ${_patch_sums[@]}
)

src_prepare() {
  tar -xf ${distdir}/${sources[0]} --strip-components=1
  for _patch in ${_patches[@]}; do
    patch -p1 -i ${filedir}/${_patch}
  done
  cargo fetch --locked --target "$(rustc --print host-tuple)"
}

src_build() {
  local meson_options=(
    --prefix=/usr
    --buildtype=release
    --wrap-mode=nodownload
    -D avif=disabled
    -D introspection=enabled
    -D pixbuf=enabled
    -D pixbuf-loader=enabled
    -D docs=disabled
    -D vala=disabled
    -D tests=true
  )

  meson setup build "${meson_options[@]}"
  meson compile -C build
}

src_check() {
  meson test -C build --print-errorlogs --no-rebuild
}

src_install() {
  meson install -C build --destdir "$pkgdir" --no-rebuild
}

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