-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
32 lines (28 loc) · 987 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
#![feature(const_trait_impl)]
#![deny(warnings)]
use std::env::{var_os};
use std::fs::File;
use std::io::{Write, BufReader, BufRead};
use std::path::Path;
use std::str::FromStr;
#[allow(dead_code)]
#[allow(unused_macros)]
mod tag {
include!("src/tag.rs");
}
use tag::*;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/tag.rs");
println!("cargo:rerun-if-changed=src/tags.list");
let base_dir = var_os("CARGO_MANIFEST_DIR").unwrap();
let out_dir = var_os("OUT_DIR").unwrap();
let src_path = Path::new(&base_dir).join("src").join("tags.list");
let dest_path = Path::new(&out_dir).join("tags.rs");
let mut dest = File::create(dest_path).unwrap();
let src = BufReader::new(File::open(src_path).unwrap());
let tags = src.lines().map(|s| Tag::from_str(&s.unwrap()).unwrap());
for tag in tags {
writeln!(dest, "pub const {}: Tag = Tag {{ dword: {} }};", tag, tag.dword).unwrap();
}
}