From c73d50c33dc60b2e0fb39f065e71245e635da141 Mon Sep 17 00:00:00 2001 From: Adam Perry Date: Fri, 5 Jun 2026 23:33:51 +0000 Subject: [PATCH] bazel: define release bundle platforms --- .github/workflows/bazel.yml | 18 +++++++++++++++ BUILD.bazel | 46 +++++++++++++++++++++++++++++++++++++ defs.bzl | 24 +++++++++---------- 3 files changed, 76 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index f17d6dbd30..2f3deb1c26 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -560,6 +560,24 @@ jobs: -- \ "${bazel_targets[@]}" + - name: Analyze Bazel release bundle + if: runner.os == 'Linux' + env: + BUILDBUDDY_API_KEY: ${{ secrets.BUILDBUDDY_API_KEY }} + shell: bash + run: | + # Keep the documented `just build-for-release` target's platform + # transitions covered without compiling every release artifact in CI. + ./.github/scripts/run-bazel-ci.sh \ + --print-failed-action-summary \ + -- \ + build \ + --nobuild \ + --build_metadata=COMMIT_SHA=${GITHUB_SHA} \ + --build_metadata=TAG_job=analyze-release-bundle \ + -- \ + //codex-rs/cli:release_binaries + - name: Verify Bazel builds bwrap if: runner.os == 'Linux' env: diff --git a/BUILD.bazel b/BUILD.bazel index dfd46bd8ca..6dfec359f4 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -56,6 +56,52 @@ platform( ], ) +# Release bundles cross-compile from the host and need the complete constraint +# set expected by both the Rust and LLVM toolchains. +platform( + name = "release_linux_arm64_musl", + constraint_values = [ + "@llvm//constraints/libc:musl", + "@llvm//constraints/pie:off", + "@platforms//cpu:aarch64", + "@platforms//os:linux", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "release_linux_amd64_musl", + constraint_values = [ + "@llvm//constraints/libc:musl", + "@llvm//constraints/pie:off", + "@platforms//cpu:x86_64", + "@platforms//os:linux", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "release_windows_amd64", + constraint_values = [ + "@llvm//constraints/windows_abi:gnullvm", + "@platforms//cpu:x86_64", + "@platforms//os:windows", + "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm", + ], + visibility = ["//visibility:public"], +) + +platform( + name = "release_windows_arm64", + constraint_values = [ + "@llvm//constraints/windows_abi:gnullvm", + "@platforms//cpu:aarch64", + "@platforms//os:windows", + "@rules_rs//rs/experimental/platforms/constraints:windows_gnullvm", + ], + visibility = ["//visibility:public"], +) + toolchain( name = "windows_gnullvm_tests_on_msvc_host_toolchain", exec_compatible_with = [ diff --git a/defs.bzl b/defs.bzl index 4af81ecef1..fd4168b26a 100644 --- a/defs.bzl +++ b/defs.bzl @@ -4,14 +4,14 @@ load("@rules_platform//platform_data:defs.bzl", "platform_data") load("@rules_rust//cargo/private:cargo_build_script_wrapper.bzl", "cargo_build_script") load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_library", "rust_proc_macro", "rust_test") -PLATFORMS = [ - "linux_arm64_musl", - "linux_amd64_musl", - "macos_amd64", - "macos_arm64", - "windows_amd64", - "windows_arm64", -] +PLATFORMS = { + "linux_arm64_musl": "//:release_linux_arm64_musl", + "linux_amd64_musl": "//:release_linux_amd64_musl", + "macos_amd64": "@llvm//platforms:macos_amd64", + "macos_arm64": "@llvm//platforms:macos_arm64", + "windows_amd64": "//:release_windows_amd64", + "windows_arm64": "//:release_windows_arm64", +} # Match Cargo's Windows linker behavior so Bazel-built binaries and tests use # the same stack reserve on both Windows ABIs and resolve UCRT imports on MSVC. @@ -54,17 +54,17 @@ MACOS_WEBRTC_RUSTC_LINK_FLAGS = select({ }) def multiplatform_binaries(name, platforms = PLATFORMS): - for platform in platforms: + for platform_name, platform_label in platforms.items(): platform_data( - name = name + "_" + platform, - platform = "@llvm//platforms:" + platform, + name = name + "_" + platform_name, + platform = platform_label, target = name, tags = ["manual"], ) native.filegroup( name = "release_binaries", - srcs = [name + "_" + platform for platform in platforms], + srcs = [name + "_" + platform for platform in platforms.keys()], tags = ["manual"], )