# Maintainer: Naveen M K <naveen521kk@gmail.com>

_realname=dust
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5.4
pkgrel=1
pkgdesc="A more intuitive version of du in rust  (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url='https://github.com/bootandy/dust'
license=(APACHE)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-rust"
)
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
source=("${_realname}-${pkgver}.tar.gz::${url}/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('395f0d5f44d5000468dc51a195e4b8e8c0b710a1c75956fb1f9ad08f2fbbc935')

prepare() {
  cp -r ${_realname}-${pkgver} build-${CARCH}
  ${MINGW_PREFIX}/bin/cargo fetch \
  --locked \
  --manifest-path build-${CARCH}/Cargo.toml
}

build() {
  ${MINGW_PREFIX}/bin/cargo build \
  --release \
  --manifest-path build-${CARCH}/Cargo.toml
}

package() {
  ${MINGW_PREFIX}/bin/cargo install \
  --offline \
  --no-track \
  --path build-${CARCH} \
  --root ${pkgdir}${MINGW_PREFIX}

  # Package licenses
  install -Dm644 build-${CARCH}/LICENSE \
    "${pkgdir}${MINGW_PREFIX}"/share/licenses/$pkgname/LICENSE
}
