nsi-sys 0.1.4

Auto-generated Rust bindings for Illumination Research’s Nodal Scene Interface – ɴsɪ.
Documentation
// build.rs
extern crate bindgen;

use std::{
    env,
    path::{Path, PathBuf},
};

fn main() {
    // TODO: make this generic & work on Linux/Windows
    let delight = match &env::var("DELIGHT") {
        Err(_) => {
            #[cfg(target_os="windows")]
            {
                panic!("Please download & install 3Delight from https://www.3delight.com/download before building this crate");
            }
            eprintln!("Building against 3Delight 2.1.2 shipped with crate");
            env::var("CARGO_MANIFEST_DIR").unwrap()
        }
        Ok(path) => {
            eprintln!("Building against locally installed 3Delight @ {}", &path);
            path.to_string()
        }
    };

    // Emit linker searchpath
    println!(
        "cargo:rustc-link-search={}",
        Path::new(&delight).join("lib").display()
    );
    // Link to lib3delight
    println!("cargo:rustc-link-lib=3delight");

    // Build bindings
    let bindings = bindgen::Builder::default()
        .header("wrapper.h")
        // Searchpath
        .clang_arg(format!(
            "-I{}",
            Path::new(&delight).join("include").display()
        ))
        .generate()
        .expect("Unable to generate bindings");

    // Write the bindings to the $OUT_DIR/bindings.rs file.
    let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());

    bindings
        .write_to_file(out_path.join("bindings.rs"))
        .expect("Couldn't write bindings.");
}