-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.rs
31 lines (27 loc) · 1.08 KB
/
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
use std::fs::{File};
use std::io::{Write, BufReader, BufRead};
use std::env;
use std::path::{Path, PathBuf};
use std::iter::once;
fn main() {
let path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()).join("agl-aglfn/glyphlist.txt");
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed={}", path.to_str().expect("no-utf8 path"));
let mut glyph_list = File::create(PathBuf::from(env::var("OUT_DIR").unwrap()).join("glyphlist.rs")).unwrap();
writeln!(glyph_list, "[");
for line in BufReader::new(File::open(path).unwrap()).lines() {
let line = line.unwrap();
if line.starts_with("#") {
continue;
}
let mut parts = line.split(";");
let name = parts.next().unwrap();
let unicode: String = parts.next().unwrap()
.split(" ")
.map(|s| u32::from_str_radix(s, 16).unwrap())
.map(|cp| std::char::from_u32(cp).unwrap())
.collect();
writeln!(glyph_list, " ({:?}, {:?}),", name, unicode);
}
writeln!(glyph_list, "]");
}