vyre_build_scan/lib.rs
1#![deny(missing_docs)]
2
3//! Build-time filesystem scanner. Emits a typed registry from a flat directory
4//! of `.rs` files, so adding a new responsibility is one file drop with zero
5//! modifications to any other file.
6//!
7//! # build.rs example
8//!
9//! ```ignore
10//! vyre_build_scan::scan(&vyre_build_scan::Registry {
11//! scan_dir: "src/enforce/gates",
12//! const_name: "ALL_GATES",
13//! element_type: "&'static dyn crate::enforce::EnforceGate",
14//! item_const_name: "REGISTERED",
15//! output_file: "gates_registry.rs",
16//! module_prefix: "crate::enforce::gates",
17//! });
18//! ```
19//!
20//! # Model
21//!
22//! Every responsibility directory follows this shape:
23//!
24//! ```text
25//! src/gates/
26//! mod.rs - declares: `automod::dir!(pub "src/gates");`
27//! plus: `include!(concat!(env!("OUT_DIR"), "/gates_registry.rs"));`
28//! atomics.rs - exposes: `pub const GATE: Atomics = Atomics;`
29//! barrier.rs - exposes: `pub const GATE: Barrier = Barrier;`
30//! oob.rs - ...
31//! ```
32//!
33//! Build-time, [`scan`] walks `src/gates/`, reads every `.rs` file other than
34//! `mod.rs` and filenames starting with `_`, and writes
35//! `$OUT_DIR/gates_registry.rs` containing a flat slice referencing the
36//! constants.
37//!
38//! The contributor adds `src/gates/my_gate.rs` with one
39//! `pub const GATE: MyGate = MyGate;` declaration. Nothing else in the tree
40//! changes. `cargo build` wires it in.
41//!
42//! This is the collision-free single-responsibility enforcement mechanism: no
43//! central list of registrations, no manual `pub mod` edits, no `inventory`
44//! linker-section magic. Pure filesystem scanning, build-time codegen, and
45//! static dispatch.
46
47mod config;
48mod fatal;
49mod flat;
50mod paths;
51mod rust_specs;
52
53pub use config::{Registry, RustSpecRegistry};
54pub use flat::{scan, scan_all};
55pub use rust_specs::scan_rust_specs;