reenable dependency checks for the generation of src/bindings.rs again to optimize cargo check in CLion for dependent projects
@@ -143,28 +143,38 @@ fn main() {
// regenerate bindings?
//
- // note: the bindings are generated into the src directory to support
- // IDE based symbol lookup in dependent projects.
+ // The bindings are generated into the src directory to support
+ // IDE based symbol lookup in dependent projects, but this has the consequence
+ // that the IDE and corgo might be confused by its datestamp, so we
+ // avoid the regeneration if possible by implementing our own dependency checks.
+ // The results of this is hard to reproduce. What can be said is that CLion's
+ // cargo check invocation does from time to time takes a lot longer than expected
+ // in dependent projects even though the bindings were not updated.
+
+ let regenerate_bindings = {
+ let generated_bindings = PathBuf::from("src/bindings.rs");
+ if !generated_bindings.exists() { true } else {
-/*
+ let skia_lib_filename =
+ if cfg!(windows) { "skia.lib" } else { "libskia.a" };
- let skia_lib = PathBuf::from(&skia_out_dir).join("skia.lib");
- let generated_bindings = PathBuf::from("src/bindings.rs");
+ let skia_lib = PathBuf::from(&skia_out_dir).join(skia_lib_filename);
let bindings_cpp_src = PathBuf::from("src/bindings.cpp");
let us = PathBuf::from("build.rs");
+ let config = PathBuf::from("Cargo.toml");
fn mtime(path: &Path) -> std::time::SystemTime {
fs::metadata(path).unwrap().modified().unwrap()
}
- let regenerate_bindings =
- !generated_bindings.exists()
- || mtime(&skia_lib) > mtime(&generated_bindings)
- || mtime(&bindings_cpp_src) > mtime(&generated_bindings)
- || mtime(&us) > mtime(&generated_bindings);
-*/
+ let gen_time = mtime(&generated_bindings);
- let regenerate_bindings = true;
+ mtime(&config) > gen_time
+ || mtime(&skia_lib) > gen_time
+ || mtime(&bindings_cpp_src) > gen_time
+ || mtime(&us) > gen_time
+ }
+ };
if regenerate_bindings {
bindgen_gen(&current_dir_name, &skia_out_dir)
