mirror of
https://github.com/openai/codex.git
synced 2026-09-10 20:26:47 +00:00
## What changed - Add a `schema_bundle` rule that generates stable and experimental app-server schema directories as declared Bazel actions. - Include the pinned `zstd` executable in the bundle so consumers can normalize generated JSON without a separate `bazel run` invocation. - Expose the app-server protocol test binary as the schema generator and add the manual `//bazel/schema:public-schema-bundle` target. GitOrigin-RevId: 0a7ce47258d297dbf20db78626f2843145ee1b49
40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
"""Cache schema generation from the filtered public Rust test executable."""
|
|
|
|
def _schema_bundle_impl(ctx):
|
|
outputs = []
|
|
for mode in ["stable", "experimental"]:
|
|
schema = ctx.actions.declare_directory(ctx.label.name + "." + mode)
|
|
ctx.actions.run(
|
|
executable = ctx.executable.generator,
|
|
tools = [ctx.attr.generator[DefaultInfo].files_to_run],
|
|
arguments = [
|
|
"--exact",
|
|
"--ignored",
|
|
"schema_fixtures_tests::write_schema_fixtures_from_env",
|
|
],
|
|
env = {
|
|
"CODEX_APP_SERVER_SCHEMA_ROOT": schema.path,
|
|
"CODEX_APP_SERVER_SCHEMA_EXPERIMENTAL": "1" if mode == "experimental" else "0",
|
|
"RUST_MIN_STACK": "8388608",
|
|
},
|
|
outputs = [schema],
|
|
mnemonic = "PublicSchema",
|
|
progress_message = "Generating %s public app-server schemas" % mode,
|
|
)
|
|
outputs.append(schema)
|
|
|
|
# Expose the pinned compressor alongside the cached directories so callers
|
|
# can normalize the JSON without a separate `bazel run` invocation.
|
|
zstd = ctx.actions.declare_file(ctx.label.name + ".zstd")
|
|
ctx.actions.symlink(output = zstd, target_file = ctx.executable.zstd, is_executable = True)
|
|
return [DefaultInfo(files = depset(outputs + [zstd]))]
|
|
|
|
schema_bundle = rule(
|
|
implementation = _schema_bundle_impl,
|
|
attrs = {
|
|
"generator": attr.label(mandatory = True, executable = True, cfg = "exec"),
|
|
"zstd": attr.label(default = "@zstd//:zstd_cli", executable = True, cfg = "exec"),
|
|
},
|
|
doc = "Generates both schema modes as cacheable actions with explicit tool dependencies.",
|
|
)
|