-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
39 lines (33 loc) · 1.25 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
use std::{env, path::PathBuf};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
#[cfg(feature = "cbindgen")]
{
let config = cbindgen::Config::from_file("cbindgen.toml").unwrap();
cbindgen::generate_with_config(&crate_dir, config)
.unwrap()
.write_to_file("zarrs.h");
}
let mut shared_object_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
shared_object_dir.push("target");
shared_object_dir.push(env::var("PROFILE").unwrap());
let shared_object_dir = shared_object_dir.as_path().to_string_lossy();
let include_dir = PathBuf::from(&crate_dir);
let include_dir = include_dir.as_path().to_string_lossy();
println!(
"cargo:rustc-env=INLINE_C_RS_CFLAGS=-I{I} -L{L} -D_DEBUG -D_CRT_SECURE_NO_WARNINGS",
I = include_dir,
L = shared_object_dir,
);
println!(
"cargo:rustc-env=INLINE_C_RS_LDFLAGS={shared_object_dir}/{lib}",
shared_object_dir = shared_object_dir,
lib = if cfg!(target_os = "windows") {
"zarrs_ffi.dll".to_string()
} else if cfg!(target_os = "macos") {
"libzarrs_ffi.dylib".to_string()
} else {
"libzarrs_ffi.so".to_string()
},
);
}