-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.rs
37 lines (34 loc) · 1.11 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
#[cfg(not(feature = "opencv"))]
fn main() {}
#[cfg(feature = "opencv")]
fn main() {
extern crate bindgen;
extern crate pkg_config;
use std::env;
use std::path;
let library = pkg_config::Config::new().probe("opencv").unwrap();
let bindings = bindgen::Builder::default()
.clang_args(
library
.include_paths
.iter()
.map(|p| format!("-I{}", p.to_str().unwrap())),
)
.header("wrapper.h")
.whitelist_function("cvCreateImageHeader")
.whitelist_function("cvSetData")
.whitelist_function("cvReleaseImageHeader")
.whitelist_function("cvCopy")
.whitelist_function("cvShowImage")
.whitelist_function("cvWaitKey")
.whitelist_function("cvCreateCameraCapture")
.whitelist_function("cvReleaseCapture")
.whitelist_function("cvQueryFrame")
.prepend_enum_name(false)
.rustfmt_bindings(false)
.generate()
.unwrap();
bindings
.write_to_file(path::PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs"))
.unwrap();
}