# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=minidump-stackwalk
_projectname=rust-minidump
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.26.1
pkgrel=1
pkgdesc="Provides both machine-readable and human-readable digests of a minidump, with backtraces and symbolication (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/rust-minidump/rust-minidump'
msys2_references=(
  'aur: minidump-stackwalk'
  'purl: pkg:cargo/minidump-stackwalk'
)
license=('spdx:MIT')
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('811b4aca5457c4bee0ebeec60e17ab162ac31296dddca5faa1098a9937d486dd')

prepare() {
  cp -r "${_projectname}-${pkgver}" "build-${MSYSTEM}" && cd "build-${MSYSTEM}"

  cargo fetch --locked --target "${RUST_CHOST}"
}

build() {
  cd "build-${MSYSTEM}"

  cargo build --release --frozen -p minidump-stackwalk
}

check() {
  cd "build-${MSYSTEM}"

  cargo test --release --frozen -p minidump-stackwalk
}

package() {
  cd "build-${MSYSTEM}"

  cargo install \
    --frozen \
    --offline \
    --no-track \
    --path minidump-stackwalk \
    --root "${pkgdir}${MINGW_PREFIX}"

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
