ctranslate2_src_build_support/file_changes.rs
1use std::{fs, path::Path};
2
3pub fn watch_dir_recursively(dir: &Path) {
4 for entry in fs::read_dir(dir)
5 .map(|v| v.collect::<Vec<_>>())
6 .unwrap_or_default()
7 {
8 let entry = entry.expect("Failed to read entry");
9 let path = entry.path();
10
11 if path.is_file() {
12 println!("cargo:rerun-if-changed={}", path.display());
13 } else if path.is_dir() {
14 watch_dir_recursively(&path);
15 }
16 }
17}