Files
codex/codex-rs/app-server-protocol/BUILD.bazel
T
jif 6f8bf683ce Disable optimization for the on-demand Bazel schema generator (#57723)
## Why

The short-lived schema exporter sits on the critical path of application builds. Optimizing its full test harness adds unnecessary compilation work.

## What changed

Compile `schema-generator-on-demand` with `-Copt-level=0` and keep debug assertions disabled with `-Cdebug-assertions=no`, preserving exec-mode assertion behavior.

GitOrigin-RevId: ef1b3a80d9484e1656349ed0d2cc2d63e5e17624
2026-10-28 12:49:59 +00:00

84 lines
2.3 KiB
Python

load("@crates//:defs.bzl", "all_crate_deps")
load("@rules_rust//rust:defs.bzl", "rust_binary")
load("//:defs.bzl", "WINDOWS_RUSTC_LINK_FLAGS", "codex_rust_crate")
load("//bazel/rules:schema_bundle.bzl", "schema_sources")
schema_sources(
name = "schema-sources",
srcs = glob(["src/**/*.rs"]),
schema = "//bazel/schema:app-server",
)
filegroup(
name = "schema-precomputed",
srcs = [":schema-sources"],
output_group = "precomputed",
)
codex_rust_crate(
name = "app-server-protocol",
compile_data = [":schema-precomputed"],
crate_name = "codex_app_server_protocol",
crate_srcs = [":schema-sources"],
test_data_extra = glob(
["schema/**"],
allow_empty = True,
),
)
alias(
name = "schema-generator",
testonly = True,
actual = ":app-server-protocol-unit-tests-bin",
tags = ["manual"],
visibility = ["//bazel/schema:__pkg__"],
)
schema_sources(
name = "schema-generator-sources",
srcs = glob(["src/**/*.rs"]),
tags = ["manual"],
)
filegroup(
name = "schema-generator-root",
srcs = [":schema-generator-sources"],
output_group = "crate_root",
tags = ["manual"],
)
filegroup(
name = "schema-generator-placeholders",
srcs = [":schema-generator-sources"],
output_group = "precomputed",
tags = ["manual"],
)
# Compile the crate's test harness, including its unit tests.
# Each schema action runs only write_schema_fixtures_from_env via --exact --ignored.
rust_binary(
name = "schema-generator-on-demand",
srcs = [":schema-generator-sources"],
compile_data = [":schema-generator-placeholders"],
crate_name = "codex_app_server_protocol",
crate_root = ":schema-generator-root",
edition = "2024",
rustc_env = {
"BAZEL_PACKAGE": "codex-rs/app-server-protocol",
"CARGO_PKG_NAME": "codex-app-server-protocol",
},
# This short-lived exporter sits on application builds' critical path. Avoid
# optimizing its full test harness, retaining exec-mode assertion behavior.
rustc_flags = [
"--test",
"-Copt-level=0",
"-Cdebug-assertions=no",
] + WINDOWS_RUSTC_LINK_FLAGS,
tags = ["manual"],
visibility = ["//bazel/schema:__pkg__"],
deps = all_crate_deps(
normal = True,
normal_dev = True,
),
)