2018-12-14 06:58:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
|
|
|
# Cleanup for previous run
|
2019-04-24 09:35:58 -05:00
|
|
|
# v Clean target dir except for build scripts and incremental cache
|
|
|
|
rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
|
2018-12-14 06:58:33 -06:00
|
|
|
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
|
2018-12-28 10:15:13 -06:00
|
|
|
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
2019-04-10 09:50:50 -05:00
|
|
|
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
|
2018-12-14 06:58:33 -06:00
|
|
|
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
|
|
|
|
cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|