From a92e84c80fb0110e85917c0ba3528632591f96ac Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 12 Feb 2026 22:33:49 +0100 Subject: [PATCH] build(models): adding the models of to the mod generation --- build.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/build.rs b/build.rs index 9f5ebab..b3899a8 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,7 @@ use std::{ const COMMAND_DIR: &str = "./src/commands/"; const EVENT_DIR: &str = "./src/events/"; +const MODEL_DIR: &str = "./src/models/"; const MOD_PREFIX: &str = "pub mod "; const MOD_FILE: &str = "/mod_gen.rs"; @@ -102,6 +103,20 @@ fn events() -> io::Result<()> { Ok(()) } +fn models() -> io::Result<()> { + let root: &Path = Path::new(MODEL_DIR); + let sources: Vec = read_dir(root); + let mut modules: String = String::new(); + println!("'modules'"); + for source in sources { + modules = modules + &String::from(MOD_PREFIX) + &source + &String::from(";\n"); + println!("\t'{}'", source); + } + write(String::from(MODEL_DIR) + &String::from(MOD_FILE), modules)?; + + Ok(()) +} + fn main() { if let Err(e) = commands() { panic!("Error when writing the commands \n{}", e) @@ -109,4 +124,7 @@ fn main() { if let Err(e) = events() { panic!("Error when writing the events:\n{}", e) } + if let Err(e) = models() { + panic!("Error when writing the models:\n{}", e) + } }