forked from oxfordcontrol/Clarabel.rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rs
62 lines (52 loc) · 1.72 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
use std::error::Error;
#[cfg(feature = "buildinfo")]
use vergen::*;
macro_rules! printinfo {
($($tokens: tt)*) => {
println!("cargo:warning=\r\x1b[36;1m {}", format!($($tokens)*))
}
}
fn main() -> Result<(), Box<dyn Error>> {
config_python_blas();
#[cfg(feature = "buildinfo")]
config_build_info()?;
Ok(())
}
#[cfg(feature = "buildinfo")]
fn config_build_info() -> Result<(), Box<dyn Error>> {
// NOTE: This will output everything, and requires all features enabled.
// NOTE: See the specific builder documentation for configuration options.
let build = BuildBuilder::all_build()?;
let cargo = CargoBuilder::all_cargo()?;
let rustc = RustcBuilder::all_rustc()?;
let si = SysinfoBuilder::all_sysinfo()?;
Emitter::default()
.add_instructions(&build)?
.add_instructions(&cargo)?
.add_instructions(&rustc)?
.add_instructions(&si)?
.emit()?;
Ok(())
}
fn config_python_blas() {
// cfg(sdp_pyblas) is used to indicate that BLAS/LAPACK functions
// should be taken from Python's scipy. It will only be defined
// for python builds that do not link to one of the blas/lapack
// libraries provided by blas-src and lapack-src.
println!("cargo:rustc-check-cfg=cfg(sdp_pyblas)");
if cfg!(not(feature = "python")) {
return;
}
if !cfg!(any(
feature = "sdp-accelerate",
feature = "sdp-netlib",
feature = "sdp-openblas",
feature = "sdp-mkl",
feature = "sdp-r"
)) {
println!("cargo:rustc-cfg=sdp_pyblas");
printinfo!("Python: compiling with python blas from scipy");
} else {
printinfo!("Python: compiling with local blas/lapack libraries");
}
}