1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::fs;
use crate::config::{config_file_path, read_config_file, Config};
pub fn when_changed() {
println!(
"cargo:rerun-if-changed={}",
config_file_path().to_str().unwrap()
);
let file = read_config_file();
let config = Config::new(&file);
let mut stack = vec![config.get_dir().clone()];
while let Some(dir) = stack.pop() {
println!("cargo:rerun-if-changed={}", dir.to_str().unwrap());
for entry in fs::read_dir(dir).expect("valid directory") {
let path = entry.expect("valid directory entry").path();
if path.is_dir() {
stack.push(path);
} else {
println!("cargo:rerun-if-changed={}", path.to_str().unwrap());
}
}
}
}