forked from immunant/c2rust
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
66 lines (59 loc) · 2.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
fn process_ast(mode: &str, dest: &Path) {
let mut p = Command::new("python3")
.arg("-B") // Don't write bytecode files (and thus pollute the source
// directory)
.arg("gen/process_ast.py")
.arg(mode)
.arg(dest)
.spawn()
.expect("failed to run process_ast.py. Make sure python3 is in your PATH.");
let ret = p.wait().expect("failed to wait on process_ast.py");
assert!(ret.success(), "error while running process_ast.py");
}
fn main() {
let out_dir_str = env::var("OUT_DIR").unwrap();
let out_dir = Path::new(&out_dir_str);
process_ast("ast_deref", &out_dir.join("ast_deref_gen.inc.rs"));
process_ast("ast_equiv", &out_dir.join("ast_equiv_gen.inc.rs"));
process_ast("matcher", &out_dir.join("matcher_impls_gen.inc.rs"));
process_ast("get_span", &out_dir.join("get_span_gen.inc.rs"));
process_ast("get_node_id", &out_dir.join("get_node_id_gen.inc.rs"));
process_ast("lr_expr", &out_dir.join("lr_expr_gen.inc.rs"));
process_ast("list_node_ids", &out_dir.join("list_node_ids_gen.inc.rs"));
process_ast("mac_table", &out_dir.join("mac_table_gen.inc.rs"));
process_ast("nt_match", &out_dir.join("nt_match_gen.inc.rs"));
process_ast("ast_names", &out_dir.join("ast_names_gen.inc.rs"));
process_ast("lua_ast_node", &out_dir.join("lua_ast_node_gen.inc.rs"));
process_ast(
"rewrite_rewrite",
&out_dir.join("rewrite_rewrite_gen.inc.rs"),
);
process_ast(
"rewrite_recursive",
&out_dir.join("rewrite_recursive_gen.inc.rs"),
);
process_ast(
"rewrite_recover_children",
&out_dir.join("rewrite_recover_children_gen.inc.rs"),
);
process_ast(
"rewrite_seq_item",
&out_dir.join("rewrite_seq_item_gen.inc.rs"),
);
process_ast(
"rewrite_maybe_rewrite_seq",
&out_dir.join("rewrite_maybe_rewrite_seq_gen.inc.rs"),
);
println!("cargo:rerun-if-changed=gen/");
for entry in fs::read_dir(&"gen").unwrap() {
let name = entry.unwrap().file_name().into_string().unwrap();
if name.starts_with(".") {
continue;
}
println!("cargo:rerun-if-changed=gen/{}", name);
}
}