2018-12-14 06:58:33 -06:00
|
|
|
#!/bin/bash
|
2019-07-30 06:37:47 -05:00
|
|
|
|
|
|
|
# Requires the CHANNEL env var to be set to `debug` or `release.`
|
|
|
|
|
2018-12-14 06:58:33 -06:00
|
|
|
set -e
|
|
|
|
cd $(dirname "$0")
|
|
|
|
|
2019-07-30 06:37:47 -05:00
|
|
|
pushd ../ >/dev/null
|
|
|
|
source ./config.sh
|
|
|
|
popd >/dev/null
|
|
|
|
|
2018-12-14 06:58:33 -06:00
|
|
|
# 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
|
|
|
|
|
|
|
|
# Build libs
|
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
|
2019-07-30 06:37:47 -05:00
|
|
|
sysroot_channel='release'
|
2018-12-14 06:58:33 -06:00
|
|
|
RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
|
|
|
|
else
|
2019-07-30 06:37:47 -05:00
|
|
|
sysroot_channel='debug'
|
2018-12-14 06:58:33 -06:00
|
|
|
cargo build --target $TARGET_TRIPLE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy files to sysroot
|
2019-07-30 06:37:47 -05:00
|
|
|
mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|
|
|
|
cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|