2018-12-14 12:58:33 +00:00
|
|
|
#!/bin/bash
|
2019-07-30 11:37:47 +00:00
|
|
|
|
|
|
|
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
|
|
|
|
2018-12-14 12:58:33 +00:00
|
|
|
set -e
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
2019-07-30 11:37:47 +00:00
|
|
|
pushd ../ >/dev/null
|
|
|
|
source ./config.sh
|
|
|
|
popd >/dev/null
|
|
|
|
|
2018-12-14 12:58:33 +00:00
|
|
|
# Cleanup for previous run
|
2019-04-24 14:35:58 +00: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 12:58:33 +00:00
|
|
|
rm Cargo.lock 2>/dev/null || true
|
|
|
|
rm -r sysroot 2>/dev/null || true
|
|
|
|
|
|
|
|
# Build libs
|
2019-04-10 14:50:50 +00:00
|
|
|
export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
|
2018-12-14 12:58:33 +00:00
|
|
|
if [[ "$1" == "--release" ]]; then
|
2019-07-30 11:37:47 +00:00
|
|
|
sysroot_channel='release'
|
2018-12-14 12:58:33 +00:00
|
|
|
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
|
|
|
|
else
|
2019-07-30 11:37:47 +00:00
|
|
|
sysroot_channel='debug'
|
2018-12-14 12:58:33 +00:00
|
|
|
cargo build --target $TARGET_TRIPLE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to sysroot
|
2019-07-30 11:37:47 +00:00
|
|
|
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
|
|
|
cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|