-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
41 lines (37 loc) · 1.04 KB
/
Copy pathbuild.rs
File metadata and controls
41 lines (37 loc) · 1.04 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
38
39
40
41
use std::env;
use std::path::*;
use std::process::*;
fn main() {
println!("cargo:rerun-if-changed=src/runtime");
println!("cargo:rerun-if-changed=src/llvm");
let out_dir = env::var("OUT_DIR").unwrap();
let mut build = cc::Build::new();
build.cpp(true).files(&[
"src/llvm/main.cpp",
"src/llvm/inliner.cpp",
"src/llvm/tailerizer.cpp",
]);
build.warnings(false).compile("durin-llvm");
let mut out_file = PathBuf::from(out_dir.clone());
out_file.push("prelude.bc");
if !Command::new("llvm-as")
.args(&["src/runtime/prelude.ll", "-o"])
.arg(out_file)
.status()
.unwrap()
.success()
{
panic!("Failed to assemble prelude.ll");
}
let mut out_file = PathBuf::from(out_dir);
out_file.push("runtime.bc");
if !Command::new("clang")
.args(&["src/runtime/runtime.c", "-c", "-emit-llvm", "-g", "-o"])
.arg(out_file)
.status()
.unwrap()
.success()
{
panic!("Failed to compile runtime.c");
}
}