# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=corrosion
pkgver=0.5.0
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 --output-on-failure -E "(parse_target_triple_build|cargo_config_rustflags_build|cargo_config_rustflags_run_cargo_config_rustflags|rustup_proxy_build)"
}

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

sha512sums="
1542be551d8e253a522800d9270e52754540f803493bd35217cfeaf8d2660cbc446c112b04deb040249ab3381d08166d353b5dec1f29f43cf976b5b8639b4b9a  corrosion-0.5.0.tar.gz
"
