build(models): adding the models of to the mod generation
This commit is contained in:
parent
561b4858dc
commit
a92e84c80f
1 changed files with 18 additions and 0 deletions
18
build.rs
18
build.rs
|
|
@ -7,6 +7,7 @@ use std::{
|
||||||
|
|
||||||
const COMMAND_DIR: &str = "./src/commands/";
|
const COMMAND_DIR: &str = "./src/commands/";
|
||||||
const EVENT_DIR: &str = "./src/events/";
|
const EVENT_DIR: &str = "./src/events/";
|
||||||
|
const MODEL_DIR: &str = "./src/models/";
|
||||||
const MOD_PREFIX: &str = "pub mod ";
|
const MOD_PREFIX: &str = "pub mod ";
|
||||||
const MOD_FILE: &str = "/mod_gen.rs";
|
const MOD_FILE: &str = "/mod_gen.rs";
|
||||||
|
|
||||||
|
|
@ -102,6 +103,20 @@ fn events() -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn models() -> io::Result<()> {
|
||||||
|
let root: &Path = Path::new(MODEL_DIR);
|
||||||
|
let sources: Vec<String> = 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() {
|
fn main() {
|
||||||
if let Err(e) = commands() {
|
if let Err(e) = commands() {
|
||||||
panic!("Error when writing the commands \n{}", e)
|
panic!("Error when writing the commands \n{}", e)
|
||||||
|
|
@ -109,4 +124,7 @@ fn main() {
|
||||||
if let Err(e) = events() {
|
if let Err(e) = events() {
|
||||||
panic!("Error when writing the events:\n{}", e)
|
panic!("Error when writing the events:\n{}", e)
|
||||||
}
|
}
|
||||||
|
if let Err(e) = models() {
|
||||||
|
panic!("Error when writing the models:\n{}", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue