-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
86 lines (82 loc) · 3.58 KB
/
Copy pathbuild.rs
File metadata and controls
86 lines (82 loc) · 3.58 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
76
77
78
79
80
81
82
83
84
85
86
extern crate cmake;
extern crate bindgen;
use std::env;
use std::path::PathBuf;
fn main() {
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.use_core()
.ctypes_prefix("libc")
.whitelist_function(".*compress.*")
.whitelist_function(".*shuffle.*")
.whitelist_function(".*threads.*")
.whitelist_function(".*version.*")
.generate()
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
bindings
.write_to_file(out_path.join("src/bindings.rs"))
.expect("Couldn't write bindings!");
// TODO deduplicate code, only MinGW line for Windows, check if on MSVC
if cfg!(windows) {
if cfg!(target_env = "gnu") {
let dst = cmake::Config::new("c-blosc")
.generator("MinGW Makefiles")
.define("BUILD_STATIC", "ON")
.define("BUILD_SHARED", "OFF")
.define("BUILD_TESTS", "OFF")
.define("BUILD_BENCHMARKS", "OFF")
.define("DEACTIVATE_AVX2", "OFF")
.define("DEACTIVATE_LZ4", "OFF")
.define("DEACTIVATE_SNAPPY", "ON")
.define("DEACTIVATE_ZLIB", "OFF")
.define("DEACTIVATE_ZSTD", "OFF")
.define("PREFER_EXTERNAL_LZ4", "OFF")
.define("PREFER_EXTERNAL_SNAPPY", "OFF")
.define("PREFER_EXTERNAL_ZLIB", "OFF")
.define("PREFER_EXTERNAL_ZSTD", "OFF")
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=blosc");
}else{
let dst = cmake::Config::new("c-blosc")
.define("BUILD_STATIC", "ON")
.define("BUILD_SHARED", "OFF")
.define("BUILD_TESTS", "OFF")
.define("BUILD_BENCHMARKS", "OFF")
.define("DEACTIVATE_AVX2", "OFF")
.define("DEACTIVATE_LZ4", "OFF")
.define("DEACTIVATE_SNAPPY", "ON")
.define("DEACTIVATE_ZLIB", "OFF")
.define("DEACTIVATE_ZSTD", "OFF")
.define("PREFER_EXTERNAL_LZ4", "OFF")
.define("PREFER_EXTERNAL_SNAPPY", "OFF")
.define("PREFER_EXTERNAL_ZLIB", "OFF")
.define("PREFER_EXTERNAL_ZSTD", "OFF")
// .define("CMAKE_BUILD_TYPE", "Release") - cmake-rs does the right this depending on opt-level and debug/release
.static_crt(true)
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=libblosc");
}
} else {
let dst = cmake::Config::new("c-blosc")
.define("BUILD_STATIC", "ON")
.define("BUILD_SHARED", "OFF")
.define("BUILD_TESTS", "OFF")
.define("BUILD_BENCHMARKS", "OFF")
.define("DEACTIVATE_AVX2", "OFF")
.define("DEACTIVATE_LZ4", "OFF")
.define("DEACTIVATE_SNAPPY", "ON")
.define("DEACTIVATE_ZLIB", "OFF")
.define("DEACTIVATE_ZSTD", "OFF")
.define("PREFER_EXTERNAL_LZ4", "OFF")
.define("PREFER_EXTERNAL_SNAPPY", "OFF")
.define("PREFER_EXTERNAL_ZLIB", "OFF")
.define("PREFER_EXTERNAL_ZSTD", "OFF")
.build();
println!("cargo:rustc-link-search=native={}/lib", dst.display());
println!("cargo:rustc-link-lib=static=blosc");
}
}