rust/build_sysroot/build_sysroot.sh
bjorn3 1e5c6bc5b8 Stop using xargo for building the sysroot
It is currently broken. (see https://github.com/japaric/xargo/issues/227)

This makes it easier to for example patch whole crates away.
2018-12-15 16:18:03 +01:00

34 lines
884 B
Bash
Executable File

#!/bin/bash
set -e
cd $(dirname "$0")
# Cleanup for previous run
cargo clean
rm Cargo.lock 2>/dev/null || true
rm -r sysroot 2>/dev/null || true
# FIXME find a better way to get the target triple
unamestr=`uname`
if [[ "$unamestr" == 'Linux' ]]; then
TARGET_TRIPLE='x86_64-unknown-linux-gnu'
elif [[ "$unamestr" == 'Darwin' ]]; then
TARGET_TRIPLE='x86_64-apple-darwin'
else
echo "Unsupported os"
exit 1
fi
# Build libs
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot ../"
if [[ "$1" == "--release" ]]; then
channel='release'
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
else
channel='debug'
cargo build --target $TARGET_TRIPLE
fi
# Copy files to sysroot
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/