diff --git a/.bazelrc b/.bazelrc index be1ccf8719..7463422fd7 100644 --- a/.bazelrc +++ b/.bazelrc @@ -37,12 +37,14 @@ common:macos --host_linkopt=-Wl,-no_warn_duplicate_libraries # See: https://github.com/grpc/grpc/issues/37619 common:macos --features=-module_maps -# Bake the Xcode build version into action cache keys so that stale -# local/remote cache entries are naturally ignored after Xcode updates. -# Generated by scripts/sync_bazel_xcode.sh (run in CI before every build). -try-import %workspace%/.bazelrc.xcode +# Pin DEVELOPER_DIR so the apple_cc_autoconf repo rule doesn't re-evaluate +# when Xcode updates in-place. The sync script overrides this for mactools. common:macos --repo_env=DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer +# Xcode config for mactools builds only. Generated by scripts/sync_bazel_xcode.sh. +# Bakes the Xcode build version into action cache keys and sets DEVELOPER_DIR. +try-import %workspace%/.bazelrc.xcode + common --java_language_version=25 common --java_runtime_version=remotejdk_25 common --tool_java_language_version=25 diff --git a/.github/workflows/auth_build.yml b/.github/workflows/auth_build.yml index 7cae9e37da..d608248993 100644 --- a/.github/workflows/auth_build.yml +++ b/.github/workflows/auth_build.yml @@ -35,9 +35,6 @@ jobs: with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - - name: Build Auth Server Docker image id: build-auth run: | diff --git a/.github/workflows/bazel_test.yml b/.github/workflows/bazel_test.yml index ab6939ab9a..389f49196b 100644 --- a/.github/workflows/bazel_test.yml +++ b/.github/workflows/bazel_test.yml @@ -44,8 +44,6 @@ jobs: uses: actions/checkout@v4 with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - name: Check BUILD.bazel dependencies run: ./scripts/check_build_deps.sh --strict - name: Set up Node.js @@ -68,8 +66,6 @@ jobs: uses: actions/checkout@v4 with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - name: Run tests run: bazel test --build_event_json_file=test.json //src/test/... //src/main/go/... - name: Collect failed test logs diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index f4a0335581..692b3d888a 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -74,10 +74,6 @@ jobs: with: lfs: false - - name: Sync Bazel Xcode config - if: steps.check-latest.outputs.skip != 'true' - run: ./scripts/sync_bazel_xcode.sh - - name: Fetch LFS files needed for admin server if: steps.check-latest.outputs.skip != 'true' run: git lfs pull --include="src/main/go/net/eagle0/admin_server/static/tiles/*" diff --git a/.github/workflows/eagle_build.yml b/.github/workflows/eagle_build.yml index 2ed40312bd..6a0b037dcd 100644 --- a/.github/workflows/eagle_build.yml +++ b/.github/workflows/eagle_build.yml @@ -29,7 +29,5 @@ jobs: uses: actions/checkout@v4 with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - name: Build Eagle server run: bazel build //src/main/scala/net/eagle0/eagle:eagle_server diff --git a/.github/workflows/shardok_arm64_build.yml b/.github/workflows/shardok_arm64_build.yml index 698fbcd6f2..11f5388fbd 100644 --- a/.github/workflows/shardok_arm64_build.yml +++ b/.github/workflows/shardok_arm64_build.yml @@ -38,9 +38,6 @@ jobs: with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - - name: Build Shardok ARM64 binary (cross-compile for Linux ARM64) run: | set -ex diff --git a/.github/workflows/shardok_build.yml b/.github/workflows/shardok_build.yml index 1885acd4cc..8bdbc95d1a 100644 --- a/.github/workflows/shardok_build.yml +++ b/.github/workflows/shardok_build.yml @@ -30,7 +30,5 @@ jobs: uses: actions/checkout@v4 with: lfs: false - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - name: Build Shardok server run: bazel build -c opt //src/main/cpp/net/eagle0/shardok:shardok-server diff --git a/.github/workflows/unity_build.yml b/.github/workflows/unity_build.yml index 9dc42f6e09..f2e8acf94d 100644 --- a/.github/workflows/unity_build.yml +++ b/.github/workflows/unity_build.yml @@ -111,8 +111,6 @@ jobs: git lfs pull echo "LFS objects after pull:" git lfs ls-files | wc -l - - name: Sync Bazel Xcode config - run: ./scripts/sync_bazel_xcode.sh - name: Ensure Unity version installed run: ./ci/github_actions/ensure_unity_installed.sh windows - name: Build Windows unity diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 139efc7852..12c9bb2263 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -1138,168 +1138,12 @@ }, "@@googleapis+//:extensions.bzl%switched_rules": { "general": { - "bzlTransitiveDigest": "vG6fuTzXD8MMvHWZEQud0MMH7eoC4GXY0va7VrFFh04=", - "usagesDigest": "tB2/BAROtqvrfaBweAJxJpqqnx85mOx/aupy9bEK4Ss=", + "bzlTransitiveDigest": "liqpEiZfQn8ycdEspyJt6J+baY9GQOl+9/prJJz2wTA=", + "usagesDigest": "AtKnJVSfl4DFbEt1Zhzwc971VYZMgmyRYK8WMKrwA7o=", "recordedFileInputs": {}, "recordedDirentsInputs": {}, "envVariables": {}, - "generatedRepoSpecs": { - "com_google_googleapis_imports": { - "repoRuleId": "@@googleapis+//:repository_rules.bzl%switched_rules", - "attributes": { - "rules": { - "proto_library_with_info": [ - "", - "" - ], - "moved_proto_library": [ - "", - "" - ], - "java_proto_library": [ - "", - "" - ], - "java_grpc_library": [ - "", - "" - ], - "java_gapic_library": [ - "", - "" - ], - "java_gapic_test": [ - "", - "" - ], - "java_gapic_assembly_gradle_pkg": [ - "", - "" - ], - "py_proto_library": [ - "", - "" - ], - "py_grpc_library": [ - "", - "" - ], - "py_gapic_library": [ - "", - "" - ], - "py_test": [ - "", - "" - ], - "py_gapic_assembly_pkg": [ - "", - "" - ], - "py_import": [ - "", - "" - ], - "go_proto_library": [ - "", - "" - ], - "go_grpc_library": [ - "", - "" - ], - "go_library": [ - "", - "" - ], - "go_test": [ - "", - "" - ], - "go_gapic_library": [ - "", - "" - ], - "go_gapic_assembly_pkg": [ - "", - "" - ], - "cc_proto_library": [ - "", - "" - ], - "cc_grpc_library": [ - "", - "" - ], - "cc_gapic_library": [ - "", - "" - ], - "php_proto_library": [ - "", - "php_proto_library" - ], - "php_grpc_library": [ - "", - "php_grpc_library" - ], - "php_gapic_library": [ - "", - "php_gapic_library" - ], - "php_gapic_assembly_pkg": [ - "", - "php_gapic_assembly_pkg" - ], - "nodejs_gapic_library": [ - "", - "typescript_gapic_library" - ], - "nodejs_gapic_assembly_pkg": [ - "", - "typescript_gapic_assembly_pkg" - ], - "ruby_proto_library": [ - "", - "" - ], - "ruby_grpc_library": [ - "", - "" - ], - "ruby_ads_gapic_library": [ - "", - "" - ], - "ruby_cloud_gapic_library": [ - "", - "" - ], - "ruby_gapic_assembly_pkg": [ - "", - "" - ], - "csharp_proto_library": [ - "", - "" - ], - "csharp_grpc_library": [ - "", - "" - ], - "csharp_gapic_library": [ - "", - "" - ], - "csharp_gapic_assembly_pkg": [ - "", - "" - ] - } - } - } - }, + "generatedRepoSpecs": {}, "recordedRepoMappingEntries": [] } }, @@ -1399,34 +1243,6 @@ "recordedRepoMappingEntries": [] } }, - "@@rules_apple+//apple:extensions.bzl%non_module_deps": { - "general": { - "bzlTransitiveDigest": "UsflLeiazyu2v5pvibcvOeIdDV95S25rT96h4XU1nhY=", - "usagesDigest": "M3VqFpeTCo4qmrNKGZw0dxBHvTYDrfV3cscGzlSAhQ4=", - "recordedFileInputs": {}, - "recordedDirentsInputs": {}, - "envVariables": {}, - "generatedRepoSpecs": { - "xctestrunner": { - "repoRuleId": "@@bazel_tools//tools/build_defs/repo:http.bzl%http_archive", - "attributes": { - "urls": [ - "https://github.com/google/xctestrunner/archive/b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6.tar.gz" - ], - "strip_prefix": "xctestrunner-b7698df3d435b6491b4b4c0f9fc7a63fbed5e3a6", - "sha256": "ae3a063c985a8633cb7eb566db21656f8db8eb9a0edb8c182312c7f0db53730d" - } - } - }, - "recordedRepoMappingEntries": [ - [ - "rules_apple+", - "bazel_tools", - "bazel_tools" - ] - ] - } - }, "@@rules_dotnet+//dotnet:extensions.bzl%dotnet": { "general": { "bzlTransitiveDigest": "fd+R6GHICVvxgxz6YGDAcp7EbUx26nq9MWH1unOHz9I=", diff --git a/scripts/sync_bazel_xcode.sh b/scripts/sync_bazel_xcode.sh index 6088ed901a..8747099916 100755 --- a/scripts/sync_bazel_xcode.sh +++ b/scripts/sync_bazel_xcode.sh @@ -1,12 +1,16 @@ #!/usr/bin/env bash -# Keeps Bazel in sync with the installed Xcode version. Two mechanisms: +# Keeps Bazel mactools builds in sync with the installed Xcode version. # -# 1. Writes .bazelrc.xcode with --action_env=XCODE_BUILD_VERSION= -# so the version is part of every action's cache key. This prevents stale -# remote cache entries from being reused after an Xcode update. +# 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. +# +# 1. Writes .bazelrc.xcode with mactools-scoped flags: +# - action_env for remote cache key invalidation +# - DEVELOPER_DIR pointing to the active Xcode # # 2. Runs `bazel clean --expunge` when the version actually changes, because -# local_config_xcode (a cached repository rule) bakes in the old version +# local_config_apple_cc (a cached repository rule) bakes in the old version # and can only be refreshed by clearing the output base. # # .bazelrc imports the generated file via: try-import %workspace%/.bazelrc.xcode @@ -20,23 +24,31 @@ if [ -z "$XCODE_BUILD_VERSION" ]; then exit 0 fi -BAZELRC_XCODE=".bazelrc.xcode" -EXPECTED="common --action_env=XCODE_BUILD_VERSION=${XCODE_BUILD_VERSION}" +DEVELOPER_DIR=$(xcode-select -p 2>/dev/null) -# If the file already has the right version, nothing to do -if [ -f "$BAZELRC_XCODE" ] && [ "$(cat "$BAZELRC_XCODE")" = "$EXPECTED" ]; then - exit 0 +BAZELRC_XCODE=".bazelrc.xcode" +EXPECTED_LINE="common:mactools --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 + CURRENT_FIRST_LINE=$(head -1 "$BAZELRC_XCODE") + if [ "$CURRENT_FIRST_LINE" = "$EXPECTED_LINE" ]; then + exit 0 + fi fi # Xcode version changed (or first run) — expunge local cache to clear -# stale local_config_xcode, then write the new version for remote cache keys +# stale local_config_apple_cc, then write the new config OLD_VERSION="unknown" if [ -f "$BAZELRC_XCODE" ]; then - OLD_VERSION=$(sed -n 's/.*XCODE_BUILD_VERSION=//p' "$BAZELRC_XCODE") + OLD_VERSION=$(sed -n 's/.*XCODE_BUILD_VERSION=//p' "$BAZELRC_XCODE" | head -1) fi echo "Xcode build version changed: ${OLD_VERSION} -> ${XCODE_BUILD_VERSION}" echo "Running bazel clean --expunge to clear stale toolchain config..." bazel clean --expunge 2>/dev/null || true -echo "$EXPECTED" > "$BAZELRC_XCODE" -echo "Updated ${BAZELRC_XCODE} — next build will do a full rebuild with Xcode ${XCODE_BUILD_VERSION}" +cat > "$BAZELRC_XCODE" << EOF +${EXPECTED_LINE} +common:mactools --repo_env=DEVELOPER_DIR=${DEVELOPER_DIR} +EOF +echo "Updated ${BAZELRC_XCODE} — next mactools build will rebuild with Xcode ${XCODE_BUILD_VERSION}"