# Maintainer: Kimiblock Moe
# Maintainer: JohanChane

pkgname=clashtui-git
pkgdesc="Mihomo (Clash.Meta) TUI Client"
url="https://github.com/JohanChane/clashtui"
license=("MIT")
arch=("x86_64" "aarch64")
pkgver=0.3.2.alpha.2.r14.g4338100a
pkgrel=1
makedepends=("rust" "git")
depends=("gcc-libs" "glibc" "mihomo")
source=("source::git+https://github.com/JohanChane/clashtui.git")
md5sums=('SKIP')
provides=("clashtui")
conflicts+=(clashtui)
options=(!lto)

function pkgver() {
	cd "${srcdir}/source"
	git describe --long --tags --abbrev=8 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

function prepare() {
	cd source
	export RUSTUP_TOOLCHAIN=stable
	cargo fetch --target "$CARCH-unknown-linux-gnu"
}

function build() {
	cd source
	export RUSTUP_TOOLCHAIN=stable
	export CARGO_TARGET_DIR=target
	cargo build --release --frozen --all-features --locked
}

function check() {
	cd source
	export RUSTUP_TOOLCHAIN=stable
	cargo test --release --frozen --all-features --locked
}

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