Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Attempt to build all cross-compile targets supported by `rustc` and report the time taken.
#!/bin/sh -eu
FILTER="${FILTER:="."}"
TOOLCHAIN_BK="$(rustup toolchain list | rg default | awk '{print $1}')"
TOOLCHAIN_KIND_BK="$(echo "$TOOLCHAIN_BK" | rg -o '^(stable|nightly)')"
if [ "$TOOLCHAIN_KIND_BK" != "stable" ]; then
rustup install stable
rustup default stable
fi
TARGETS="$(rustc --print target-list | rg "$FILTER")"
echo "=== Installing targets."
for target in $TARGETS; do
echo "+ $target"
rustup target add "$target" 1>/dev/null 2>&1 || true
done
echo "=== Compiling with collected targets."
for target in $TARGETS; do
cargo clean 1>/dev/null 2>&1
export RUSTC_WRAPPER=
export RUSTFLAGS=
cargo build --target="$target" 2>&1 | awk "/Finished/{ rc = 1; print \"+ $target in\", \$8 }; END { exit !rc }" || echo "- $target"
done
if [ "$TOOLCHAIN_KIND_BK" != "stable" ]; then
rustup default "$TOOLCHAIN_BK"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.