mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
Homebrew's rustup puts cargo and rustup in opt/rustup/bin as two separate wrapper scripts, so the same-file test passed them over and the iOS build stopped. The lookup (now crates/keyboard/tools/rustup-env.sh, which iOS's build, Xcode Cloud's ci_post_clone.sh and Android's Gradle all use) takes a folder whose rustup and cargo, started in crates/keyboard, run the toolchain rust-toolchain.toml pins: rustup's own links in ~/.cargo/bin and Homebrew's wrappers alike. Another cargo, such as Homebrew's `rust` in /opt/homebrew/bin, reports its own version and is still passed over. Xcode Cloud installs the pinned toolchain right after a fresh rustup-init, before looking again.
29 lines
1.5 KiB
Shell
29 lines
1.5 KiB
Shell
# Sourced by ios/scripts/build-keyboard-core.sh, ios/ci_scripts/ci_post_clone.sh and
|
|
# android/app/build.gradle.kts. `find_rustup <crate folder>` sets rustup_bin to a folder that
|
|
# has rustup and rustup's cargo, and fails when there is none. rustup's cargo is whatever runs
|
|
# the toolchain the crate's rust-toolchain.toml pins when started in the crate: rustup's own
|
|
# links in ~/.cargo/bin, or the wrapper scripts Homebrew's rustup puts in opt/rustup/bin (it
|
|
# installs the pinned toolchain on first use, as a build would). Another cargo, such as the one
|
|
# Homebrew's `rust` puts in /opt/homebrew/bin, reports its own version and is passed over. It
|
|
# looks on PATH, then in CARGO_HOME (~/.cargo by default) and ~/.cargo, then in Homebrew's
|
|
# rustup (keg-only in opt/rustup/bin, or linked into bin) under HOMEBREW_PREFIX
|
|
# (/opt/homebrew by default).
|
|
find_rustup() {
|
|
rustup_bin=
|
|
channel=$(sed -n 's/^channel *= *"\(.*\)"$/\1/p' "$1/rust-toolchain.toml")
|
|
[ -n "$channel" ] || return 1
|
|
on_path=$(command -v rustup 2>/dev/null || true)
|
|
brew=${HOMEBREW_PREFIX:-/opt/homebrew}
|
|
for dir in "${on_path%/*}" "${CARGO_HOME:-$HOME/.cargo}/bin" "$HOME/.cargo/bin" \
|
|
"$brew/opt/rustup/bin" "$brew/bin"; do
|
|
[ -n "$dir" ] && [ -x "$dir/rustup" ] && [ -x "$dir/cargo" ] || continue
|
|
version=$(cd "$1" && "$dir/cargo" --version 2>/dev/null) || continue
|
|
case "$version" in
|
|
"cargo $channel "*)
|
|
rustup_bin=$dir
|
|
return 0
|
|
;;
|
|
esac
|
|
done
|
|
return 1
|
|
}
|