void-packages/srcpkgs/cargo/template

108 lines
3.0 KiB
Bash

# Template file for 'cargo'
pkgname=cargo
version=0.33.0
revision=2
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"
checksum=914d715ff1a4ac4280b63d05c0f848d38889900a5559888d4a20c9600f87e6a4
_cargo_dist_version=0.33.0
build_options="static"
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo"
makedepends+=" rust"
else
case "$XBPS_MACHINE" in
x86_64-musl)
hostmakedepends+=" libgit2-0.27"
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
checksum+="
6c519f5103e422650c3f69ac9b19303f829e9f9bb7e088d84dcd0318fd1b56c0"
;;
x86_64)
distfiles+="
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.gz"
checksum+="
9dd7f79a0ab882ed7c892731514a4aed6435f7bc8a20381a8346b471c8a14209"
;;
i686)
distfiles+="
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.gz"
checksum+="
163f46bd84ba6348dfe1ac3c10bc4730059f321791d2a7d4d4704fe8ddf8a755"
;;
ppc64le)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
checksum+="
bd22f3c2fad2be544a80c890a659cb5f1c5bf2d80f3f6a14be23d19000545d01"
;;
ppc64le-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
checksum+="
1db7c45306e3a424620ac2c6d07374a6ea0e3c6be0d3a546393188bf1fea1f02"
;;
ppc64-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
checksum+="
a6b3f9ba055bb78ae70d31aed05d37969dee864fc003135f34f1bb92b6cd13b5"
;;
esac
fi
post_extract() {
if [ -z "$CROSS_BUILD" ]; then
mkdir -p target/snapshot
case "$XBPS_MACHINE" in
x86_64-musl|ppc64*) cp ../cargo cargo;;
*) cp ../cargo-${_cargo_dist_version}-${RUST_TARGET}/cargo/bin/cargo cargo;;
esac
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
}