]> git.lizzy.rs Git - rust.git/blob - build_sysroot/build_sysroot.sh
Libtest support
[rust.git] / build_sysroot / build_sysroot.sh
1 #!/bin/bash
2
3 # Requires the CHANNEL env var to be set to `debug` or `release.`
4
5 set -e
6 cd $(dirname "$0")
7
8 pushd ../ >/dev/null
9 source ./config.sh
10 popd >/dev/null
11
12 # Cleanup for previous run
13 #     v Clean target dir except for build scripts and incremental cache
14 rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
15 rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true
16 rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
17 rm -r sysroot 2>/dev/null || true
18
19 # Build libs
20 export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
21 if [[ "$1" == "--release" ]]; then
22     sysroot_channel='release'
23     RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
24 else
25     sysroot_channel='debug'
26     cargo build --target $TARGET_TRIPLE
27 fi
28
29 # Copy files to sysroot
30 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
31 cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
32
33 if [[ "$1" == "--release" ]]; then
34     channel='release'
35     RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml
36 else
37     channel='debug'
38     cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml
39 fi
40
41 # Copy files to sysroot
42 cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/