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
use anyhow::Result;
use std::env;
use std::path::PathBuf;
fn main() -> Result<()> {
// Get the directory containing Cargo.toml
let manifest_dir = env::var("CARGO_MANIFEST_DIR")?;
let manifest_path = PathBuf::from(&manifest_dir);
// Set up library search paths
let lib_dir = manifest_path.join("paddle/lib");
println!("cargo:rustc-link-search=native={}", lib_dir.display());
println!("cargo:rustc-link-lib=dylib=paddle_inference_c");
println!("cargo:rerun-if-changed=paddle/wrapper.h");
#[cfg(feature = "gen")]
{
let bindings = bindgen::Builder::default()
.header("paddle/wrapper.h")
// .opaque_type("std::.*")
// .allowlist_type("Point")
// .allowlist_type("DefectInfo")
// .allowlist_type("DetectionResult")
// .allowlist_function("createDetector")
// .allowlist_function("initializeDetector")
// .allowlist_function("detect")
// .allowlist_function("releaseDetector")
.generate()
.expect("Unable to generate bindings");
let out_path = PathBuf::from("src");
bindings
.write_to_file(out_path.join("paddle_inference.rs"))
.expect("Couldn't write bindings!");
}
Ok(())
}