-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
29 lines (25 loc) · 817 Bytes
/
Copy pathbuild.rs
File metadata and controls
29 lines (25 loc) · 817 Bytes
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
use std::fs::{File, read_to_string};
use tera::{Tera, Context};
fn main () {
println!("cargo:rerun-if-changed=techniques");
let cont = read_to_string("techniques/techniques").unwrap();
let techs: Vec<&str> = cont.lines().filter_map(|l| {
let trimmed = l.trim();
if trimmed.is_empty() {
None
} else {
Some(trimmed)
}
}).collect();
let tera = Tera::new("techniques/*.tera").unwrap();
let mut structs_file = File::create("src/techniques.rs").unwrap();
let mut ctx = Context::new();
ctx.insert("techniques", &techs);
match tera.render_to("techniques.rs.tera", &ctx, &mut structs_file) {
Ok(_) => {},
Err(e) => {
println!("cargo:warning={}", e);
std::process::exit(1);
}
}
}