build(cargo): adding the utils automod
This commit is contained in:
parent
bfee640f06
commit
212e2526fc
1 changed files with 18 additions and 0 deletions
18
build.rs
18
build.rs
|
|
@ -9,6 +9,7 @@ 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 MODEL_DIR: &str = "./src/models/";
|
||||||
const DB_DIR: &str = "./src/database/";
|
const DB_DIR: &str = "./src/database/";
|
||||||
|
const UTILS_DIR: &str = "./src/database/";
|
||||||
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";
|
||||||
|
|
||||||
|
|
@ -132,6 +133,20 @@ fn database_helper() -> io::Result<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn utils() -> io::Result<()> {
|
||||||
|
let root: &Path = Path::new(UTILS_DIR);
|
||||||
|
let sources: Vec<String> = read_dir(root);
|
||||||
|
let mut modules: String = String::new();
|
||||||
|
println!("'utils'");
|
||||||
|
for source in sources {
|
||||||
|
modules = modules + &String::from(MOD_PREFIX) + &source + &String::from(";\n");
|
||||||
|
println!("\t'{}'", source);
|
||||||
|
}
|
||||||
|
write(String::from(UTILS_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)
|
||||||
|
|
@ -145,4 +160,7 @@ fn main() {
|
||||||
if let Err(e) = database_helper() {
|
if let Err(e) = database_helper() {
|
||||||
panic!("Error when writing the database_helper:\n{}", e)
|
panic!("Error when writing the database_helper:\n{}", e)
|
||||||
}
|
}
|
||||||
|
if let Err(e) = utils() {
|
||||||
|
panic!("Error when writing the database_helper:\n{}", e)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue