# Maintainer: team/rust <alpine@ptrcnull.me>
pkgname=cargo-auditable
pkgver=0.6.7
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.
checkdepends="lld rust-wasm"
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="$CHOST" --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

	cargo test --frozen
}

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="
6805c59dd677d101139d75bea1261b9044a15a6882303609dbc2364a58ec3f87509be6fba76233427a43d3ae0ace84523a6e4fd22bc2c481657615a966f97c61  cargo-auditable-0.6.7.tar.gz
"