From fabb0d65326832ff5dde2a9affc1994d74ef971c Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Sun, 23 Aug 2020 10:09:56 -0700 Subject: [PATCH 1/2] Rerun if libui source files change --- ui-sys/build.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/ui-sys/build.rs b/ui-sys/build.rs index db12b5f84..2bad191e1 100644 --- a/ui-sys/build.rs +++ b/ui-sys/build.rs @@ -43,6 +43,7 @@ fn main() { .opaque_type("max_align_t") // For some reason this ends up too large //.rustified_enum(".*") .trust_clang_mangling(false) // clang sometimes wants to treat these functions as C++ + .parse_callbacks(Box::new(bindgen::CargoCallbacks)) .generate() .expect("Unable to generate bindings"); @@ -57,6 +58,14 @@ fn main() { let src_base = env::var("SRC_BASE").unwrap_or("libui".to_string()); let src_path = |x| format!("{}/{}", src_base, x); + macro_rules! src_add { + ($p:expr) => { + let path = $p; + println!("cargo:rerun-if-changed={}", path); + base_config.file(path); + } + } + // Add source files that are common to all platforms base_config.include(src_path("/common")); @@ -77,7 +86,7 @@ fn main() { ] .iter() { - base_config.file(src_path(filename)); + src_add!(src_path(filename)); } if target_os == "windows" { @@ -149,7 +158,7 @@ fn main() { ] .iter() { - base_config.file(src_path(filename)); + src_add!(src_path(filename)); } // See https://github.com/nabijaczleweli/rust-embed-resource/issues/11 @@ -231,7 +240,7 @@ fn main() { ] .iter() { - base_config.file(src_path(filename)); + src_add!(src_path(filename)); } } else if apple { base_config.include(src_path("/darwin")); @@ -289,7 +298,7 @@ fn main() { ] .iter() { - base_config.file(src_path(filename)); + src_add!(src_path(filename)); } println!("cargo:rustc-link-lib=framework=AppKit"); } else { From ce751c83277a2298975e1701ee8455a6d20e64c6 Mon Sep 17 00:00:00 2001 From: Logan Darklock Date: Tue, 25 Aug 2020 10:12:00 -0700 Subject: [PATCH 2/2] Also rerun if wrapper.h changes --- ui-sys/build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui-sys/build.rs b/ui-sys/build.rs index 2bad191e1..3ed603215 100644 --- a/ui-sys/build.rs +++ b/ui-sys/build.rs @@ -37,6 +37,8 @@ fn main() { } } + println!("cargo:rerun-if-changed=wrapper.h"); + // Generate libui bindings on the fly let bindings = BindgenBuilder::default() .header("wrapper.h")