// Copyright 2026 California Institute of Technology
//
// You should have received a copy of the licensing terms for this
// software included in the file “LICENSE” located in the top-level
// directory of this package. If you did not, you can view a copy at
// http://dcc.ligo.org/M1500244/LICENSE.txt

use std::env;
use std::path::PathBuf;

fn main() {
    println!("cargo::rustc-link-search=/usr/lib/epics/lib/host");
    println!("cargo::rustc-link-lib=ca");
    println!("cargo::rustc-link-lib=Com");

    let bindings = bindgen::Builder::default()
        .header("include/epics-sys-wrapper.h")
        .clang_arg("-I/usr/lib/epics/include")
        .clang_arg("-I/usr/lib/epics/include/os/Linux")
        .clang_arg("-I/usr/lib/epics/include/compiler/clang")
        .parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
        .generate()
        .expect("Unable to generate bindings");

    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings");
}
