Last active
March 21, 2023 16:59
-
-
Save justanotherdot/ca1f163754e9a90f6c6b9dfb25a0598f to your computer and use it in GitHub Desktop.
Attempt to build all cross-compile targets supported by `rustc` and report the time taken.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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