# Maintainer: team/rust <alpine@ptrcnull.me>
pkgname=cargo-auditable
pkgver=0.6.6
pkgrel=0
pkgdesc="Cargo wrapper for embedding auditing data"
url="https://github.com/rust-secure-code/cargo-auditable"
arch="all"
license="MIT OR Apache-2.0"
depends="cmd:cargo"
# lld: for build order resolution during bootstrap, we only want rust-wasm
# (not rust) to depend on lld to prevent lld-llvm version mismatch issues.
case "$CARCH" in
s390x) ;; # limited by rust-wasm
*) checkdepends="lld rust-wasm" ;;
esac
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/rust-secure-code/cargo-auditable/archive/refs/tags/v$pkgver.tar.gz"
options="net"

prepare() {
	default_prepare

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

build() {
	msg "building cargo auditable"
	cargo build --release --frozen
	msg "rebuilding with cargo-auditable itself"
	PATH="$PATH:$PWD/target/release" \
		cargo auditable build --release --frozen
}

check() {
	# we have -Clink-args in default RUSTFLAGS
	# that are not valid for wasm32 code built in the tests
	unset RUSTFLAGS

	case "$CARCH" in
	s390x) cargo test --frozen -- --skip test_wasm ;;
	*) cargo test --frozen ;;
	esac
}

package() {
	install -Dm755 target/release/cargo-auditable -t "$pkgdir"/usr/bin/
	install -Dm644 cargo-auditable/cargo-auditable.1 -t "$pkgdir"/usr/share/man/man1/
}

sha512sums="
e235735767292bc347aef1095b3458e84e57e5ea8019c17842190a6a90ff4a72feb05e1ce9afe29e8d8199aaf703368e939b088b9a052c00c8e05b1b3ff5c4f6  cargo-auditable-0.6.6.tar.gz
"
