void-packages/srcpkgs/cargo/template
2019-10-07 19:54:22 +02:00

132 lines
3.4 KiB
Bash

# Template file for 'cargo'
pkgname=cargo
version=0.39.0
revision=1
wrksrc="cargo-${version}"
build_helper=rust
hostmakedepends="rust python curl cmake pkg-config"
makedepends="libcurl-devel libgit2-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/rust-lang/git2-rs/archive/libgit2-sys-0.8.2.tar.gz"
checksum="1fade63d5c09eab6fa234a1fdf64693ccf1b63398a316ad27edeb1f76ee4a57e
c6597bcdc2be7a2fd70c1bb8fdc75883ca5df6aea33f0354c5a8124eacc0938b"
_cargo_dist_version=0.39.0
build_options="static"
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo"
makedepends+=" rust"
else
_bootstrap_url="https://static.rust-lang.org/dist"
case "$XBPS_MACHINE" in
x86_64*|i686|ppc64le|ppc) ;;
ppc*) _bootstrap_url="https://alpha.de.repo.voidlinux.org/distfiles" ;;
*) broken="unsupported host: ${XBPS_MACHINE}" ;;
esac
distfiles+="
${_bootstrap_url}/cargo-${_cargo_dist_version}-${RUST_BUILD}.tar.xz"
case "$XBPS_MACHINE" in
i686)
checksum+="
2996b0fb41506e87d9b07851f40b41fed94725cf53c3d251e4e1c78eea08df4c"
;;
x86_64)
checksum+="
80bcb1368ce98d13cb371df89cbbed9007fb98843f34d07f2abd2c03b8f2747a"
;;
x86_64-musl)
checksum+="
1d7d881a5af73fb7c3f632278d47a7d174f8347673e2263c4cd6a2f7d0278733"
;;
ppc64le)
checksum+="
456d019511cfe015152a7a4c1c2f518fdeb10e0c610c9bc3ef44d73861ca967e"
;;
ppc64le-musl)
checksum+="
5725c42c8356443db15f378d88f2ccb67e363ebf4beacc96ae1eac9ba36f8fe7"
;;
ppc64)
checksum+="
73a4f13b8edda6b4c9c1818341c5d936f7b11a04f892358039d072b80ccd41dc"
;;
ppc64-musl)
checksum+="
ac18707b8df5d1f64b7e15dabd73eb7a3b0f9ef5976ef7c6ceb462b5d3feb9cd"
;;
ppc)
checksum+="
02c07b741062e75556f5993a05eefe6dace70fee4a45542f1c6997fa69624d7e"
;;
ppc-musl)
checksum+="
b06306fc164bffa73afd2d21d96381a28d38446e58cf01a0d1585e92b4656a23"
;;
esac
fi
post_extract() {
if [ -z "$CROSS_BUILD" ]; then
mkdir -p target/snapshot
cp ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo cargo
fi
# need this for the patch to work
cp -R ${XBPS_BUILDDIR}/git2-rs-libgit2-sys-0.8.2/libgit2-sys .
}
post_patch() {
# but only use the patched libgit2 when not static; when static, bundled
# libgit2 is used and this would not work (libgit2 sources are not there)
if [ ! "$build_option_static" ]; then
cat >> Cargo.toml <<- EOF
[patch.crates-io]
libgit2-sys = { path = './libgit2-sys' }
EOF
fi
}
do_build() {
if [ "$build_option_static" ]; then
unset LIBGIT2_SYS_USE_PKG_CONFIG
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 [ "$CROSS_BUILD" ]; then
cargo="cargo"
else
cargo="./cargo"
fi
$cargo build --release $(vopt_if static --features="all-static")
}
do_install() {
if [ "$CROSS_BUILD" ]; then
vbin target/${RUST_TARGET}/release/cargo
else
vbin target/release/cargo
fi
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
}