# Maintainer: Coelacanthus <uwu@coelacanthus.name>
# Contributor: Cooper Pierce <cppierce@andrew.cmu.edu>

pkgname=millet
pkgver=0.15.2
pkgrel=1
pkgdesc="Language server implementation for Standard ML"
arch=('x86_64')
license=('Apache-2.0 AND MIT')
url="https://github.com/azdavis/millet"
depends=(
  gcc-libs
  glibc
)
makedepends=('cargo')
source=("$pkgname-$pkgver.tgz::${url}/archive/refs/tags/v${pkgver}.tar.gz")
b2sums=('e8784a50266c18723ada24f240ed9a667e4c81e9ef352c630ca49576a5cad8d27c8db02cfd9dd26360a57df1ddbc7cf667166f427e9ae84b12e6feb33e03c56d')

prepare() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}


build() {
  cd "$pkgname-$pkgver"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR=target
  cargo build --frozen --release --all-features
}

package() {
  cd "$pkgname-$pkgver"
  install -Dm755 "target/release/millet-ls" "$pkgdir/usr/bin/millet"
  install -Dm644 "LICENSE-MIT.md" "$pkgdir/usr/share/licenses/${pkgname}/LICENSE-MIT"
}

check() {
  cd "$pkgname-$pkgver"

  # Ignores tests starting with repo. These tests assume we're in a git repo
  # (we're not, here, since this is a source tarball), and test for things
  # like changelog entries existing.
  cargo test --frozen --all-features --workspace -- --skip repo
}
# vim: set ts=2 sw=2 et:
