-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbundled.rs
54 lines (45 loc) · 1.58 KB
/
bundled.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
#[cfg(feature = "bundled")]
use crate::download::download_and_extract_zip;
#[cfg(feature = "bundled")]
use std::env;
#[cfg(feature = "bundled")]
use std::path::PathBuf;
#[cfg(feature = "bundled")]
pub fn is_bundled_feature_enabled() -> bool {
true
}
#[cfg(feature = "bundled")]
pub fn download_scip() {
let extract_path = PathBuf::from(env::var("OUT_DIR").unwrap());
if extract_path.join("scip_install").exists() {
println!("cargo:warning=SCIP was previously downloaded, skipping download");
return;
}
let os = env::consts::OS;
let arch = std::env::consts::ARCH;
println!("cargo:warning=Detected OS: {}", os);
println!("cargo:warning=Detected arch: {}", arch);
let os_string = if os == "linux" && arch == "x86_64" {
"linux"
} else if os == "macos" && arch == "x86_64" {
"macos-intel"
} else if os == "macos" && arch == "aarch64" {
"macos-arm"
} else if os == "windows" && arch == "x86_64" {
"windows"
} else {
panic!("Unsupported OS-arch combination: {}-{}", os, arch);
};
// if debug mode is enabled, download the debug version of SCIP
#[cfg(debug_assertions)]
let debug_str = "-debug";
#[cfg(not(debug_assertions))]
let debug_str = "";
let url = format!(
"https://github.com/scipopt/scipoptsuite-deploy/releases/download/v0.7.0/libscip-{os_string}{debug_str}.zip",
);
download_and_extract_zip(&url, &extract_path)
.unwrap_or_else(|e| panic!("Failed to download and extract SCIP: {}", e));
}
#[cfg(not(feature = "bundled"))]
pub fn download_scip() {}