pkgname=libspng
pkgver=0.7.4
pkgdesc='Simple, modern libpng alternative'
arch=(x86_64)
url=https://github.com/randy408/libspng
license=(BSD)
depends=(
  glibc
  zlib
)
makedepends=(meson)
checkdepends=(libpng)
sources=("${pkgname}-${pkgver}.tar.gz")
urls=("https://github.com/randy408/libspng/archive/refs/tags/v${pkgver}.tar.gz")
md5sums=("5072ee5d309c593080ea5f43e81e61e4")

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

src_build() {
  local meson_args=(
    --prefix=/usr
    --buildtype=release
    -D dev_build=true
  )
  meson setup build "${meson_args[@]}"
  meson compile -C build
}

src_check() {
  local -a tests
  tests=( $(meson test --list -C build) )
  local -a skip_tests=(
    # Incompatabilities with >=libpng-1.6.47
    # bug #956692
    ch1n3p04
    ch2n3p08
  )
  for test_index in ${!tests[@]}; do
    if [[ ${skip_tests[@]} =~ ${tests[${test_index}]} ]]; then
      unset tests[${test_index}]
    fi
  done

  meson test -C build ${tests[@]}
}

src_install() {
  DESTDIR="${pkgdir}" meson install -C build
  install -Dm 644 LICENSE -t "${pkgdir}"/usr/share/licenses/libspng/
}

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