bindgen: determinism

This commit is contained in:
nym21
2026-01-27 23:48:19 +01:00
parent 730e83472a
commit fecaf0f400
21 changed files with 787 additions and 739 deletions
+12 -1
View File
@@ -7,7 +7,7 @@
//! - `api.rs` - API method generation
//! - `mod.rs` - Entry point
use std::fmt::Write;
use std::{fmt::Write, fs, io, path::Path};
pub mod javascript;
pub mod python;
@@ -41,3 +41,14 @@ pub fn normalize_return_type(return_type: &str) -> String {
}
result
}
/// Write content to a file only if it differs from existing content.
/// Preserves mtime when unchanged, avoiding unnecessary cargo rebuilds.
pub fn write_if_changed(path: &Path, content: &str) -> io::Result<()> {
if let Ok(existing) = fs::read_to_string(path)
&& existing == content
{
return Ok(());
}
fs::write(path, content)
}