From f9cfbb2c2bd9bf64a073bd11ef839fc2ad32d7fc Mon Sep 17 00:00:00 2001 From: "nick.kino" <79381743+nick1udwig@users.noreply.github.com> Date: Mon, 6 May 2024 09:20:05 -0700 Subject: [PATCH] fix build.rs `src/` behavior --- kinode/build.rs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/kinode/build.rs b/kinode/build.rs index 9fb7ed9e7..cbc6b6463 100644 --- a/kinode/build.rs +++ b/kinode/build.rs @@ -24,17 +24,28 @@ fn get_features() -> String { } fn output_reruns(dir: &Path, rerun_files: &HashSet) { - if let Ok(entries) = fs::read_dir(dir) { - for entry in entries.filter_map(|e| e.ok()) { - let path = entry.path(); - if path.is_dir() { - // If the entry is a directory, recursively walk it - output_reruns(&path, rerun_files); - } else if let Some(filename) = path.file_name().and_then(|n| n.to_str()) { - // Check if the current file is in our list of interesting files - if rerun_files.contains(filename) { - // If so, print a `cargo:rerun-if-changed=PATH` line for it - println!("cargo:rerun-if-changed={}", path.display()); + if rerun_files.contains(dir.to_str().unwrap()) { + // Output for all files in the directory if the directory itself is specified in rerun_files + if let Ok(entries) = fs::read_dir(dir) { + for entry in entries.filter_map(|e| e.ok()) { + let path = entry.path(); + println!("cargo:rerun-if-changed={}", path.display()); + } + } + } else { + // Check files individually + if let Ok(entries) = fs::read_dir(dir) { + for entry in entries.filter_map(|e| e.ok()) { + let path = entry.path(); + if path.is_dir() { + // If the entry is a directory, recursively walk it + output_reruns(&path, rerun_files); + } else if let Some(filename) = path.file_name().and_then(|n| n.to_str()) { + // Check if the current file is in our list of interesting files + if rerun_files.contains(filename) { + // If so, print a `cargo:rerun-if-changed=PATH` line for it + println!("cargo:rerun-if-changed={}", path.display()); + } } } }