use std::env; use std::fs; use std::path::Path; fn main() { println!("cargo:rerun-if-changed=assets"); println!("cargo:rerun-if-changed=fonts"); // Chemin vers target/debug ou target/release let out_dir = env::var("OUT_DIR").unwrap(); let target_dir = Path::new(&out_dir) .ancestors() .nth(3) // On remonte pour arriver dans target/debug ou target/release .unwrap(); // Copie assets/ let _ = fs::remove_dir_all(target_dir.join("assets")); fs::create_dir_all(target_dir.join("assets")).unwrap(); copy_dir("assets", target_dir.join("assets")); // Copie fonts/ let _ = fs::remove_dir_all(target_dir.join("fonts")); fs::create_dir_all(target_dir.join("fonts")).unwrap(); copy_dir("fonts", target_dir.join("fonts")); #[cfg(windows)] { let mut res = winres::WindowsResource::new(); res.set("SubSystem", "Windows"); res.compile().unwrap(); } } fn copy_dir(src: impl AsRef, dst: impl AsRef) { for entry in fs::read_dir(src).unwrap() { let entry = entry.unwrap(); let ty = entry.file_type().unwrap(); let dst_path = dst.as_ref().join(entry.file_name()); if ty.is_dir() { fs::create_dir_all(&dst_path).unwrap(); copy_dir(entry.path(), &dst_path); } else { fs::copy(entry.path(), &dst_path).unwrap(); } } }