Rinomina: crate akode-*, cartelle akode-rs/ e akode-cli/, binario akode, ~/.akode, AKODE_* (A)
Riapplica la fase 5 di aKode (86e7c72e) sulla base ripulita:
- crate codex-* -> akode-*, codex-rs -> akode-rs, codex-cli -> akode-cli, binario e ausiliari akode;
- ~/.codex -> ~/.akode, CODEX_HOME -> AKODE_HOME, variabili CODEX_* -> AKODE_*, .codex/ -> .akode/ di progetto;
nessun fallback a ~/.codex o a CODEX_*;
- testi per l'utente "Codex" -> "aKode"; testi verso il modello e istruzioni di sistema invariati;
- snapshot insta rinominati (non ancora rigenerati).
I conflitti con la base ripulita sono stati risolti riapplicando la rinomina ai file senza le
funzioni di imeAI (script di mappa dei token per file).
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
131
akode-rs/docs/bazel.md
Normal file
131
akode-rs/docs/bazel.md
Normal file
@@ -0,0 +1,131 @@
|
||||
# Bazel in akode-rs
|
||||
|
||||
This repository uses Bazel to build the Rust workspace under `akode-rs`.
|
||||
Cargo remains the source of truth for crates and features, while Bazel
|
||||
provides hermetic builds, toolchains, and cross-platform artifacts.
|
||||
|
||||
As of 6/1/2026, this setup is still experimental as we stabilize it.
|
||||
|
||||
## High-level layout
|
||||
|
||||
- `../MODULE.bazel` defines Bazel dependencies and Rust toolchains.
|
||||
- `rules_rs` imports third-party crates from `akode-rs/Cargo.toml` and
|
||||
`akode-rs/Cargo.lock` via `crate.from_cargo(...)` and exposes them under
|
||||
`@crates`.
|
||||
- `../defs.bzl` provides `codex_rust_crate`, which wraps `rust_library`,
|
||||
`rust_binary`, and `rust_test` so Bazel targets line up with Cargo conventions.
|
||||
It provides a sane set of defaults that work for most first-party crates, but may
|
||||
need tweaks in some cases.
|
||||
- Each crate in `akode-rs/*/BUILD.bazel` typically uses `codex_rust_crate` and
|
||||
makes some adjustments if the crate needs additional compile-time or runtime data,
|
||||
or other customizations.
|
||||
|
||||
## Running Bazel locally
|
||||
|
||||
The repository root `justfile` exposes the common Bazel entry points:
|
||||
|
||||
```bash
|
||||
just bazel-test
|
||||
just bazel-clippy
|
||||
```
|
||||
|
||||
Ordinary local `bazel` and `just` invocations run locally. BuildBuddy cache,
|
||||
build event upload, downloads, and remote execution are opt-in configurations.
|
||||
|
||||
## BuildBuddy
|
||||
|
||||
Codex uses BuildBuddy for a shared Bazel cache and remoted builds and tests. To use it
|
||||
to speed up your builds and tests you'll need to provide an API key and select a
|
||||
configuration.
|
||||
|
||||
### BuildBuddy API key
|
||||
|
||||
If you're an OpenAI employee, log in to https://openai.buildbuddy.io and use Google sign-in.
|
||||
|
||||
Create a BuildBuddy API key as described in BuildBuddy's [Authentication Guide][bb-auth-guide],
|
||||
then add it to `~/.bazelrc`:
|
||||
|
||||
```bazelrc
|
||||
# Local machine only; this file contains a BuildBuddy credential.
|
||||
common --remote_header=x-buildbuddy-api-key=<your-buildbuddy-api-key>
|
||||
```
|
||||
|
||||
Keeping the credential outside the workspace reduces the risk of accidentally
|
||||
committing it.
|
||||
|
||||
If you need different API keys for different projects, put the API key in
|
||||
`%workspace%/user.bazelrc` instead. The checked-in `.bazelrc` optionally imports
|
||||
that file, and `.gitignore` excludes it. Do not commit or share a file containing
|
||||
the credential.
|
||||
|
||||
[bb-auth-guide]: https://www.buildbuddy.io/docs/guide-auth/#managing-keys
|
||||
|
||||
### Selecting a remote build configuration
|
||||
|
||||
OpenAI employees should default to the OpenAI host with remote execution unless
|
||||
they have a reason to choose another configuration. Add the following configuration
|
||||
to `%workspace%/user.bazelrc`:
|
||||
|
||||
```bazelrc
|
||||
common --config=buildbuddy-openai-rbe
|
||||
```
|
||||
|
||||
OpenAI employees who don't want remote execution can use `buildbuddy-openai`. External users
|
||||
should use `buildbuddy-generic-rbe` or `buildbuddy-generic`. See below for details on these
|
||||
configurations.
|
||||
|
||||
### All remote configurations
|
||||
|
||||
CI executes Bazel actions on its runners. The following configurations are available for explicit local use.
|
||||
|
||||
| Invocation/config | Key Required | Cache/BES | Build exec | Test exec |
|
||||
| ------------------------------------------- | ------------ | ---------------------- | ---------- | --------- |
|
||||
| `bazel ...` | No | None | Local | Local |
|
||||
| `bazel ... --config=buildbuddy-generic` | Yes | `remote.buildbuddy.io` | Local | Local |
|
||||
| `bazel ... --config=buildbuddy-generic-rbe` | Yes | `remote.buildbuddy.io` | Remote | Remote |
|
||||
| `bazel ... --config=buildbuddy-openai` | Yes | `openai.buildbuddy.io` | Local | Local |
|
||||
| `bazel ... --config=buildbuddy-openai-rbe` | Yes | `openai.buildbuddy.io` | Remote | Remote |
|
||||
|
||||
## Evolving the setup
|
||||
|
||||
When you add or change Rust dependencies, update the Cargo.toml/Cargo.lock as normal.
|
||||
Then refresh the Bzlmod lockfile from the repo root:
|
||||
|
||||
```bash
|
||||
just bazel-lock-update
|
||||
```
|
||||
|
||||
This runs `bazel mod deps --lockfile_mode=update` and updates `MODULE.bazel.lock` if needed.
|
||||
Commit the lockfile changes along with your Cargo lockfile update.
|
||||
|
||||
To verify lockfile alignment locally (the same check CI runs), use:
|
||||
|
||||
```bash
|
||||
just bazel-lock-check
|
||||
```
|
||||
|
||||
In some cases, an upstream crate may need a patch or a `crate.annotation` in `../MODULE.bzl`
|
||||
to have it build in Bazel's sandbox or make it cross-compilation-friendly. If you see issues,
|
||||
feel free to ping zbarsky or mbolin.
|
||||
|
||||
When you add a new crate or binary:
|
||||
|
||||
1. Add it to the Cargo workspace as usual.
|
||||
2. Create a `BUILD.bazel` that calls `codex_rust_crate` (see nearby crates for
|
||||
examples).
|
||||
3. If a dependency needs special handling (compile/runtime data, additional binaries
|
||||
for integration tests, env vars, etc) you may need to adjust the parameters to
|
||||
`codex_rust_crate` to configure it.
|
||||
One common customization is setting `test_tags = ["no-sandbox]` to run the test
|
||||
unsandboxed. Prefer to avoid it, but it is necessary in some cases such as when the
|
||||
test itself uses Seatbelt (the sandbox does as well, and it cannot be nested).
|
||||
To limit the blast radius, consider isolating such tests to a separate crate.
|
||||
|
||||
If you see build issue and are not sure how to apply the proper customizations, feel free to ping zbarsky or mbolin.
|
||||
|
||||
## References
|
||||
|
||||
- Bazel overview: https://bazel.build/
|
||||
- Bzlmod (module system): https://bazel.build/external/overview
|
||||
- rules_rust: https://github.com/bazelbuild/rules_rust
|
||||
- rules_rs: https://github.com/bazelbuild/rules_rs
|
||||
Reference in New Issue
Block a user