aboutsummaryrefslogtreecommitdiff
path: root/src/gen/mod_rs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gen/mod_rs.rs')
-rw-r--r--src/gen/mod_rs.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gen/mod_rs.rs b/src/gen/mod_rs.rs
new file mode 100644
index 0000000..a149319
--- /dev/null
+++ b/src/gen/mod_rs.rs
@@ -0,0 +1,18 @@
+use crate::compiler_plugin;
+use crate::gen::code_writer::CodeWriter;
+
+pub(crate) fn gen_mod_rs(mods: &[String]) -> compiler_plugin::GenResult {
+ let v = CodeWriter::with_no_error(|w| {
+ w.comment(&format!("{}generated", "@"));
+ w.write_line("");
+ let mut mods: Vec<&String> = mods.into_iter().collect();
+ mods.sort();
+ for m in mods {
+ w.write_line(&format!("pub mod {};", m));
+ }
+ });
+ compiler_plugin::GenResult {
+ name: "mod.rs".to_owned(),
+ content: v.into_bytes(),
+ }
+}