-cargo clean
-rm 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'
-else
- echo "Unsupported os"
- exit 1
-fi
+# v Clean target dir except for build scripts and incremental cache
+rm -r target/*/{debug,release}/{build,deps,examples,libsysroot*,native} 2>/dev/null || true
+
+# We expect the target dir in the default location. Guard against the user changing it.
+export CARGO_TARGET_DIR=target