test-smi-rs 0.1.2

APIs for managing and monitoring FuriosaAI NPUs
Documentation
use std::env;
use std::path::{Path, PathBuf};

use bindgen::Builder;

fn main() {
    let root_path =
        PathBuf::from(env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR is not set"));
    gen_smi_binding(&root_path);
    link_furiosa_smi();
}

fn gen_smi_binding(root_path: &Path) {
    let include_path = root_path.join("include");
    let header_path = include_path.join("furiosa_smi.h");
    let output_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("binding.rs");

    Builder::default()
        .header(header_path.to_str().unwrap())
        .clang_arg(format!("-I{}", include_path.to_str().unwrap()))
        .generate_inline_functions(true)
        .generate()
        .expect("Unable to generate bindings")
        .write_to_file(output_path.clone())
        .expect("Couldn't write bindings!");

    println!("hwloc bindings generated at {:?}", output_path.display());
}

fn link_furiosa_smi() {
    println!("cargo:rustc-link-lib=dylib=furiosa_smi");
    //fixme(@bg): search path should be update if we support apt and/or yum package
    println!("cargo:rustc-link-search=native=/usr/local/lib");
}