2026-08-13 09:58:33 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
|
|
|
|
|
|
fn main() {
|
2026-08-13 10:31:46 +00:00
|
|
|
let home = std::env::var("HOME").unwrap_or_else(|_| "/root".to_string());
|
|
|
|
|
let rvsttd_dir = PathBuf::from(&home).join(".rvsttd");
|
|
|
|
|
let lib_dir = rvsttd_dir.join("lib");
|
|
|
|
|
let include_dir = rvsttd_dir.join("include");
|
2026-08-13 09:58:33 +00:00
|
|
|
let header = include_dir.join("moonshine-c-api.h");
|
|
|
|
|
|
|
|
|
|
println!("cargo:rerun-if-changed={}", header.display());
|
|
|
|
|
println!("cargo:rustc-link-search=native={}", lib_dir.display());
|
|
|
|
|
println!("cargo:rustc-link-lib=dylib=moonshine");
|
|
|
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir.display());
|
|
|
|
|
|
|
|
|
|
let bindings = bindgen::Builder::default()
|
|
|
|
|
.header(header.to_str().unwrap())
|
|
|
|
|
.allowlist_function("moonshine_.*")
|
|
|
|
|
.allowlist_var("MOONSHINE_.*")
|
|
|
|
|
.allowlist_type("transcript.*|moonshine_option_t|speaker_span_t|transcript_word_t")
|
|
|
|
|
.derive_default(true)
|
|
|
|
|
.generate()
|
|
|
|
|
.expect("Unable to generate moonshine bindings");
|
|
|
|
|
|
|
|
|
|
let out_path = PathBuf::from(std::env::var("OUT_DIR").unwrap());
|
|
|
|
|
bindings
|
|
|
|
|
.write_to_file(out_path.join("moonshine_bindings.rs"))
|
|
|
|
|
.expect("Couldn't write bindings");
|
|
|
|
|
}
|