# Contributor: Orhun Parmaksız <orhunparmaksiz@gmail.com>
# Maintainer: Orhun Parmaksız <orhunparmaksiz@gmail.com>
pkgname=cargo-modules
pkgver=0.21.1
pkgrel=0
pkgdesc="A cargo plugin for showing an overview of a crate's modules"
url="https://github.com/regexident/cargo-modules"
arch="all"
license="MPL-2.0"
makedepends="
	cargo
	cargo-auditable
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/regexident/cargo-modules/archive/v$pkgver.tar.gz"
options="net" # needed to fetch crates

# secfixes:
#   0.21.1-r0:
#     - CVE-2024-12224

prepare() {
	default_prepare

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

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

check() {
	# Increase stack size to avoid stack overflow while compiling 'ra_ap_intern'
	export RUST_MIN_STACK="4194304"

	cargo test --frozen --lib
}

package() {
	install -Dm 755 target/release/cargo-modules -t "$pkgdir"/usr/bin
	install -Dm 644 README.md -t "$pkgdir/usr/share/doc/$pkgname"
}

sha512sums="
663c9357f53c96f9364ee9c87dcbf18c6a85a5330906fe81045c67b7db12753ecc0faf7eb8c3be56281712ab7ca07dc39572c3e1fbf7275c7d65d148bdeeb9a8  cargo-modules-0.21.1.tar.gz
"
