diff --git a/build.rs b/build.rs index 8f2a775..32bde6b 100644 --- a/build.rs +++ b/build.rs @@ -9,6 +9,7 @@ // + ▀████████████████████████████████████████████████████▀ use blend::Blend; +use std::fs; use std::fs::File; use std::io::Write; @@ -27,13 +28,18 @@ fn main() -> std::io::Result<()> { "// DO NOT MODIFY MANUALLY, CHANGES WILL BE OVERWRITTEN!\n" )?; write!(&file, "[\n")?; - extract_scene(&mut file, "test", "src/blender/scene_test.blend")?; - extract_scene(&mut file, "workshop", "src/blender/scene_workshop.blend")?; - extract_scene( - &mut file, - "greenhouse", - "src/blender/scene_greenhouse.blend", - )?; + + // find all scene_*.blend files and extract+export their scenes + for entry in fs::read_dir("src/blender")? { + let path = entry?.path(); + if let Some(file_name) = path.file_name().and_then(|s| s.to_str()) { + if file_name.starts_with("scene_") && file_name.ends_with(".blend") { + let scene_name = &file_name["scene_".len()..file_name.len() - ".blend".len()]; + + extract_scene(&mut file, scene_name, path.to_str().unwrap())?; + } + } + } write!(&file, "]\n")?; } Ok(())