Skip to content

Commit

Permalink
fix(occara): watch files in cpp/ and include/ instead of the folder f…
Browse files Browse the repository at this point in the history
…or changes

Previously recompilation was often triggered even though nothing has
changed. This improves recompilation times.
  • Loading branch information
maximmaxim345 committed Jun 28, 2024
1 parent 884ef88 commit 8a04d3a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions crates/occara/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use walkdir::WalkDir;
fn main() -> miette::Result<()> {
let build = opencascade_sys::OpenCascadeSource::new().build();
// Find all cpp files in the cpp directory
let files: Vec<_> = WalkDir::new("cpp")
let cpp_files: Vec<_> = WalkDir::new("cpp")
.into_iter()
.filter_map(Result::ok)
.filter(|e| e.path().is_file())
Expand All @@ -15,11 +15,24 @@ fn main() -> miette::Result<()> {
})
.map(|e| e.into_path())
.collect();
let include_files: Vec<_> = WalkDir::new("include")
.into_iter()
.filter_map(Result::ok)
.filter(|e| e.path().is_file())
.filter(|e| {
e.path()
.extension()
.map(|ext| ext == "hpp" || ext == "h")
.unwrap_or(false)
})
.map(|e| e.into_path())
.collect();

// Watch for changes in the cpp and include directories
println!("cargo:rerun-if-changed=cpp");
println!("cargo:rerun-if-changed=include");
for file in &files {
for file in &cpp_files {
println!("cargo:rerun-if-changed={}", file.to_str().unwrap());
}
for file in &include_files {
println!("cargo:rerun-if-changed={}", file.to_str().unwrap());
}
for entry in WalkDir::new("include")
Expand All @@ -40,7 +53,7 @@ fn main() -> miette::Result<()> {

autocxx_build
.std("c++20")
.files(files)
.files(cpp_files)
.compile("occara-autocxx-bridge");
println!("cargo:rerun-if-changed=src/ffi.rs");

Expand Down

0 comments on commit 8a04d3a

Please sign in to comment.