build(cargo): adding the models & database to build
This commit is contained in:
parent
4752488a7f
commit
e66348c308
1 changed files with 19 additions and 1 deletions
20
build.rs
20
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<String> = 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<String> = 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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue