# Contributor: Kevin Daudt <kdaudt@alpinelinux.org>
# Maintainer: Kevin Daudt <kdaudt@alpinelinux.org>
pkgname=jless
pkgver=0.9.0
pkgrel=0
pkgdesc="command-line pager for JSON data"
url="https://pauljuliusmartinez.github.io/"
# riscv64, s390x: ftbfs
# loongarch64: build failed cause by rustyline
arch="all !riscv64 !s390x !loongarch64"
options="net"
license="MIT"
makedepends="rust cargo python3 libxcb-dev cargo-auditable"
source="$pkgname-$pkgver.tar.gz::https://github.com/PaulJuliusMartinez/jless/archive/refs/tags/v$pkgver.tar.gz"


prepare() {
	default_prepare

	# Optimize binary for size (2.5 MiB -> 1.7 MiB for v0.7.1).
	cat >> Cargo.toml <<-EOF

		[profile.release]
		codegen-units = 1
		lto = true
		opt-level = "s"
		panic = "abort"
	EOF

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm0755 target/release/jless "$pkgdir"/usr/bin/jless
}

sha512sums="
2c0f4b5d662f7e93727b25ef6b138368b453dc7246a6a2a3d14c158e15baeaf70df00252b0e1a813016837504bd6f75585d6e21760c52fc3ba76d61fc094ec7a  jless-0.9.0.tar.gz
"
