Expand description
Build-time fingerprint generator for use in a downstream build.rs.
Produces ironprint.json in $OUT_DIR: a compact, normalised,
deterministically sorted JSON document capturing a stable snapshot of the
build environment.
§Functions
| Function | Description |
|---|---|
generate_ironprint | Always call this. Writes compact ironprint.json to $OUT_DIR and emits cargo:rerun-if-changed directives. |
export | Optional. Writes a pretty-printed ironprint.json alongside Cargo.toml for local inspection. Pass false or condition on cfg!(debug_assertions) to suppress in release builds. |
§Sections captured
| Section | Contents |
|---|---|
package | Crate name and version |
build | Profile, opt-level, target triple, rustc version, and active feature flags |
deps | Full normalised cargo metadata dependency graph (sorted, no absolute paths) |
cargo_lock_sha256 | SHA-256 of Cargo.lock (comment lines stripped) |
source | SHA-256 of every .rs file under src/ |
§Usage
In the downstream crate’s build.rs:
ⓘ
fn main() {
toolkit_zero::dependency_graph::build::generate_ironprint()
.expect("ironprint generation failed");
// optional — pretty-print alongside Cargo.toml for local inspection
toolkit_zero::dependency_graph::build::export(cfg!(debug_assertions))
.expect("ironprint export failed");
}Embed the fingerprint in the binary:
ⓘ
const IRONPRINT: &str = include_str!(concat!(env!("OUT_DIR"), "/ironprint.json"));§Concerns
- Not tamper-proof — the fingerprint resides as plain text in the binary’s read-only data section. It is informational in nature; it does not constitute a security boundary.
- Export file —
export(true)writesironprint.jsonto the crate root. Add it to.gitignoreto prevent unintentional commits. - Build-time overhead —
cargo metadatais executed on every rebuild. Thecargo:rerun-if-changeddirectives restrict this to changes insrc/,Cargo.toml, orCargo.lock. - Path stripping — absolute paths (
workspace_root,manifest_path,src_path,path, and others) are removed fromcargo metadataoutput to ensure the fingerprint is stable across machines and checkout locations. - Feature scope —
build.featurescaptures the active features of the crate being built, not toolkit-zero’s own features. - Compile-time only — the snapshot does not update at runtime.
Enums§
- Ironprint
Error - Errors that can occur while generating
ironprint.json.
Functions§
- export
- Write a pretty-printed
ironprint.jsonalongside the crate’sCargo.tomlwhenenabledistrue. - generate_
ironprint - Generate
ironprint.jsonin$OUT_DIR.