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