void-packages/srcpkgs/rust/template
2019-03-01 12:04:45 -03:00

241 lines
8.3 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.32.0
revision=1
_rust_dist_version=1.32.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"
build_style=configure
make_build_args="dist VERBOSE=1"
hostmakedepends="cmake curl pkg-config python"
makedepends="libffi-devel ncurses-devel libxml2-devel zlib-devel
$(vopt_if internal_llvm python-devel llvm)"
depends="rust-std"
short_desc="Safe, concurrent, practical systems language"
maintainer="Enno Boland <gottox@voidlinux.org>"
license="MIT, Apache-2.0"
homepage="https://www.rust-lang.org/"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=4c594c7712a0e7e8eae6526c464bf6ea1d82f77b4f61717c3fc28fb27ba2224a
lib32disabled=yes
patch_args="-Np1"
build_options="internal_llvm"
if [ "$CROSS_BUILD" ]; then
hostmakedepends+=" cargo $(vopt_if internal_llvm '' 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+="
1fa1c8b4b976919e229c8f3ca070ed2235e6f1cecf4967041ef0b8a29a75d517
bfc82c04c46a58ae09be1f32a11a11000830c257969afbf2a270e6eb36d6533a
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+="
75c31f32e19548c1608611d08b82b87560e02f15caac7b2663a8189a4609977c
9f2705a3ed3217c13fd55569406c52f590030752f57520312e135223ae930caf
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+="
45e633c985c259a13d3b096662241bd8255a86ed4917e0fec396e7071c04c734
69bd6064f605c1d0d7d41070efea1e329d75755b04fbc5a13ffc53efdc3a97c7
200cf76636ccbb153d5c430a5c0f3ad5af206899f76470e3cd046679a5a4ab3f"
;;
ppc64le)
distfiles+="
https://static.rust-lang.org/dist/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-gnu.tar.xz"
checksum+="
e41bce347e11e9c4868fec2892778e51ed8f3383bd6ee59dd991376c1dea56a9
b281c20115467429573da6b2b5b7a8863f29e203d7919989e71d91e6914d3bbe
bf426e52beb08e0f663b00b23a89053e713ec15c8e6d69b3f5ae85fe23ad7e18"
;;
ppc64le-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64le-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64le-unknown-linux-musl.tar.xz"
checksum+="
bacb713d86be555af4410d685aab475ac63ad66e358f6b00c058253fba275187
24b6b79356c7bf113ad34f43c14a7a6cec92b9008b05ab58624ce7a353b0e6d0
d9d91997a781753474e89dbb9b7dbbef2f6cfad9387def076d51d654f6bc21fa"
;;
ppc64-musl)
distfiles+="
https://alpha.de.repo.voidlinux.org/distfiles/rustc-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/rust-std-${_rust_dist_version}-powerpc64-unknown-linux-musl.tar.xz
https://alpha.de.repo.voidlinux.org/distfiles/cargo-${_cargo_dist_version}-powerpc64-unknown-linux-musl.tar.xz"
checksum+="
fd090e1329687c1b8e3320b40f0b13640444f93cbb7c235d8491c140337c27df
791d046ecb3203d90263cddb5f53eafdeb042a55923fea35bbb8db223c892603
ec846d1e9674f60dbd4416d54f74a618288114cea4907b61363adc71b3c8c26f"
;;
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
ppc64le) _build_triplet=powerpc64le-unknown-linux-gnu;;
ppc64le-musl) _build_triplet=powerpc64le-unknown-linux-musl;;
ppc64-musl) _build_triplet=powerpc64-unknown-linux-musl;;
*-musl) _build_triplet=${XBPS_MACHINE%-musl}-unknown-linux-musl;;
*) _build_triplet=${XBPS_MACHINE}-unknown-linux-gnu;;
esac
post_extract() {
if [ "$build_option_internal_llvm" ]; then
# patches for Rust's bundled LLVM
pushd src/llvm
for x in ${FILESDIR}/patches/internal_llvm/llvm-*.patch; do
msg_normal "Applying $x to llvm\n"
patch -sNp1 -i ${x}
done
popd
else
rm -rf src/llvm
# patches for system LLVM
for x in ${FILESDIR}/patches/sys-llvm/*.patch; do
msg_normal "Applying patch $x\n"
patch -sNp1 -i ${x}
done
fi
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|ppc64*) 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
"
if ! [ "$build_option_internal_llvm" ]; then
configure_args+="
--llvm-root=/usr
--set=target.${_build_triplet}.llvm-config=/usr/bin/llvm-config
--set=target.${RUST_TARGET}.llvm-config=/usr/bin/llvm-config
--enable-llvm-link-shared
"
fi
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}
"
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.
# Unset LDFLAGS, otherwise cross builds to the same arch will fail
do_build() {
env CFLAGS_${_build_triplet}="${CFLAGS_host}" LDFLAGS='' 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"
archs=noarch
pkg_install() {
vmove usr/share/doc
}
}
rust-std_package() {
short_desc+=" - standard library"
pkg_install() {
vmove usr/lib/rustlib
}
}