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
|
2019-07-31 07:04:00 -05:00
|
|
|
rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
|
2019-08-18 07:57:46 -05:00
|
|
|
rm -r sysroot/ 2>/dev/null || true
|
2018-12-14 06:58:33 -06:00
|
|
|
|
|
|
|
# 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/
|
2019-08-18 04:30:13 -05:00
|
|
|
cp -r target/$TARGET_TRIPLE/$sysroot_channel/deps/* sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
|