void-packages/srcpkgs/cargo/template

91 lines
2.4 KiB
Bash

# Template file for 'cargo'
pkgname=cargo
version=0.58.0
revision=1
wrksrc="cargo-${version}"
build_helper=rust
hostmakedepends="cargo-bootstrap rust python3 curl cmake pkg-config zlib-devel"
makedepends="rust libcurl-devel openssl-devel"
depends="rust"
short_desc="Rust package manager"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="MIT, Apache-2.0"
homepage="https://crates.io/"
distfiles="https://github.com/rust-lang/cargo/archive/${version}.tar.gz
https://github.com/crossbeam-rs/crossbeam/archive/refs/tags/crossbeam-utils-0.8.5.tar.gz"
checksum="e1d6f55414a29906d24b13c687996b5220e08ccce9c682e4c02851138fc7093f
57db07eb38b0aaf7951c79b4639819cb84bc4269507091afea7267e10a54e079"
replaces="cargo-tree>=0"
build_options="static bindist"
desc_option_bindist="Generate a tarball for bootstrap"
if [ -n "$build_option_static" -o -n "$build_option_bindist" ]; then
_build_static=yes
fi
if [ -z "$_build_static" ]; then
makedepends+=" libgit2-devel"
fi
post_extract() {
mv ../crossbeam-* crossbeam-utils
}
post_patch() {
rm crossbeam-utils/crossbeam-utils/no_atomic.rs
cp crossbeam-utils/no_atomic.rs crossbeam-utils/crossbeam-utils
cat >> Cargo.toml <<- EOF
[patch.crates-io]
crossbeam-utils = { path = './crossbeam-utils/crossbeam-utils' }
EOF
}
do_build() {
local cargs
if [ -n "$_build_static" ]; then
unset LIBSSH2_SYS_USE_PKG_CONFIG
export OPENSSL_STATIC=1
# rust-openssl can not be linked static if pkg-config is used
export OPENSSL_NO_PKG_CONFIG
export OPENSSL_DIR="${XBPS_CROSS_BASE}/usr"
fi
if [ -n "$_build_static" ]; then
cargs+=" --features=all-static"
fi
cargo build --release ${cargs}
}
do_install() {
local cbin="target/release/cargo"
if [ "$CROSS_BUILD" ]; then
cbin="target/${RUST_TARGET}/release/cargo"
fi
if [ "$build_option_bindist" ]; then
local dest="cargo-${version}-${RUST_TARGET}"
mkdir -p ${XBPS_SRCDISTDIR}/distfiles ${dest}/cargo/bin
install -m 0755 ${cbin} ${dest}/cargo/bin
install -m 0644 LICENSE-APACHE LICENSE-MIT LICENSE-THIRD-PARTY ${dest}
bsdtar cvJf ${dest}.tar.xz ${dest}
install -m 0644 ${dest}.tar.xz ${XBPS_SRCDISTDIR}/distfiles
exit 1
fi
vbin ${cbin}
for f in src/etc/man/*.?; do
vman $f
done
vinstall src/etc/cargo.bashcomp.sh 0644 \
usr/share/bash-completion/completions cargo
vinstall src/etc/_cargo 0644 usr/share/zsh/site-functions
vlicense LICENSE-APACHE
vlicense LICENSE-MIT
vlicense LICENSE-THIRD-PARTY
}