-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
33 lines (27 loc) · 770 Bytes
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use std::{
env,
error::Error,
fs::{self, File},
io::Write,
path::Path,
};
const SOURCE_DIR: &str = "resources/templates";
fn main() -> Result<(), Box<dyn Error>> {
let out_dir = env::var("OUT_DIR")?;
let dest_path = Path::new(&out_dir).join("templates.rs");
let mut all_the_files = File::create(&dest_path)?;
writeln!(&all_the_files, "{{")?;
for f in fs::read_dir(SOURCE_DIR)? {
let f = f?;
if f.file_type()?.is_dir() {
continue;
}
writeln!(
&mut all_the_files,
r#"m.insert("{name}", include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/{name}")));"#,
name = f.path().display()
)?;
}
writeln!(&all_the_files, "}}")?;
Ok(())
}