# Maintainer: Coelacanthus <uwu@coelacanthus.name>
# Contributor: Gyara <laxect39@gmail.com>

pkgname=beancount-language-server
pkgver=1.9.2
pkgrel=1
pkgdesc="A Language Server Protocol (LSP) for beancount files"
arch=('x86_64' 'aarch64')
url="https://github.com/polarmutex/${pkgname}"
license=('MIT')
depends=(
    'beancount'
    'glibc'
    'gcc-libs'
)
makedepends=('cargo')
source=($pkgname-$pkgver.tar.gz::https://github.com/polarmutex/${pkgname}/archive/${pkgver//_/-}.tar.gz)
b2sums=('0abaaaf25c2bef37c61c01a8b162a402d744c5b74b7b7e4a53c2d3c99c140286d2b53541538e018448c798ada82e0e01050464d93453ffcf8bb0561637b86dd4')
options=(!lto)

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
}

check() {
    cd "${pkgname}-${pkgver}"
    export RUSTUP_TOOLCHAIN=stable
    cargo test --frozen --all-features --workspace
}


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