void-packages/srcpkgs/rust/template
2018-11-24 07:21:40 +01:00

193 lines
6.1 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.30.1
revision=1
_rust_dist_version=1.30.1
_cargo_dist_version=0.31.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.eu>"
homepage="https://www.rust-lang.org/"
license="MIT, Apache-2.0"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=36a38902dbd9a3e1240d46ab0f2ca40d2fd07c2ab6508ed7970c6c4c036b5b29
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-libressl-2.8.tar.gz"
checksum+="
44abd56868e63447c43eb8644847d14662f57f2aa65342147432dc89fc4c94aa
341fb3dee37eae8235b6193110f84bb2915c08b451d228532b4f1d80366afe9b
61d72ac378f3ee592cd3c82b02518f717bfcf328946ad4a51d24a2dac546c1cb"
;;
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+="
d84de208499b59e4a3c074f9f3f2fcbb26fb20d6bfd19262e6d5f4181ddbe34d
12c4b164efed44c28096fcd141225ee9bf74e7e3395bc6a60c11c9115a0536c6
21ef918ba8970815856ef2764ad1b377a2d4868bed96340ac05d7fe62f8cf952"
;;
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+="
7259121446e2ef579f2a3ed24c8a54a85a2a1a8d5ff517a0249ba3639ee989cf
88aadaf4dd4fdf565a72ec822e08de5c6a72d3784fc378b82689f2843f8da874
642e298e1431a9d65559a3bae9c4e1dab79816577b7b3c1f35e28c5621878165"
;;
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
}
}