mirror of
https://github.com/rizsotto/Bear.git
synced 2026-05-28 00:20:45 +02:00
a2fcd51857
Item #5 consolidated platform-checks but left the build pipeline under-documented: contributors had to read three build.rs files to find out who runs what, and the lld prerequisite was a silent trap. This commit spreads that knowledge across CLAUDE.md files, co-located with the crates each piece belongs to: - New platform-checks/CLAUDE.md: role, post-Item-#5 public API, recipe for adding a probe, scope boundary against the intercept-family list. - New bear-codegen/CLAUDE.md: build-time codegen role; YAML to OUT_DIR via include!(); snapshot-test contract. - New bear-completions/CLAUDE.md: why a separate crate (clap_complete cost), how it's actually invoked (distributor runs it; install.sh only picks up pre-generated files). - Top-level CLAUDE.md: short "Build pipeline" routing section pointing at the per-crate files; "Host requirements" calling out lld as a Linux-only prerequisite; routing table grew three entries. - bear/CLAUDE.md: replaced the narrow "Code generation" subsection with a "Build script" section that also covers INTERCEPT_LIBDIR validation and the rustc-env emissions consumed by installation.rs. - intercept-preload/CLAUDE.md: "Build script duties" listing the cc-shim build, exports list, and link directives, plus a pointer at src/c/shim.c as the source of truth for INTERCEPT_FAMILY. - integration-tests/CLAUDE.md: "Build script duties" describing the executable probes (single vs grouped cfgs) and the ccache-masquerade detection. Side cleanup: dropped the dead `cargo:rustc-cfg=build_cdylib` directive from intercept-preload/build.rs. It was emitted but read by no source -- the existing comment claiming it forced cdylib generation was misleading; cdylib production is decided by Cargo.toml's crate-type, not by the cfg. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
941 B
941 B
bear-codegen
Build-time code generator for bear's compiler flag tables and
recognition rules.
How it works
- A regular library, not a
build.rsitself. - Invoked from
bear/build.rsviabear_codegen::generate(flags_dir, out_dir). - Reads
bear/interpreters/*.yaml(compiler definitions) and writes generated Rust source into the consumer'sOUT_DIR. - The
bearcrate pulls in the generated code viainclude!()insrc/semantic/interpreters/.
Generated outputs
The set of generated module names matches the input shape; see
src/lib.rs::generate for the current list. YAML schema validation
lives in yaml_types.rs. Snapshot tests in tests/snapshots/ lock
the generated output against accidental schema drift.
Adding a compiler
Read bear/interpreters/CLAUDE.md. After editing YAML, run
cargo build to regenerate, then cargo test to validate (the
snapshot tests will diff the generated tables).