-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
33 lines (28 loc) · 1.14 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
use miette::IntoDiagnostic;
fn main() -> miette::Result<()> {
let mut cmake_config = cmake::Config::new("third_party/cpuinfo");
match std::env::var("CARGO_CFG_TARGET_OS").unwrap().as_str() {
"android" => {
cmake_config
.define("CMAKE_ANDROID_NDK", std::env::var("ANDROID_NDK_HOME").into_diagnostic()?);
}
"ios" => {
cmake_config.define("CMAKE_SYSTEM_NAME", "Darwin");
}
_ => {
cmake_config
.define("CPUINFO_BUILD_BENCHMARKS", "OFF")
.define("CPUINFO_BUILD_MOCK_TESTS", "OFF")
.define("CPUINFO_BUILD_PKG_CONFIG", "OFF")
.define("CPUINFO_BUILD_TOOLS", "OFF")
.define("CPUINFO_BUILD_UNIT_TESTS", "OFF")
.define("CPUINFO_LIBRARY_TYPE", "static")
.define("CPUINFO_RUNTIME_TYPE", "static")
.define("USE_SYSTEM_LIBS", "OFF");
}
}
let cmake_output_path = cmake_config.build();
println!("cargo:rustc-link-lib=static=cpuinfo");
println!("cargo:rustc-link-search=native={}/lib", cmake_output_path.display());
Ok(())
}