libobs-bootstrapper 0.1.2

Downloads OBS binaries at runtime and bootstraps libobs
use std::path::PathBuf;

#[cfg(not(feature = "install_dummy_dll"))]
fn main() {
    println!("cargo:rerun-if-changed=build.rs");
}

#[cfg(feature = "install_dummy_dll")]
fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    let dll = include_bytes!("./assets/obs-dummy.dll");

    // Cargo target directory (one level up from OUT_DIR)
    let out_dir = PathBuf::from(std::env::var("OUT_DIR").unwrap());
    let target_dir = out_dir
        .ancestors()
        .nth(3) // up from target/<profile>/build/<crate>/out
        .unwrap();

    let obs_dll_file = target_dir.join("obs.dll");
    if !obs_dll_file.exists() {
        std::fs::write(obs_dll_file, dll).unwrap();
    }
}