-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathfrom_source.rs
More file actions
75 lines (67 loc) · 2.37 KB
/
Copy pathfrom_source.rs
File metadata and controls
75 lines (67 loc) · 2.37 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
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
#[cfg(feature = "from-source")]
use crate::download::download_and_extract_tar_gz;
#[cfg(feature = "from-source")]
use std::env;
use std::path::PathBuf;
#[cfg(feature = "from-source")]
pub fn is_from_source_feature_enabled() -> bool {
true
}
#[cfg(not(feature = "from-source"))]
pub fn is_from_source_feature_enabled() -> bool {
false
}
#[cfg(not(feature = "from-source"))]
pub fn download_scip_source() -> PathBuf {
unimplemented!("Cannot download SCIP source code without the `from-source` feature")
}
#[cfg(feature = "from-source")]
pub fn download_scip_source() -> PathBuf {
let scip_version = "10.0.2";
let url = format!(
"https://github.com/scipopt/scip/releases/download/v{scip_version}/scipoptsuite-{scip_version}.tgz"
);
let target = env::var("OUT_DIR").unwrap();
let target = std::path::Path::new(&target);
if target.join(format!("scipoptsuite-{scip_version}")).exists() {
println!("cargo:warning=SCIP was previously downloaded, skipping download");
} else {
download_and_extract_tar_gz(&url, target).expect("Failed to download SCIP");
}
target.join(format!("scipoptsuite-{scip_version}"))
}
#[cfg(feature = "from-source")]
pub fn compile_scip(source_path: PathBuf) -> PathBuf {
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = std::path::Path::new(&out_dir);
let lib_path = out_dir.join("lib");
if lib_path.exists() {
println!("cargo:warning=SCIP was previously compiled, skipping compilation");
return out_dir.to_path_buf();
}
use cmake::Config;
let dst = Config::new(source_path)
.define("IPOPT", "OFF")
.define("ZIMPL", "OFF")
.define("GMP", "OFF")
.define("READLINE", "OFF")
.define("BOOST", "OFF")
.define("AUTOBUILD", "OFF")
.define("PAPILO", "OFF")
.define("SYM", "snauty")
.define("ZLIB", "OFF")
.define("SHARED", "OFF")
.define("CMAKE_INSTALL_LIBDIR", "lib")
.define("GCG", "OFF")
.define("UG", "OFF")
.define("SANITIZE_ADDRESS", "OFF")
.define("SANITIZE_MEMORY", "OFF")
.define("SANITIZE_UNDEFINED", "OFF")
.define("SANITIZE_THREAD", "OFF")
.build();
dst
}
#[cfg(not(feature = "from-source"))]
pub fn compile_scip(_source_path: PathBuf) -> PathBuf {
unimplemented!("Cannot compile SCIP without the `from-source` feature")
}