void-packages/srcpkgs/rust/template
Leah Neukirchen 2257b4b6a1 rust: update to 1.21.0.
Disable building docs for now, broken __rde_oom?
2017-10-16 14:51:57 +02:00

147 lines
4.9 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.21.0
revision=1
# NB. if you push any(!) new version, don't forget to put a build
# output of musl to https://repo.voidlinux.eu/distfiles/
wrksrc="rustc-${version}-src"
lib32disabled=yes
patch_args="-Np1"
build_style=configure
make_build_args="dist VERBOSE=1"
only_for_archs="i686 x86_64 x86_64-musl"
hostmakedepends="cmake curl pkg-config python"
makedepends="libffi-devel llvm ncurses-devel zlib-devel"
short_desc="Safe, concurrent, practical systems language"
maintainer="Leah Neukirchen <leah@vuxu.org>"
homepage="http://www.rust-lang.org/"
license="MIT, Apache-2.0"
distfiles="https://static.rust-lang.org/dist/rustc-${version}-src.tar.gz"
checksum=1707c142244b5bd909993559c6116c81987c1de21d6207c05d3ecbe5bba548fa
case "$XBPS_MACHINE" in
x86_64-musl)
hostmakedepends+=" libcurl libgit2"
distfiles+="
https://repo.voidlinux.eu/distfiles/rustc-1.20.0-x86_64-unknown-linux-musl.tar.gz
https://repo.voidlinux.eu/distfiles/rust-std-1.20.0-x86_64-unknown-linux-musl.tar.gz
https://repo.voidlinux.eu/distfiles/cargo-0.18.0-x86_64-unknown-linux-musl.tar.gz"
checksum+="
34b84dc375ef8fb9261762e548b49c4e4c652b5cf3696e6a41a110512c3f2471
a5b14cf320e3ead97b2afdd9b5df21fa05515ff5d52d19fc7691b377ad6cc968
28f2ee839f14f8b3edf3f4e4cc8600ac99ea50905ee8fb91116bba676728c2e9"
;;
x86_64)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/2017-08-31/rustc-1.20.0-x86_64-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/2017-08-31/rust-std-1.20.0-x86_64-unknown-linux-gnu.tar.gz
https://s3.amazonaws.com/rust-lang-ci/cargo-builds/6b05583d71f982bcad049b9fa094c637c062e751/cargo-nightly-x86_64-unknown-linux-gnu.tar.gz"
checksum+="
000e776431718a32b5d40c4aa6e09b3425f0b71dea8c95e718d29b8c0f5b35d3
a1b3e13b9d6f9aa713783145cb83070b1dabbe17349043b3528031d7712ca929
d9e69d2b87dc0cf7fafe0e0eb64f82fe3414ef14fcb27f5eeff34df860e459d9"
;;
i686)
# extract from src/stage0.txt
distfiles+="
https://static.rust-lang.org/dist/2017-08-31/rustc-1.20.0-i686-unknown-linux-gnu.tar.gz
https://static.rust-lang.org/dist/2017-08-31/rust-std-1.20.0-i686-unknown-linux-gnu.tar.gz
https://s3.amazonaws.com/rust-lang-ci/cargo-builds/6b05583d71f982bcad049b9fa094c637c062e751/cargo-nightly-i686-unknown-linux-gnu.tar.gz"
checksum+="
f8ee3a910df757b071472146f7c9ed70b0990f20e7a623cf16c8ada4f6e4e620
f18fbdc7217f9b014a823c7308407ef30610ebf32f76d879bfa3e3f6937079df
863a4f92bbeec76257403fd571a90b90bd759ec8bcaddb7517fb89d40959e9e5"
;;
esac
post_extract() {
rm -rf src/llvm
mkdir -p stage0
cp -flr ../rustc-*/rustc/* stage0
cp -flr ../rust-std-*/rust-std-*/* stage0
cp -flr ../cargo-*/cargo/* stage0
# XXX: Cheat Rust build system so we can build rustc using different
# version of (prebuilt) stable rustc than preconfigured. It's hack-ish,
# but since we're basically rebuilding rustc with the same version,
# it's actually safe.
# Note: --enable-local-rebuild from #33787 didn't work, don't know why.
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
rustc_ver="$($wrksrc/stage0/bin/rustc --version | cut -f2 -d ' ')"
rustc_key="$(printf "$rustc_ver" | md5sum | cut -c1-8)"
sed -Ei \
-e "s/^(rustc):.*/\1: $rustc_ver-1970-01-01/" \
-e "s/^(rustc_key):.*/\1: $rustc_key/" \
src/stage0.txt
# Generate config for bootstrap.py to use our prebuilt rustc and cargo
# for bootstrapping instead of downloading snapshot from internet.
cat > config.toml <<EOF
[build]
cargo = "$wrksrc/stage0/bin/cargo"
rustc = "$wrksrc/stage0/bin/rustc"
EOF
sed -i /LD_LIBRARY_PATH/d src/bootstrap/bootstrap.py
}
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
}
do_configure() {
local _triplet
case $XBPS_TARGET_MACHINE in
i686) _triplet=i686-unknown-linux-gnu;;
x86_64) _triplet=x86_64-unknown-linux-gnu;;
x86_64-musl) _triplet=x86_64-unknown-linux-musl;;
*) _triplet=$XBPS_TARGET_MACHINE;;
esac
export LD_LIBRARY_PATH="$wrksrc/stage0/lib"
configure_args="
--prefix=/usr
--host=${_triplet}
--build=${_triplet}
--release-channel=stable
--disable-rpath
--disable-docs
--enable-ccache
--llvm-root=/usr
--enable-local-rust
--local-rust-root=$wrksrc/stage0
"
case "$XBPS_TARGET_MACHINE" in
*-musl)
configure_args+="--musl-root=/usr --disable-jemalloc"
;;
esac
./configure $configure_args
}
do_install() {
vmkdir usr
tar xf build/dist/rustc-*-*-*.tar.gz -C "$DESTDIR/usr" --strip-components=2 --exclude=manifest.in
tar xf build/dist/rust-std-*-*-*.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
}
}