136 lines
3.5 KiB
Bash
136 lines
3.5 KiB
Bash
# Template file for 'cargo'
|
|
pkgname=cargo
|
|
version=0.40.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/"
|
|
_libgit2_ver=0.9.1
|
|
distfiles="https://github.com/rust-lang/cargo/archive/${version}.tar.gz
|
|
https://github.com/rust-lang/git2-rs/archive/libgit2-sys-${_libgit2_ver}.tar.gz"
|
|
checksum="b0a6808a2eaa9b20ccaeedeb04f583ee34b33d289f4d0076044b9fc2b1f4c59d
|
|
81e20fa9a0f6ea3e3a0e6458148f3dea4a89af87d34128d4375f2b7fd661a49c"
|
|
_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
|
|
|
|
mv ${XBPS_BUILDDIR}/git2-rs-libgit2-sys-${_libgit2_ver} .
|
|
mv git2-rs-libgit2-sys-${_libgit2_ver}/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
|
|
|
|
# gotta pin out libgit2-sys at the version
|
|
$cargo update
|
|
$cargo update --package libgit2-sys --precise ${_libgit2_ver}
|
|
$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
|
|
}
|