MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / write_if_changed

Function write_if_changed

build.rs:653–664  ·  view source on GitHub ↗

Write the generated file only if its content has actually changed. This avoids bumping the mtime on `stub_map_generated.rs` when nothing changed, which in turn prevents `rustc` from unnecessarily recompiling the main crate.

(content: &str)

Source from the content-addressed store, hash-verified

651/// changed, which in turn prevents `rustc` from unnecessarily recompiling
652/// the main crate.
653fn write_if_changed(content: &str) {
654 let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
655 let dest_path = Path::new(&out_dir).join("stub_map_generated.rs");
656
657 if let Ok(existing) = fs::read_to_string(&dest_path)
658 && existing == content
659 {
660 return;
661 }
662
663 fs::write(&dest_path, content).expect("Failed to write generated stub map");
664}

Callers 2

mainFunction · 0.85
write_empty_stubsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected