Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rerun build if libui source files change #99

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions ui-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ fn main() {
}
}

println!("cargo:rerun-if-changed=wrapper.h");

// Generate libui bindings on the fly
let bindings = BindgenBuilder::default()
.header("wrapper.h")
.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");

Expand All @@ -57,6 +60,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"));

Expand All @@ -77,7 +88,7 @@ fn main() {
]
.iter()
{
base_config.file(src_path(filename));
src_add!(src_path(filename));
}

if target_os == "windows" {
Expand Down Expand Up @@ -149,7 +160,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
Expand Down Expand Up @@ -231,7 +242,7 @@ fn main() {
]
.iter()
{
base_config.file(src_path(filename));
src_add!(src_path(filename));
}
} else if apple {
base_config.include(src_path("/darwin"));
Expand Down Expand Up @@ -289,7 +300,7 @@ fn main() {
]
.iter()
{
base_config.file(src_path(filename));
src_add!(src_path(filename));
}
println!("cargo:rustc-link-lib=framework=AppKit");
} else {
Expand Down