# Maintainer: Maksim Bondarenkov <maksapple2306@gmail.com>
# Contributor: Wu Zhenyu <wuzy01@qq.com>

_realname=fd
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=10.3.0
pkgrel=1
pkgdesc='Simple, fast and user-friendly alternative to find (mingw-w64)'
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url='https://github.com/sharkdp/fd'
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
license=('spdx:Apache-2.0 OR MIT')
msys2_references=(
  'archlinux: fd'
  'purl: pkg:cargo/fd-find'
)
source=("${url}/archive/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha512sums=('fa7d03cbc4abab02db8ed5cc7f3cb91ba87a6b4a609186edb40db80420a31a7ef671558e7a172008d8d31d9f7ef46ad9f58503129e1a253e36f1c2c15135595b')

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

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

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

  export WINAPI_NO_BUNDLED_LIBRARIES=1
  make prefix="${MINGW_PREFIX}"
}

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

  cargo test --release --frozen
}

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

  make install DESTDIR="${pkgdir}" prefix="${MINGW_PREFIX}"

  install -Dm644 LICENSE-{APACHE,MIT} -t "${pkgdir}${MINGW_PREFIX}/share/licenses/fd/"
}
