| 1 |
use std::path::Path; |
| 2 |
|
| 3 |
use log::info; |
| 4 |
|
| 5 |
use crate::{env::Env, file_saver::*, nameutil::*}; |
| 6 |
|
| 7 |
pub fn generate( |
| 8 |
env: &Env, |
| 9 |
root_path: &Path, |
| 10 |
mod_rs: &mut Vec<String>, |
| 11 |
traits: &mut Vec<String>, |
| 12 |
builders: &mut Vec<String>, |
| 13 |
) { |
| 14 |
info!("Generate objects"); |
| 15 |
for class_analysis in env.analysis.objects.values() { |
| 16 |
let obj = &env.config.objects[&class_analysis.full_name]; |
| 17 |
if !obj.status.need_generate() { |
| 18 |
continue; |
| 19 |
} |
| 20 |
|
| 21 |
let mod_name = obj |
| 22 |
.module_name |
| 23 |
.clone() |
| 24 |
.unwrap_or_else(|| module_name(split_namespace_name(&class_analysis.full_name).1)); |
| 25 |
|
| 26 |
let mut path = root_path.join(&mod_name); |
| 27 |
path.set_extension("rs"); |
| 28 |
info!("Generating file {path:?}"); |
| 29 |
|
| 30 |
save_to_file(path, env.config.make_backup, |w| { |
| 31 |
super::object::generate(w, env, class_analysis) |
| 32 |
}); |
| 33 |
|
| 34 |
super::object::generate_reexports(env, class_analysis, &mod_name, mod_rs, traits, builders); |
| 35 |
} |
| 36 |
} |