# Description: SVG rendering library with cairo backend
# URL: https://wiki.gnome.org/Projects/LibRsvg
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: cargo-c pango toml2json
# Optional: gdk-pixbuf graphite2 libdav1d sccache vala

name=librsvg
version=2.62.3
release=1
source=(https://download.gnome.org/sources/$name/${version%.*}/$name-$version.tar.xz)

build() {
  prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
  [[ ! -e $PKGMK_SOURCE_DIR/rust ]] && mkdir $PKGMK_SOURCE_DIR/rust

  prt-get isinst vala && PKGMK_LIBRSVG+=' -D vala=enabled' || PKGMK_LIBRSVG+=' -D vala=disabled'
  prt-get isinst gdk-pixbuf && PKGMK_LIBRSVG+=' -D pixbuf=enabled -D pixbuf-loader=enabled -D introspection=enabled' || PKGMK_LIBRSVG+=' -D pixbuf=disabled -D pixbuf-loader=disabled -D introspection=disabled'

  export CARGO_PROFILE_RELEASE_LTO=true
  export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1

  meson setup $name-$version build $PKGMK_LIBRSVG \
    --prefix=/usr \
    --buildtype=plain \
    --wrap-mode nodownload \
    -D b_lto=true \
    -D b_pie=true \
    -D docs=disabled \
    -D tests=false
  meson compile -C build
  DESTDIR=$PKG meson install -C build
}
