hex/ios/ci_scripts/ci_post_clone.sh
Sebastian Herrlinger c3fa08c690 Keyboard core builds take Homebrew's rustup: a cargo that runs the pinned toolchain
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.
2026-11-22 20:02:35 +01:00

50 lines
2.5 KiB
Shell
Executable file

#!/bin/sh
set -eu
# The Xcode project is generated; the full dependency graph is checked in.
if [ -n "${CI_PRIMARY_REPOSITORY_PATH:-}" ]; then
cd "$CI_PRIMARY_REPOSITORY_PATH/ios"
else
cd "$(dirname "$0")/.."
fi
command -v xcodegen >/dev/null || brew install xcodegen
# An App Store build is tagged ios-beta-appstore-<version> (e.g. ios-beta-appstore-0.2.1):
# it is stamped with that version, while the repo and TestFlight stay on project.yml's.
case "${CI_TAG:-}" in
ios-beta-appstore-*)
version="${CI_TAG#ios-beta-appstore-}"
case "$version" in
*[!0-9.]* | "" | .* | *.) echo "Bad App Store version in tag: $CI_TAG" >&2; exit 1 ;;
esac
sed -i '' -E "s/^( +MARKETING_VERSION: ).*/\1$version/" project.yml
grep -n 'MARKETING_VERSION' project.yml
;;
esac
scripts/fetch-cleanup-model.sh
# The keyboard's Rust core (scripts/build-keyboard-core.sh) builds with rustup and the
# toolchain crates/keyboard pins (rust-toolchain.toml). Without a rustup the build script
# would find (crates/keyboard/tools/rustup-env.sh), install one: rustup-init 1.29.3 from its
# versioned URL, checked against the SHA-256 static.rust-lang.org publishes beside it, into
# CARGO_HOME (~/.cargo by default).
. ../crates/keyboard/tools/rustup-env.sh
if ! find_rustup ../crates/keyboard; then
case "$(uname -m)" in
arm64) host=aarch64-apple-darwin sha256=63752a1919a3a4793173ec70f8f212621a7ce38ba6a246095984482f4de20f9f ;;
x86_64) host=x86_64-apple-darwin sha256=bc107f1fb0228de7fa32413c89c1b305cea9cd256e94b01150cd054128145429 ;;
*) echo "No rustup-init for $(uname -m)" >&2; exit 1 ;;
esac
init="$(mktemp -d)/rustup-init"
curl --proto '=https' --tlsv1.2 -sSf -o "$init" "https://static.rust-lang.org/rustup/archive/1.29.3/$host/rustup-init"
echo "$sha256 $init" | shasum -a 256 -c - >/dev/null
chmod +x "$init"
"$init" -y -q --profile minimal --default-toolchain none --no-modify-path
(cd ../crates/keyboard && "${CARGO_HOME:-$HOME/.cargo}/bin/rustup" -q toolchain install)
find_rustup ../crates/keyboard || { echo "rustup-init left no rustup where the build looks for it" >&2; exit 1; }
fi
(cd ../crates/keyboard && "$rustup_bin/rustup" -q toolchain install)
xcodegen generate
pins=HEXMobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm
mkdir -p "$pins"
cp Package.resolved "$pins/Package.resolved"
xcodebuild -resolvePackageDependencies -project HEXMobile.xcodeproj -scheme HEXMobile \
-disableAutomaticPackageResolution -onlyUsePackageVersionsFromResolvedFile