#!/usr/bin/env bash # The Mac CI toolchain for a Swift job: cargo on PATH (the Mac's own rustup or # one under ~/.cache/cottondb/rust), the channel crates/rust-toolchain.toml # names, the two iOS targets, xcodegen. Writes CARGO_TARGET_DIR, # COTTON_CARGO_LOCK, RUSTUP_TOOLCHAIN (and CARGO_HOME/RUSTUP_HOME when it made # them) to $GITHUB_ENV and the toolchain's bin to $GITHUB_PATH, as verify-main's # Mac jobs do inline. Used by swift-main.yml. # # bash scripts/ci/mac-toolchain.sh set -euo pipefail ref="${1:?usage: mac-toolchain.sh }" root="$HOME/.cache/cottondb/rust" target="$(bash scripts/ci/cargo-target-dir.sh --ensure "$ref")" { echo "CARGO_TARGET_DIR=$target" echo "COTTON_CARGO_LOCK=$target.lock" } >> "$GITHUB_ENV" echo "CARGO_TARGET_DIR for '$ref' is $target" if [ -x "$HOME/.cargo/bin/cargo" ]; then echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" export PATH="$HOME/.cargo/bin:$PATH" else export CARGO_HOME="$root/cargo" RUSTUP_HOME="$root/rustup" mkdir -p "$CARGO_HOME" "$RUSTUP_HOME" { echo "CARGO_HOME=$CARGO_HOME" echo "RUSTUP_HOME=$RUSTUP_HOME" } >> "$GITHUB_ENV" if [ ! -x "$CARGO_HOME/bin/rustup" ]; then curl -fsSL --proto '=https' --tlsv1.2 https://sh.rustup.rs \ | sh -s -- -y --profile minimal --default-toolchain none --no-modify-path fi echo "$CARGO_HOME/bin" >> "$GITHUB_PATH" export PATH="$CARGO_HOME/bin:$PATH" fi channel="$(sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/p' crates/rust-toolchain.toml | head -1)" if [ -z "$channel" ]; then echo "::error::crates/rust-toolchain.toml names no channel — the toolchain source moved." exit 1 fi echo "RUSTUP_TOOLCHAIN=$channel" >> "$GITHUB_ENV" export RUSTUP_TOOLCHAIN="$channel" echo "RUSTUP_TOOLCHAIN is $channel, read from crates/rust-toolchain.toml" cargo --version # shellcheck source=../lib/rustup-lock.sh . scripts/lib/rustup-lock.sh (cd crates && with_rustup_lock rustup target add aarch64-apple-ios aarch64-apple-ios-sim) with_rustup_lock rustup target list --installed if ! command -v xcodegen >/dev/null 2>&1; then echo "xcodegen is not installed on $(scutil --get ComputerName) — installing it." HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_NO_INSTALL_CLEANUP=1 brew install xcodegen fi command -v xcodegen >/dev/null 2>&1 || { echo "::error::xcodegen is still not on PATH after \`brew install xcodegen\`; fix this machine's Homebrew." exit 1 } xcodegen --version xcodebuild -version