paddle-inference-rs 0.1.0

Rust bindings for PaddlePaddle inference library
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(())
}