use std::fs;
use std::path::Path;
fn copy_json_files(src_dir: &Path, dst_dir: &Path) {
if src_dir.exists() {
fs::create_dir_all(dst_dir)
.unwrap_or_else(|e| panic!("Failed to create {:?} directory: {}", dst_dir, e));
for entry in
fs::read_dir(src_dir).unwrap_or_else(|e| panic!("Failed to read {:?}: {}", src_dir, e))
{
let entry = entry.expect("Failed to read directory entry");
let src_path = entry.path();
if src_path.extension().map(|e| e == "json").unwrap_or(false) {
let dst_path = dst_dir.join(entry.file_name());
fs::copy(&src_path, &dst_path).unwrap_or_else(|e| {
panic!("Failed to copy {:?} to {:?}: {}", src_path, dst_path, e)
});
}
}
}
}
fn main() {
copy_json_files(Path::new("acp-spec/schemas/v1"), Path::new("schemas/v1"));
copy_json_files(Path::new("acp-spec/primers"), Path::new("primers"));
println!("cargo:rerun-if-changed=acp-spec/schemas/v1");
println!("cargo:rerun-if-changed=acp-spec/primers");
}