diff --git a/crates/text/build.rs b/crates/text/build.rs index 73c952fa..25544a3a 100644 --- a/crates/text/build.rs +++ b/crates/text/build.rs @@ -51,6 +51,12 @@ fn main() { } let src = format!("pub static CRAFT_FONTS: &[CraftFont] = &[\n{fonts}];\npub static WEB_FONTS: &[WebFont] = &[\n{web}];\n"); let out = PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join("craft_fonts.rs"); + // Unchanged output keeps its mtime. Rewritten just before this crate compiles, it can read as + // newer than that compile where cargo's recorded times lose their sub-second part (ecryptfs + // home directories), and the next build would compile this crate and everything above it again. + if std::fs::read_to_string(&out).is_ok_and(|old| old == src) { + return; + } if let Err(e) = std::fs::write(&out, src) { println!("cargo::error=writing {}: {e}", out.display()); } diff --git a/crates/ui-egui/build.rs b/crates/ui-egui/build.rs index f40007fb..22fa00b2 100644 --- a/crates/ui-egui/build.rs +++ b/crates/ui-egui/build.rs @@ -21,7 +21,13 @@ fn main() { let people = read(&dir.join("people.toml"), "contributors are shown by username only", |t| t.parse::().map_err(|e| e.to_string())) .unwrap_or_default(); let out = std::path::PathBuf::from(std::env::var_os("OUT_DIR").unwrap_or_default()).join("credits.rs"); - if let Err(e) = std::fs::write(&out, generate(&json, &people)) { + let src = generate(&json, &people); + // Unchanged output keeps its mtime, so the next build doesn't compile this crate again + // (see crates/text/build.rs). + if std::fs::read_to_string(&out).is_ok_and(|old| old == src) { + return; + } + if let Err(e) = std::fs::write(&out, src) { println!("cargo::warning=writing {}: {e}", out.display()); } }