From e66348c30886f4db9343fd1f66ffcb6d88b31f8a Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 13 Feb 2026 12:14:28 +0100 Subject: [PATCH] build(cargo): adding the models & database to build --- build.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index b3899a8..676bed4 100644 --- a/build.rs +++ b/build.rs @@ -8,6 +8,7 @@ use std::{ const COMMAND_DIR: &str = "./src/commands/"; const EVENT_DIR: &str = "./src/events/"; const MODEL_DIR: &str = "./src/models/"; +const DB_DIR: &str = "./src/database/"; const MOD_PREFIX: &str = "pub mod "; const MOD_FILE: &str = "/mod_gen.rs"; @@ -107,7 +108,7 @@ 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'"); + println!("'models'"); for source in sources { modules = modules + &String::from(MOD_PREFIX) + &source + &String::from(";\n"); println!("\t'{}'", source); @@ -117,6 +118,20 @@ fn models() -> io::Result<()> { Ok(()) } +fn database_helper() -> io::Result<()> { + let root: &Path = Path::new(DB_DIR); + let sources: Vec = read_dir(root); + let mut modules: String = String::new(); + println!("'database_helper'"); + for source in sources { + modules = modules + &String::from(MOD_PREFIX) + &source + &String::from(";\n"); + println!("\t'{}'", source); + } + write(String::from(DB_DIR) + &String::from(MOD_FILE), modules)?; + + Ok(()) +} + fn main() { if let Err(e) = commands() { panic!("Error when writing the commands \n{}", e) @@ -127,4 +142,7 @@ fn main() { if let Err(e) = models() { panic!("Error when writing the models:\n{}", e) } + if let Err(e) = database_helper() { + panic!("Error when writing the database_helper:\n{}", e) + } }