-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
33 lines (28 loc) · 859 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
use std::env::var;
use std::path::PathBuf;
fn main() {
let out = PathBuf::from(var("OUT_DIR").unwrap());
bindgen::builder()
.header("crossdb/include/crossdb.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate()
.unwrap()
.write_to_file(out.join("./bindings.rs"))
.unwrap();
let mut builder = cc::Build::new();
builder
.file("crossdb/src/crossdb.c")
.include("crossdb/include")
.flag("-lpthread")
.opt_level(2)
.static_flag(true);
// TODO: Potentially unsafe
builder.cargo_warnings(false);
#[cfg(target_os = "windows")]
{
builder.flag("-lws2_32").compiler("gcc");
}
builder.compile("crossdb");
println!("cargo:rustc-link-lib=static=crossdb");
println!("cargo:rerun-if-changed=crossdb/");
}