]> git.lizzy.rs Git - rust.git/blob - build_sysroot/build_sysroot.sh
Stop using xargo for building the sysroot
[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 export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked --sysroot ../"
23 if [[ "$1" == "--release" ]]; then
24     channel='release'
25     RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
26 else
27     channel='debug'
28     cargo build --target $TARGET_TRIPLE
29 fi
30
31 # Copy files to sysroot
32 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
33 cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/