extern crate cbindgen;

use std::env;


fn main() {
    let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
    // We automatically generate C headers to ensure safe interoperability.
    // This prevents the common "drift" between implementation and header found in manual C projects.
    match cbindgen::Builder::new()
        .with_crate(crate_dir)
        .with_language(cbindgen::Language::C)
        .with_autogen_warning("/* Generated by cbindgen. Do not modify manually. */")
        .generate()
    {
        Ok(bindings) => {
             // By writing to "aman.h", we ensure the artifact is where the developer expects it,
             // ready to be included in their C/C++ build pipelines.
             bindings.write_to_file("aman.h");
        },
        Err(e) => {
            println!("cargo:warning=Unable to generate bindings: {:?}", e);
        }
    }
}
