Skip to content

Commit

Permalink
Avoid overwriting bindings.rs if content is unchanged (#346)
Browse files Browse the repository at this point in the history
Compare the contents of `bindings.rs` before overwriting. If no changes
are detected, skip the overwrite to prevent unnecessary recompilation.
  • Loading branch information
tomasol authored Nov 16, 2024
1 parent 96cb023 commit 0186a82
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -855,13 +855,14 @@ async fn generate_package_bindings(
path = output_dir.display()
)
})?;

fs::write(&bindings_path, bindings).with_context(|| {
format!(
"failed to write bindings file `{path}`",
path = bindings_path.display()
)
})?;
if fs::read_to_string(&bindings_path).unwrap_or_default() != bindings {
fs::write(&bindings_path, bindings).with_context(|| {
format!(
"failed to write bindings file `{path}`",
path = bindings_path.display()
)
})?;
}

Ok(import_name_map)
}
Expand Down

0 comments on commit 0186a82

Please sign in to comment.