-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
76 lines (75 loc) · 2.66 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
67
68
69
70
71
72
73
74
75
76
use std::io::Result;
use std::process::{Child, Command};
fn clone_bdwgc(){
let path = std::env::var_os("OUT_DIR").expect("OUT_DIR is not set").to_owned();
let result = Command::new("git")
.current_dir(path)
.arg("clone")
.arg("--depth")
.arg("1")
.arg("https://github.com/ivmai/bdwgc")
.output()
.expect("failed to execute process");
if(result.stderr.len() > 0){
let message = std::str::from_utf8(&result.stderr).expect("Error message not UTF-8");
if !(message.contains("already exists and is not an empty directory") || message.contains("Cloning into '")){
panic!("error:{}",message);
}
}
}
fn clone_libatomic_ops(){
let mut path =std::env::var_os("OUT_DIR").expect("OUT_DIR is not set").to_owned();
//This is NOT how docs describe this ought to work!
path.push("/bdwgc/");
let result = Command::new("git")
.current_dir(path)
.arg("clone")
.arg("--depth")
.arg("1")
.arg("https://github.com/ivmai/libatomic_ops")
.output()
.expect("failed to execute process");
if(result.stderr.len() > 0){
let message = std::str::from_utf8(&result.stderr).expect("Error message not UTF-8");
if !(message.contains("already exists and is not an empty directory") || message.contains("Cloning into '")){
panic!("error:{}",message);
}
}
}
fn configure_cmake<P: AsRef<std::path::Path>>(compile_path: P) {
let result = Command::new("cmake")
.current_dir(compile_path)
.arg("-Denable_cplusplus=ON")
.arg("..")
.output()
.unwrap();
if(result.stderr.len() > 0){
let message = std::str::from_utf8(&result.stderr).expect("Error message not UTF-8");
if !(message.contains("Explicit GC_INIT() calls may be required.")){
panic!("error:{}",message);
}
}
}
fn cmake_build<P: AsRef<std::path::Path>>(compile_path: P) {
let result = Command::new("cmake")
.current_dir(compile_path)
.arg("--build")
.arg(".")
.output()
.unwrap();
if(result.stderr.len() > 0){
let message = std::str::from_utf8(&result.stderr).expect("Error message not UTF-8");
panic!("error:{}",message);
}
}
fn main() {
clone_bdwgc();
clone_libatomic_ops();
let mut compile_path = std::env::var_os("OUT_DIR")
.expect("OUT_DIR is not set")
.to_owned();
compile_path.push("/bdwgc/out");
std::fs::create_dir_all(&compile_path).unwrap();
configure_cmake(&compile_path);
cmake_build(&compile_path);
}