]> git.lizzy.rs Git - rust.git/blob - build_sysroot/build_sysroot.sh
Remove unnecessary changes
[rust.git] / build_sysroot / build_sysroot.sh
1 #!/bin/bash
2 set -e
3 cd $(dirname "$0")
4
5 # Cleanup for previous run
6 #     v Clean target dir except for build scripts and incremental cache
7 rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
8 rm Cargo.lock 2>/dev/null || true
9 rm -r sysroot 2>/dev/null || true
10
11 # FIXME find a better way to get the target triple
12 unamestr=`uname`
13 if [[ "$unamestr" == 'Linux' ]]; then
14    TARGET_TRIPLE='x86_64-unknown-linux-gnu'
15 elif [[ "$unamestr" == 'Darwin' ]]; then
16    TARGET_TRIPLE='x86_64-apple-darwin'
17 else
18    echo "Unsupported os"
19    exit 1
20 fi
21
22 # Build libs
23 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
24 export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
25 if [[ "$1" == "--release" ]]; then
26     channel='release'
27     RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
28 else
29     channel='debug'
30     cargo build --target $TARGET_TRIPLE
31 fi
32
33 # Copy files to sysroot
34 cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/