-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.rs
37 lines (32 loc) · 987 Bytes
/
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
#[cfg(not(feature = "cmake"))]
fn main() -> std::io::Result<()> {
let mut make = cc::Build::new();
make.include("include");
make.define("A_EXPORTS", None);
#[cfg(feature = "float")]
make.define("A_SIZE_REAL", "4");
#[cfg(feature = "static_crt")]
make.static_crt(true);
for entry in std::fs::read_dir("src")? {
let path = entry?.path();
let extension = path.extension().unwrap();
if path.is_file() & extension.eq("c") {
make.file(path);
}
}
make.compile("a");
Ok(())
}
#[cfg(feature = "cmake")]
fn main() {
let mut cmake = cmake::Config::new("");
cmake.define("BUILD_TESTING", "0");
#[cfg(feature = "float")]
cmake.define("LIBA_REAL", "4");
#[cfg(feature = "static_crt")]
cmake.static_crt(true);
let out = cmake.build();
let lib = out.join("lib");
println!("cargo:rustc-link-search=native={}", lib.display());
println!("cargo:rustc-link-lib=static=a");
}