-
Notifications
You must be signed in to change notification settings - Fork 7
/
build.rs
41 lines (34 loc) · 1.16 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
#[cfg(feature = "ffi")]
fn main() {
use std::env;
use std::path::PathBuf;
const LIB_NAME: &str = "libcqlite.dylib";
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
cbindgen::Builder::new()
.with_crate(&manifest_dir)
.with_language(cbindgen::Language::C)
.with_no_includes()
.with_sys_include("stdint.h")
.with_sys_include("stdbool.h")
.with_include_guard("CQLITE_H")
.generate()
.unwrap()
.write_to_file("cqlite.h");
let include_dir = manifest_dir.clone();
let mut shared_object_dir = PathBuf::from(manifest_dir);
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();
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 = LIB_NAME,
);
}
#[cfg(not(feature = "ffi"))]
fn main() {}