-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.rs
28 lines (23 loc) · 891 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
use std::env;
use std::path::{Path, PathBuf};
use glob::glob;
fn main() {
let manifest_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
let include_dir = Path::new(&manifest_dir).join("cld3");
cxx_build::CFG.exported_header_dirs.push(&include_dir);
let cxx_files = glob(format!("{}/*.cc", include_dir.to_string_lossy()).as_str())
.unwrap()
.filter_map(Result::ok)
.collect::<Vec<PathBuf>>();
cxx_build::bridge("src/lib.rs")
.file("cld3_wrapper.cc")
.files(cxx_files)
.flag_if_supported("-std=c++17")
.flag("-Wno-unused-parameter")
.flag("-Wno-implicit-fallthrough")
.compile("cxx-cld3");
println!("cargo:rustc-link-lib=protobuf");
println!("cargo:rerun-if-changed=cld3/cld3.cc");
println!("cargo:rerun-if-changed=cld3/cld3.h");
println!("cargo:rerun-if-changed=src/lib.rs");
}