Skip to content

Commit

Permalink
build.rs: skip write if file identical
Browse files Browse the repository at this point in the history
this will fix `npm run tauri dev` to go into an infinite loop, as the watchdog checks timestamps and not file hashes (speculation)
  • Loading branch information
jamesa08 committed Jun 7, 2024
1 parent 2e10468 commit 8a17034
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rust-impl/midianimator/src-tauri/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ pub fn get_cmds() -> impl Fn(tauri::Invoke<tauri::Wry>) + Send + Sync + 'static
return {};
}}", handler);

// check if the file is identical to the generated code
let current_code = fs::read_to_string(&out_path).unwrap_or("".to_string());
if current_code == generated_code {
println!("cargo:warning=generated code is identical to current code, skipping write");
return;
}

fs::write(out_path, generated_code).expect("failed to write auto_command.rs");

println!("cargo:warning=written generated code to src/auto_command.rs");
Expand Down

0 comments on commit 8a17034

Please sign in to comment.