Apply Xcode sync to all macOS Bazel builds (#6807)

This commit is contained in:
2026-05-29 18:10:24 -07:00
committed by GitHub
parent ff7fcbcac8
commit 2536e43e56
2 changed files with 14 additions and 12 deletions
+9 -8
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
# Keeps Bazel mactools builds in sync with the installed Xcode version.
# Keeps Bazel macOS builds in sync with the installed Xcode version.
#
# Only needed on runners that do mactools builds (Mac/Sparkle). Non-Mac builds
# don't run this script; their apple_cc_autoconf stays cached because none of
# its environ vars change, so they're unaffected by Xcode version changes.
# Needed on macOS runners and developer machines because Bazel's generated
# local_config_xcode/local_config_apple_cc repositories bake in the discovered
# Xcode version. If Xcode is upgraded in place, the DEVELOPER_DIR path stays the
# same, so Bazel can otherwise keep using stale Xcode metadata.
#
# 1. Writes .bazelrc.xcode with mactools-scoped flags:
# 1. Writes .bazelrc.xcode with macOS-scoped flags:
# - action_env for remote cache key invalidation
# - DEVELOPER_DIR pointing to the active Xcode
#
@@ -34,7 +35,7 @@ if [ -z "$XCODE_BUILD_VERSION" ]; then
fi
BAZELRC_XCODE=".bazelrc.xcode"
EXPECTED_LINE="common:mactools --action_env=XCODE_BUILD_VERSION=${XCODE_BUILD_VERSION}"
EXPECTED_LINE="common:macos --action_env=XCODE_BUILD_VERSION=${XCODE_BUILD_VERSION}"
# Check if the file already has the right version (first line is the version marker)
if [ -f "$BAZELRC_XCODE" ]; then
@@ -56,11 +57,11 @@ bazel clean --expunge 2>/dev/null || true
cat > "$BAZELRC_XCODE" << EOF
${EXPECTED_LINE}
common:mactools --repo_env=DEVELOPER_DIR=${DEVELOPER_DIR}
common:macos --repo_env=DEVELOPER_DIR=${DEVELOPER_DIR}
EOF
if [ -n "${GITHUB_ENV:-}" ]; then
echo "DEVELOPER_DIR=${DEVELOPER_DIR}" >> "$GITHUB_ENV"
fi
echo "Updated ${BAZELRC_XCODE} — next mactools build will rebuild with Xcode ${XCODE_BUILD_VERSION}"
echo "Updated ${BAZELRC_XCODE} — next macOS Bazel build will rebuild with Xcode ${XCODE_BUILD_VERSION}"