# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Carl Smedstad <carsme@archlinux.org>
# Contributor: László Várady <laszlo.varady93@gmail.com>
# Contributor: Snaipe

pkgname=criterion
_pkgname=Criterion
pkgver=2.4.2
pkgrel=3
pkgdesc="A cross-platform C and C++ unit testing framework for the 21st century"
arch=(x86_64 riscv64)
url="https://github.com/Snaipe/Criterion"
license=(MIT)
depends=(
  glibc
  libffi
  libgit2
  nanomsg
)
makedepends=(
  cmake
  git
  meson
)
checkdepends=(python-cram)
options=(!lto)
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz")
sha256sums=('83e1a39c8c519fbef0d64057dc61c8100b3a5741595788c9f094bba2eeeef0df')

prepare() {
  cd $_pkgname-$pkgver
  # Use system packages for these instead.
  rm -v \
    subprojects/libffi.wrap \
    subprojects/libgit2-cmake.wrap \
    subprojects/nanomsg-cmake.wrap
  # Download of nanopb produces an error as it does not contain a meson.build
  # file. A meson.build file is not necessary, so ignore the error.
  meson subprojects download || :
}

build() {
  cd $_pkgname-$pkgver
  arch-meson build
  meson compile -C build
}

check() {
  cd $_pkgname-$pkgver
  meson test -C build --print-errorlogs
}

package() {
  cd $_pkgname-$pkgver
  meson install -C build --destdir "$pkgdir"
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
