-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
132 lines (128 loc) · 4.17 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
use std::{
// io,
// fs::{
// self,
// File,
// },
path::Path,
};
// fn download(url: &str, to: &str) {
// let path = Path::new(to);
// if path.is_file() {
// println!("File already exists: {}", to);
// return;
// }
// let parent = path.parent().unwrap();
// let mut resp = reqwest::blocking::get(url)
// .expect(&format!("Failed to get response for {}", url));
// fs::create_dir_all(parent)
// .expect("Failed to create parent directory");
// let mut out = File::create(path)
// .expect(&format!("Failed to create file {}", to));
// io::copy(&mut resp, &mut out)
// .expect(&format!("Failed to download {}", to));
// }
fn add_pthread(includes: &mut Vec<&str>) {
if cfg!(windows) {
includes.push("c/pthread-win32/include");
let arch = if cfg!(target_arch = "x86_64") {
"x64"
} else if cfg!(target_arch = "x86") {
"x86"
} else {
panic!("Unsupported architecture");
};
println!(
"cargo:rustc-link-search=native={}",
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("c")
.join("pthread-win32")
.join("lib")
.join(arch)
.display(),
);
println!("cargo:rustc-link-lib=pthreadVC3");
}
}
// fn make_bindings(name: &str) {
// println!("cargo:rerun-if-changed=src/solver/{}/bindings.rs", name);
// bindgen::Builder::default()
// .clang_arg(format!("-Ic/{}-c-bindings", name))
// .header(format!("c/wrappers/{}-wrapper.h", name))
// .generate()
// .expect(&format!("Could not create bindings to {}", name))
// .write_to_file(format!("src/solver/{}/bindings.rs", name))
// .expect(&format!("Couldn't write bindings for {}", name));
// }
fn main() {
// download(
// "https://raw.githubusercontent.com/madler/zlib/master/zlib.h",
// "c/lib/zlib.h",
// );
// download(
// "https://raw.githubusercontent.com/madler/zlib/master/zconf.h",
// "c/lib/zconf.h",
// );
// Minisat
cc::Build::new()
.warnings(false)
.cpp(true)
.include("c/minisat")
.include("c/lib")
.file("c/minisat/minisat/core/Solver.cc")
.file("c/minisat/minisat/simp/SimpSolver.cc")
.file("c/minisat/minisat/utils/System.cc")
.file("c/minisat-c-bindings/minisat.cc")
.flag_if_supported("-fpermissive")
.compile("minisat");
// Manysat
cc::Build::new()
.warnings(false)
.cpp(true)
.include("c/lib")
.include("c/manysat")
.file("c/manysat/core/Solver.cc")
.file("c/manysat/core/Cooperation.cc")
.file("c/manysat-c-bindings/manysat.cc")
.flag_if_supported("-fpermissive")
.compile("manysat");
// Maplesat
cc::Build::new()
.warnings(false)
.cpp(true)
.include("c/maplesat")
.include("c/lib")
.file("c/maplesat/core/Solver.cc")
.file("c/maplesat/simp/SimpSolver.cc")
.file("c/maplesat/utils/System.cc")
.file("c/maplesat-c-bindings/maplesat.cc")
.flag_if_supported("-fpermissive")
.compile("maplesat");
// Glucose
let mut includes = vec![
"c/lib",
"c/glucose",
];
add_pthread(&mut includes);
cc::Build::new()
.warnings(false)
.cpp(true)
.includes(includes)
.flag_if_supported("-fpermissive")
.file("c/glucose/parallel/MultiSolvers.cc")
.file("c/glucose/parallel/SolverConfiguration.cc")
.file("c/glucose/parallel/ParallelSolver.cc")
.file("c/glucose/parallel/SharedCompanion.cc")
.file("c/glucose/parallel/SolverCompanion.cc")
.file("c/glucose/parallel/ClausesBuffer.cc")
.file("c/glucose/simp/SimpSolver.cc")
.file("c/glucose/core/Solver.cc")
.file("c/glucose/utils/System.cc")
.file("c/glucose-c-bindings/glucose.cc")
.compile("glucose");
// Bindings
// make_bindings("minisat");
// make_bindings("manysat");
// make_bindings("maplesat");
// make_bindings("glucose");
}