maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=corrosion
pkgver=0.5.2
pkgrel=0
pkgdesc="Marrying Rust and CMake - Easy Rust and C/C++ Integration!"
url="https://github.com/corrosion-rs/corrosion"
arch="all"
license="MIT"
depends="
	cargo
	cmake
	rust
	"
makedepends="samurai"
source="https://github.com/AndrewGaspar/corrosion/archive/v$pkgver/corrosion-$pkgver.tar.gz"
options="net" # Required to download Rust dependencies


build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib
	cmake --build build
}

check() {
	# unset these for tests as they aren't relevant and just slow them down
	unset CARGO_PROFILE_RELEASE_LTO
	unset CARGO_PROFILE_RELEASE_CODEGEN_UNITS
	unset CARGO_PROFILE_RELEASE_PANIC

	# parse_target_triple_build is broken, expects rustup and fails without it
	# cargo_config_rustflags seems broken
	# rustup_proxy_build expects to find rustup
	ctest --test-dir build -E "(parse_target_triple_build|cargo_config_rustflags_(build|run_cargo_config_rustflags)|rustup_proxy_build)"
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
2510d4d0484fc12a6b429244b283515fda650b52ea74fbfdcc141298b452b20e2bef800b8f8a573a2bf509f4147ecb2d68e795cbd86cc8edd092f57ccff8b86b  corrosion-0.5.2.tar.gz
"
