# Template file for 'rustup'
pkgname=rustup
version=1.14.0
revision=5
wrksrc="${pkgname}.rs-${version}"
build_style=cargo
configure_args="--features no-self-update --bin rustup-init"
hostmakedepends="perl pkg-config"
makedepends="libressl-devel zlib-devel libcurl-devel"
short_desc="The Rust toolchain installer"
maintainer="Daniel Lee Ramírez <dleeram@protonmail.com>"
license="Apache-2.0, MIT"
homepage="https://www.rustup.rs"
distfiles="https://github.com/rust-lang-nursery/${pkgname}.rs/archive/${version}.tar.gz"
checksum=ab125d9b12bf0f3f7e7ad98e826035fa1ae3dbe6ba8b78be4c82f9cde00bc59f
conflicts="rust cargo"

pre_build() {
	cargo update --package openssl-sys --precise 0.9.35
}

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

	# rustup doesn't set PATH correctly to include these.
	for cmd in cargo rust-gdb rust-lldb rustc rustdoc; do
		ln -s rustup ${DESTDIR}/usr/bin/${cmd}
	done

	if ! [ "$CROSS_BUILD" ]; then
		# generate shell completions
		ln -s target/${RUST_TARGET}/release/rustup-init rustup
		./rustup completions zsh > rustup.zsh
		./rustup completions bash > rustup.bash
		./rustup completions fish > rustup.fish

		vinstall rustup.zsh 0644 usr/share/zsh/site-functions/ _rustup
		vinstall rustup.bash 0644 usr/share/bash-completion/completions/ rustup
		vinstall rustup.fish 0644 usr/share/fish/completions/
	fi

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