]> git.lizzy.rs Git - rust.git/blobdiff - build_sysroot/build_sysroot.sh
Merge pull request #660 from bjorn3/libtest
[rust.git] / build_sysroot / build_sysroot.sh
index ea5e4a169e566f1e337fe43c0952aad77ef891af..4e58858f133daf416d6b5055867eaf50d791a0c5 100755 (executable)
@@ -1,32 +1,42 @@
 #!/bin/bash
+
+# Requires the CHANNEL env var to be set to `debug` or `release.`
+
 set -e
 cd $(dirname "$0")
 
+pushd ../ >/dev/null
+source ./config.sh
+popd >/dev/null
+
 # Cleanup for previous run
 #     v Clean target dir except for build scripts and incremental cache
+rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} || true
+rm -r sysroot_src/src/{libcore,libtest}/target/$TARGET_TRIPLE/$sysroot_channel/ || true
+rm Cargo.lock test_target/Cargo.lock 2>/dev/null || true
 rm -r sysroot 2>/dev/null || true
 
-# FIXME find a better way to get the target triple
-unamestr=`uname`
-if [[ "$unamestr" == 'Linux' ]]; then
-   TARGET_TRIPLE='x86_64-unknown-linux-gnu'
-elif [[ "$unamestr" == 'Darwin' ]]; then
-   TARGET_TRIPLE='x86_64-apple-darwin'
+# Build libs
+export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
+if [[ "$1" == "--release" ]]; then
+    sysroot_channel='release'
+    RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
 else
-   echo "Unsupported os"
-   exit 1
+    sysroot_channel='debug'
+    cargo build --target $TARGET_TRIPLE
 fi
 
-# Build libs
+# Copy files to sysroot
 mkdir -p sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
-export RUSTFLAGS="$RUSTFLAGS -Z force-unstable-if-unmarked"
+cp target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
+
 if [[ "$1" == "--release" ]]; then
     channel='release'
-    RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release
+    RUSTFLAGS="$RUSTFLAGS -Zmir-opt-level=3" cargo build --target $TARGET_TRIPLE --release --manifest-path ./sysroot_src/src/libtest/Cargo.toml
 else
     channel='debug'
-    cargo build --target $TARGET_TRIPLE
+    cargo build --target $TARGET_TRIPLE --manifest-path ./sysroot_src/src/libtest/Cargo.toml
 fi
 
 # Copy files to sysroot
-cp target/$TARGET_TRIPLE/$channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/
+cp sysroot_src/src/libtest/target/$TARGET_TRIPLE/$sysroot_channel/deps/*.rlib sysroot/lib/rustlib/$TARGET_TRIPLE/lib/