# Maintainer: Matthew Jiang <matthewyjiang@gmail.com>
pkgname=rho-coding-agent
pkgver=0.22.0 # x-release-please-version
pkgrel=1
pkgdesc="A lightweight agent harness inspired by Pi"
arch=('x86_64')
url="https://github.com/matthewyjiang/rho"
license=('MIT')
depends=('gcc-libs' 'glibc' 'sqlite')
makedepends=('cargo')
options=(!lto)
_tagname="rho-coding-agent-v$pkgver"
source=("$pkgname-$pkgver.tar.gz::https://github.com/matthewyjiang/rho/archive/refs/tags/$_tagname.tar.gz")
sha256sums=('SKIP')

prepare() {
    cd "rho-$_tagname"
    export CARGO_HOME="$srcdir/cargo"
    cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
    cd "rho-$_tagname"
    export CARGO_HOME="$srcdir/cargo"
    cargo build --release --locked --bin rho --no-default-features
}

check() {
    cd "rho-$_tagname"
    export CARGO_HOME="$srcdir/cargo"
    cargo test --release --locked --no-default-features
}

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