39 lines
1.6 KiB
Rust
39 lines
1.6 KiB
Rust
//! Build script linking the C++ vision backend into the Rust cdylib.
|
|
fn main() {
|
|
let project_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
|
|
let root_dir = std::path::Path::new(&project_dir).parent().unwrap();
|
|
let lib_dir = root_dir.join("build").join("lib");
|
|
|
|
println!("cargo:rustc-link-search=native={}", lib_dir.display());
|
|
println!("cargo:rustc-link-lib=dylib=visioncpp");
|
|
println!("cargo:rustc-link-lib=dylib=ggml");
|
|
println!("cargo:rustc-link-lib=dylib=ggml-cpu");
|
|
println!("cargo:rustc-link-lib=dylib=ggml-base");
|
|
|
|
// Look in the executable/plugin directory first, then in build/lib.
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,$ORIGIN");
|
|
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", lib_dir.display());
|
|
|
|
// Copy runtime dependencies next to the built plugin so both the
|
|
// cargo target directory and the plugins/ staging directory work without
|
|
// extra LD_LIBRARY_PATH setup.
|
|
let target_dir = std::path::Path::new(&project_dir)
|
|
.join("..").join("..").join("target")
|
|
.join(std::env::var("PROFILE").unwrap());
|
|
if target_dir.exists() {
|
|
let libs = [
|
|
"libvisioncpp.so", "libvisioncpp.so.0", "libvisioncpp.so.0.3.1",
|
|
"libggml.so", "libggml.so.0", "libggml.so.0.9.9",
|
|
"libggml-cpu.so", "libggml-cpu.so.0", "libggml-cpu.so.0.9.9",
|
|
"libggml-base.so", "libggml-base.so.0", "libggml-base.so.0.9.9",
|
|
];
|
|
for lib in &libs {
|
|
let src = lib_dir.join(lib);
|
|
let dst = target_dir.join(lib);
|
|
if src.exists() {
|
|
std::fs::copy(&src, &dst).ok();
|
|
}
|
|
}
|
|
}
|
|
}
|