# Template file for 'mise'
pkgname=mise
version=2026.8.2
revision=1
build_style=cargo
hostmakedepends="pkg-config cmake libzstd-devel"
makedepends="openssl-devel libzstd-devel bzip2-devel"
depends="usage"
checkdepends="git"
short_desc="Polyglot runtime manager (asdf rust clone)"
maintainer="Daniel Lewan <daniel@teddydd.me>"
license="MIT"
homepage="https://github.com/jdx/mise"
changelog="https://github.com/jdx/mise/releases"
distfiles="https://github.com/jdx/mise/archive/v${version}.tar.gz>${pkgname}-${version}.tar.gz"
checksum=4c35c9f882d5672b7cd990ad3a4e5eb2607d67b720697e3ed7f56c93e0a91b05

case "$XBPS_TARGET_MACHINE" in
	i686*) broken="runs out of memory" ;;
esac

if [ "$CROSS_BUILD" ]; then
	# those also run out of memory linking now.
	XBPS_CROSS_RUSTFLAGS+=" -Clto=off"
fi

pre_build() {
	# workaround the cc-rs mixing CFLAGS for host and target.
	# https://github.com/rust-lang/cc-rs/issues/1469
	export CFLAGS_${RUST_BUILD//-/_}="${CFLAGS_host}" \
		   CXXFLAGS_${RUST_BUILD//-/_}="${CXXFLAGS_host}" \
		   LDFLAGS_${RUST_BUILD//-/_}="${LDFLAGS_host}" \
		   CFLAGS_${RUST_TARGET//-/_}="${CFLAGS}" \
		   CXXFLAGS_${RUST_TARGET//-/_}="${CXXFLAGS}" \
		   LDFLAGS_${RUST_TARGET//-/_}="${LDFLAGS}" \
		   CFLAGS="" CXXFLAGS="" LDFLAGS=""
}

pre_install() {
	pre_build
}

post_install() {
	vlicense LICENSE
	vman man/man1/mise.1
	vdoc README.md
	vcompletion completions/mise.bash bash mise
	vcompletion completions/mise.fish fish mise
	vcompletion completions/_mise zsh mise
}

rtx_package() {
	depends="${sourcepkg}>=${version}_${revision}"
	short_desc+=" (transitional dummy package)"
	metapackage=yes
}
