# Template file for 'rustup'
pkgname=rustup
version=1.22.1
revision=2
build_style=cargo
build_helper=qemu
configure_args="--features no-self-update --bin rustup-init"
hostmakedepends="pkg-config"
makedepends="libressl-devel zlib-devel libcurl-devel"
short_desc="Rust toolchain installer"
maintainer="Jan Christian Grünhage <jan.christian@gruenhage.xyz>"
license="Apache-2.0, MIT"
homepage="https://www.rustup.rs"
distfiles="https://github.com/rust-lang/${pkgname}/archive/${version}.tar.gz"
checksum=ad46cc624f318a9493aa62fc9612a450564fe20ba93c689e0ad856bff3c64c5b

post_build() {
	# rustup errors out because it doesn't know about armv6l-musl
	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
		RUSTUP="target/${RUST_TARGET}/release/rustup-init"
		ln -sf "$RUSTUP" rustup
		# generate shell completions
		vtargetrun ./rustup completions zsh >rustup.zsh
		vtargetrun ./rustup completions bash >rustup.bash
		vtargetrun ./rustup completions fish >rustup.fish
	fi
}

do_install() {
	vbin target/${RUST_TARGET}/release/rustup-init

	if [ "$XBPS_TARGET_MACHINE" != armv6l-musl ]; then
		vcompletion rustup.bash bash
		vcompletion rustup.fish fish
		vcompletion rustup.zsh zsh
	fi

	vdoc README.md
	vlicense LICENSE-APACHE
	vlicense LICENSE-MIT
}
