forked from bext-lang/b
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
37 lines (32 loc) · 1.11 KB
/
Copy pathbuild.rs
File metadata and controls
37 lines (32 loc) · 1.11 KB
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
use std::process::Command;
fn main() {
// 1. Compile C helper stubs
cc::Build::new()
.file("thirdparty/nob.c")
.file("thirdparty/arena.c")
.file("thirdparty/jim.c")
.file("thirdparty/flag.c")
.file("thirdparty/glob.c")
.file("thirdparty/jimp.c")
.file("thirdparty/libc.c")
.file("thirdparty/shlex.c")
.file("thirdparty/time.c")
.include("thirdparty")
.warnings(false)
.compile("crust_thirdparty");
println!("cargo:rustc-link-lib=c");
// 2. Build and run bgen to generate src/codegen/.INDEX.rs if missing
if !std::path::Path::new("src/codegen/.INDEX.rs").exists() {
let status = Command::new("rustc")
.args(&["src/bgen.rs", "-o", "target/bgen_build"])
.status()
.expect("Failed to compile bgen.rs");
if status.success() {
Command::new("./target/bgen_build")
.status()
.expect("Failed to run bgen");
}
}
println!("cargo:rerun-if-changed=thirdparty/");
println!("cargo:rerun-if-changed=src/codegen/");
}