# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>
# Contributor: yumetodo <yume-wikijp@live.jp>

_realname=hexyl
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.16.0
pkgrel=1
pkgdesc="A command-line hex viewer (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/sharkdp/hexyl"
license=('spdx:Apache-2.0 OR MIT')
msys2_references=(
  'archlinux: hexyl'
  'purl: pkg:cargo/hexyl'
)
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('52853b4edede889b40fd6ff132e1354d957d1f26ee0c26ebdea380f8ce82cb0b')

prepare() {
  cd "${_realname}-${pkgver}"

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

build() {
  cd "${_realname}-${pkgver}"

  cargo build --release --frozen
}

check() {
  cd "${_realname}-${pkgver}"

  cargo test --release --frozen
}

package() {
  cd "${_realname}-${pkgver}"

  install -Dm755 "target/release/${_realname}" "${pkgdir}${MINGW_PREFIX}/bin/${_realname}"
  install -Dm644 LICENSE-{APACHE,MIT} -t "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
}
