#![allow(clippy::needless_doctest_main)]
mod sync;
use std::path::Path;
use sync::Sync;
#[derive(Default)]
pub struct Builder {
table: Vec<Sync>,
file_list: Vec<String>,
}
impl Builder {
pub fn new() -> Self {
Self::default()
}
pub fn add<P: AsRef<Path>>(mut self, file: P, dep_file: P) -> Self {
self.file_list.push(file.as_ref().display().to_string());
self.file_list.push(dep_file.as_ref().display().to_string());
self.table.push(Sync::new(
file.as_ref().to_path_buf(),
dep_file.as_ref().to_path_buf(),
));
self
}
pub fn sync(&mut self) {
for sync in &self.table {
sync.sync();
}
self.file_list.dedup();
for file in &self.file_list {
println!("cargo:rerun-if-changed={}", file);
}
}
}