Files
codex/codex-rs/bwrap/BUILD.bazel
T
bencodes-oai c123aa2c10 Fix Bazel tool resolution for bubblewrap and voice builds (#61254)
## What changed

- Use the Bazel coreutils toolchain's `sha256sum` to generate `CODEX_BWRAP_SHA256` for bubblewrap.
- Add the running Python interpreter's directory to `PATH` for Unix native voice builds so GLib generators using `env python3` can find it.

## Testing

Add a regression test verifying that a Unix generator using `env python3` runs with the recipe's interpreter.

GitOrigin-RevId: 52694cc09c92db27bc117217d3833a35524ff304
2026-11-13 04:48:28 +00:00

73 lines
2.0 KiB
Python

load("@rules_cc//cc:defs.bzl", "cc_library")
load("//:defs.bzl", "codex_rust_crate")
load("//bazel/rules:runtime_package.bzl", "release_binary")
codex_rust_crate(
name = "bwrap",
# Bazel wires vendored bubblewrap + libcap via :bwrap-ffi below and sets
# bwrap_available explicitly, so we skip Cargo's build.rs in Bazel builds.
build_script_enabled = False,
crate_name = "codex_bwrap",
deps_extra = select({
"@platforms//os:linux": [":bwrap-ffi"],
"//conditions:default": [],
}),
rustc_flags_extra = select({
"@platforms//os:linux": [
"--cfg=bwrap_available",
# TODO(anp) Extract bwrap symbols before stripping.
"-Cstrip=symbols",
],
"//conditions:default": [],
}),
)
release_binary(
binary = ":bwrap",
target_compatible_with = ["@platforms//os:linux"],
)
genrule(
name = "bwrap-sha256-env",
srcs = [":bwrap"],
outs = ["bwrap.sha256.env"],
cmd = " && ".join([
'digest=$$("$(COREUTILS_BIN)" sha256sum < "$<")',
'printf "CODEX_BWRAP_SHA256=%s\\n" "$${digest%% *}" > "$@"',
]),
target_compatible_with = ["@platforms//os:linux"],
toolchains = ["@coreutils_toolchains//:resolved_toolchain"],
visibility = ["//codex-rs/linux-sandbox:__pkg__"],
)
config_setting(
name = "optimized",
values = {"compilation_mode": "opt"},
)
cc_library(
name = "bwrap-ffi",
srcs = ["//codex-rs/vendor:bubblewrap_c_sources"],
hdrs = [
"config.h",
"//codex-rs/vendor:bubblewrap_headers",
],
copts = [
"-D_GNU_SOURCE",
"-Dmain=bwrap_main",
] + select({
# Cargo cc-rs uses release OPT_LEVEL=3 and DEBUG=true, without
# the C toolchain's default NDEBUG; retain native symbols for packaging.
":optimized": [
"-O3",
"-g",
"-UNDEBUG",
],
"//conditions:default": [],
}),
includes = ["."],
target_compatible_with = ["@platforms//os:linux"],
visibility = ["//visibility:private"],
deps = ["@libcap"],
)