-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
49 lines (43 loc) · 1.53 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
use std::env;
use cmake::Config;
fn build_and_link_soplex() {
let profile = env::var("PROFILE").unwrap();
let build_type = if profile == "release" { "Release" } else { "Debug" };
// build soplex library with cmake
let dst = Config::new("soplex")
.profile(build_type)
.define("GMP", "off")
.define("BOOST", "off")
.define("QUADMATH", "off")
.define("PAPILO", "off")
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-search={}/lib64", dst.display());
println!("cargo:rustc-link-lib=static=soplex");
println!("cargo:rustc-link-lib=z");
let target = env::var("TARGET").unwrap();
let apple = target.contains("apple");
let linux = target.contains("linux");
let mingw = target.contains("pc-windows-gnu");
if apple {
println!("cargo:rustc-link-lib=dylib=c++");
} else if linux || mingw {
println!("cargo:rustc-link-lib=dylib=stdc++");
}
}
fn main() {
// skip building soplex on docs.rs
if std::env::var("DOCS_RS").is_err() {
build_and_link_soplex();
}
// generate bindings
let bindings = bindgen::Builder::default()
.header("soplex/src/soplex_interface.h")
.allowlist_function("SoPlex_.*")
.generate()
.expect("Unable to generate bindings");
let out_path = std::path::PathBuf::from(std::env::var("OUT_DIR").unwrap());
bindings
.write_to_file(out_path.join("bindings.rs"))
.expect("Couldn't write bindings!");
}