void-packages/srcpkgs/rust/template

194 lines
6.1 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.31.1
revision=1
_rust_dist_version=1.31.0
_cargo_dist_version=0.32.0
# NB. if you push any(!) new version, don't forget to put a build
# output of musl to https://alpha.de.repo.voidlinux.org/distfiles/
wrksrc="rustc-${version}-src"
lib32disabled=yes
patch_args="-Np1"
build_style=configure
make_build_args="dist VERBOSE=1"
hostmakedepends="cmake curl pkg-config python"
makedepends="libffi-devel llvm ncurses-devel libxml2-devel zlib-devel"
depends="rust-std"
short_desc="Safe, concurrent, practical systems language"
maintainer="Enno Boland <gottox@voidlinux.org>"
homepage="https://www.rust-lang.org/"
license="MIT, Apache-2.0"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=91d2fc22f08d986adab7a54eb3a6a9b99e490f677d2d092e5b9e4e069c23686a
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo llvm"
# These are required for building the buildhost's stage0/1
hostmakedepends+=" libffi-devel libxml2-devel
ncurses-devel zlib-devel"
else
case "$XBPS_MACHINE" in
x86_64-musl)
hostmakedepends+=" libcurl libgit2"
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-x86_64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-x86_64-unknown-linux-musl.tar.xz"
checksum+="
7ca7360b9243b7117bbb5281b563fdf2bfae61d223ad858199aabc438c828926
b5cadf379e82905459dea5359c7111b30cfbba33a17b6960e3beb72ce79b7db9
4dfb1cca7730b38920c04731be0e9d47ec520b3365059b4ccd9c0948346787ea"
;;
x86_64)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-x86_64-unknown-linux-gnu.tar.xz"
checksum+="
5c4581f0fc05f0f5076db6231b0c1a4d27eb61c0b36bfb42d97243ad8f4e43a0
fe67a62c7a63acbf2458a36d7689ef41903187a472f0c28850f1fca7ea478da8
7e46150e431eaafef9439c9cd958aa8d980a0a70f0bb052473f0a75023930dcc"
;;
i686)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/cargo-${_cargo_dist_version}-i686-unknown-linux-gnu.tar.xz"
checksum+="
549116e23dce8687f69327f5ea2c717c93175d24d82d456fab37160f800f8ce8
14de38321f6f2c64496e77bac793ad5511d37696b9c33283bb6f395dc590c4d9
200cf76636ccbb153d5c430a5c0f3ad5af206899f76470e3cd046679a5a4ab3f"
;;
esac
fi
# In rust terminology 'build' is the build host ($CBUILD) and `target`
# and `host` are the triplets that are supposed to run the built binaries
# ($CTARGET)
case $XBPS_MACHINE in
*-musl) _build_triplet=${XBPS_MACHINE%-musl}-unknown-linux-musl;;
*) _build_triplet=${XBPS_MACHINE}-unknown-linux-gnu;;
esac
post_extract() {
rm -rf src/llvm
if [ -z "$CROSS_BUILD" ]; then
mkdir -p stage0
rm ../rustc-*/rustc/manifest.in
cp -bflr ../rustc-*/rustc/* stage0
rm ../rust-std-*/rust-std-*/manifest.in
cp -bflr ../rust-std-*/rust-std-*/* stage0
case "$XBPS_MACHINE" in
*-musl) cp -bflr ../cargo stage0/bin;;
*)
rm ../cargo-*/cargo/manifest.in
cp -flr ../cargo-*/cargo/* stage0
;;
esac
fi
sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
}
do_configure() {
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
configure_args="
--prefix=/usr
--host=${RUST_TARGET}
--target=${RUST_TARGET}
--build=${_build_triplet}
--disable-full-bootstrap
--release-channel=stable
--disable-rpath
--disable-docs
--disable-codegen-tests
--llvm-root=/usr
--set=target.${_build_triplet}.llvm-config=/usr/bin/llvm-config
"
# Disable jemalloc for now. It increases the size of small programs
# significantly (hello world without jemalloc 130KB vs with jemalloc
# 300KB) and provides worse performance in some cases.
configure_args+=" --disable-jemalloc"
if [ "$CROSS_BUILD" ]; then
configure_args+="
--local-rust-root=/usr
--enable-local-rebuild
"
# Set the appropriate values for the native compilation tools
configure_args+="
--set=target.${_build_triplet}.cc=${CC_host}
--set=target.${_build_triplet}.cxx=${CXX_host}
--set=target.${_build_triplet}.ar=${AR_host}
--set=target.${_build_triplet}.linker=${CC_host}
"
# Set 'llvm-config' for the cross target (host) so that we don't build
# LLVM for it again.
configure_args+="
--set=target.${RUST_TARGET}.llvm-config="/usr/bin/llvm-config"
"
else
configure_args+=" --local-rust-root=$wrksrc/stage0"
fi
case "$XBPS_TARGET_MACHINE" in
*-musl)
configure_args+=" --set=target.${RUST_TARGET}.musl-root=/usr"
;;
esac
./configure $configure_args
}
pre_build() {
export CARGO_HOME="$wrksrc/.cargo"
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
export PATH="$wrksrc/stage0/bin:$PATH"
export MUSL_ROOT=/usr
export RUST_BACKTRACE=1
export RUSTFLAGS="-C linker=${CC}"
}
# Set the correct CFLAGS for the build host, we have to compile libbacktrace
# for it during stage1. Otherwise it attemps to use CFLAGS, which are the CFLAGS
# of the cross host.
do_build() {
env CFLAGS_${_build_triplet}="${CFLAGS_host}" make ${makejobs} ${make_build_args}
}
do_install() {
vmkdir usr
tar xf build/dist/rustc-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
tar xf build/dist/rust-std-${version}-${RUST_TARGET}.tar.gz -C "$DESTDIR/usr/lib" --strip-components=3 --exclude=manifest.in
vlicense COPYRIGHT
vlicense LICENSE-APACHE
vlicense LICENSE-MIT
cd ${DESTDIR}/usr/lib
ln -sf rustlib/*/lib/*.so . # symlinks instead of copies
}
rust-doc_package() {
short_desc+=" - documentation"
noarch=yes
pkg_install() {
vmove usr/share/doc
}
}
rust-std_package() {
short_desc+=" - standard library"
pkg_install() {
vmove usr/lib/rustlib
}
}