use std::env;
use std::fs;
use std::path::Path;
const TEMPLATE_FILES: &[&str] = &[
"config.json",
"initial_conditions.json",
"penalties.json",
"stages.json",
"system/buses.json",
"system/hydros.json",
"system/lines.json",
"system/thermals.json",
"scenarios/inflow_seasonal_stats.parquet",
"scenarios/load_seasonal_stats.parquet",
];
fn main() {
let manifest_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR must be set");
let out_dir = env::var("OUT_DIR").expect("OUT_DIR must be set");
let src_root = Path::new(&manifest_dir).join("templates/1dtoy");
let dst_root = Path::new(&out_dir).join("templates/1dtoy");
for rel in TEMPLATE_FILES {
let src = src_root.join(rel);
let dst = dst_root.join(rel);
println!("cargo:rerun-if-changed={}", src.display());
if let Some(parent) = dst.parent() {
fs::create_dir_all(parent).unwrap_or_else(|e| {
panic!("failed to create directory {}: {e}", parent.display());
});
}
fs::copy(&src, &dst).unwrap_or_else(|e| {
panic!("failed to copy {} -> {}: {e}", src.display(), dst.display());
});
}
}