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

_realname=starship
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.54.0
pkgrel=1
pkgdesc="The cross-shell prompt for astronauts (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://starship.rs"
license=(ISC)
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-rust"
)
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
options=('staticlibs' 'strip')
_tag=5e9d9c5419b26496e5c75bd8d6923762e8ffb909
source=(git+https://github.com/starship/starship.git#tag=${_tag})
sha256sums=('SKIP')

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

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

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

  install -Dm 644 build-${CARCH}/LICENSE -t "${pkgdir}${MINGW_PREFIX}"/share/licenses/starship/
  install -dm 755 "${pkgdir}${MINGW_PREFIX}"/share/{bash-completion/completions,fish/vendor_completions.d,zsh/site-functions}/
  ./build-${CARCH}/target/release/starship completions bash >"${pkgdir}${MINGW_PREFIX}"/share/bash-completion/completions/starship
  ./build-${CARCH}/target/release/starship completions fish >"${pkgdir}${MINGW_PREFIX}"/share/fish/vendor_completions.d/starship.fish
  ./build-${CARCH}/target/release/starship completions zsh >"${pkgdir}${MINGW_PREFIX}"/share/zsh/site-functions/_starship
}
