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