-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
71 lines (66 loc) · 2.5 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
extern crate cc;
extern crate bindgen;
use std::env;
use std::path::PathBuf;
// use std::process::Command;
fn main() {
// Command::new("sh").args(&["pre_build.sh"])
// .status().unwrap();
#[cfg(feature = "generate-bindings")]
generate_bindings();
build();
}
#[cfg(feature = "generate-bindings")]
fn generate_bindings(){
let bindings = bindgen::Builder::default()
.header("cglucose/wrapper.h")
.allowlist_type("*CGlucose*")
.allowlist_function("cglucose_init")
.allowlist_function("cglucose_assume")
.allowlist_function("cglucose_solve")
.allowlist_function("cglucose_val")
.allowlist_function("cglucose_add_to_clause")
.allowlist_function("cglucose_commit_clause")
.allowlist_function("cglucose_clean_clause")
.allowlist_function("cglucose_solver_nodes")
.allowlist_function("cglucose_nb_learnt")
.allowlist_function("cglucose_set_random_seed")
.allowlist_function("cglucose_clean_clause_receive")
.allowlist_function("cglucose_clean_clause_send")
.allowlist_function("cglucose_add_to_clause_receive")
.allowlist_function("cglucose_add_to_clause_send")
.allowlist_function("cglucose_print_incremental_stats")
.allowlist_function("cglucose_commit_incoming_clause")
//.allowlist_function("cglucose_get_add_conflicts_size")
//.allowlist_function("cglucose_get_conflicts_at")
.rustfmt_bindings(true)
// .enable_cxx_namespaces()
.clang_arg("-Icglucose/")
// .clang_arg(r"-std=c++11")
// .clang_arg("-xc++")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("glucose_bindings.rs"))
.expect("Couldn't write bindings!");
}
fn build(){
cc::Build::new()
.include("cglucose/")
.cpp(true)
.file("cglucose/simp/SimpSolver.cc")
.file("cglucose/simp/SolverHelper.cc")
.file("cglucose/utils/System.cc")
.file("cglucose/utils/Options.cc")
.file("cglucose/core/Solver.cc")
.file("cglucose/wrapper.cpp")
.flag_if_supported("-D__STDC_LIMIT_MACROS")
.flag_if_supported("-D__STDC_FORMAT_MACROS")
.flag_if_supported("-DNDEBUG")
.flag_if_supported("-fomit-frame-pointer")
.flag_if_supported("-std=c++11")
.flag_if_supported("-w")
.opt_level(3)
.compile("glucose");
}