void-packages/srcpkgs/rust/template
2018-01-08 22:37:38 +01:00

152 lines
4.9 KiB
Bash

# Template file for 'rust'
pkgname=rust
version=1.23.0
revision=1
_date=2018-01-02
# 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 llvm3.9 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=7464953871dcfdfa8afcc536916a686dd156a83339d8ec4d5cb4eb2fe146cb91
case "$XBPS_MACHINE" in
x86_64-musl)
hostmakedepends+=" libcurl libgit2"
distfiles+="
https://repo.voidlinux.eu/distfiles/rustc-1.22.1-x86_64-unknown-linux-musl.tar.gz
https://repo.voidlinux.eu/distfiles/rust-std-1.22.1-x86_64-unknown-linux-musl.tar.gz
https://repo.voidlinux.eu/distfiles/cargo-0.24.0-x86_64-unknown-linux-musl.tar.gz"
checksum+="
2a2a807a11bc41dd52649edcd2e96552694f037b478066f5b96dc02d70159f05
0eb41deb30ce8158077adb291e49cdd3447f0949c5827858ce022462825b36fc
8a784a2318eea7bfd7db7d854f51dc31a25ed866757bc948babbb8edb3ba41a0"
;;
x86_64)
# extract from src/stage0.txt
distfiles+="
https://dev-static.rust-lang.org/dist/2017-11-20/rustc-1.22.0-x86_64-unknown-linux-gnu.tar.gz
https://dev-static.rust-lang.org/dist/2017-11-20/rust-std-1.22.0-x86_64-unknown-linux-gnu.tar.gz
https://dev-static.rust-lang.org/dist/${_date}/cargo-0.24.0-x86_64-unknown-linux-gnu.tar.xz"
checksum+="
a54835b06f960cb04507136a6491e561271374701bc38a8e8fd085f9e78e12e6
c065c4958444955968aae60a3724bea177ddabf364c5b8cf29a08dd5d1e7df6f
93b953c8c7a2088aef952de8dccd7f6ccf9b21bf94b735d3909961ffe831da8c"
;;
i686)
# extract from src/stage0.txt
distfiles+="
https://dev-static.rust-lang.org/dist/2017-11-20/rustc-1.22.0-i686-unknown-linux-gnu.tar.gz
https://dev-static.rust-lang.org/dist/2017-11-20/rust-std-1.22.0-i686-unknown-linux-gnu.tar.gz
https://dev-static.rust-lang.org/dist/${_date}/cargo-0.24.0-i686-unknown-linux-gnu.tar.xz"
checksum+="
fb5d94ccdfa5d60ca35b7aa8b2f60b82a2e1c67ae41acc3744549eaebd1f1ddf
5ec4414598cfbba4114a343911042c8f01b6284cab386e52bd37c0adea56582b
6ffc847e0ee2a1273223ce500f7b212d051e99a6d234e34585d0c55e21a963ea"
;;
esac
post_extract() {
rm -rf src/llvm
mkdir -p stage0
cp -flr ../rustc-*/rustc/* stage0
cp -flr ../rust-std-*/rust-std-*/* stage0
case "$XBPS_MACHINE" in
*-musl) cp -flr ../cargo stage0/bin;;
*) cp -flr ../cargo-*/cargo/* stage0;;
esac
# 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
--disable-codegen-tests
--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
}
}