use std::env;
use std::path::{Path, PathBuf};
fn main() {
println!("cargo:rerun-if-env-changed=DEP_NOESIS_LIB_DIR");
if env::var_os("DOCS_RS").is_some() {
return;
}
let lib_dir = env::var("DEP_NOESIS_LIB_DIR").expect(
"DEP_NOESIS_LIB_DIR not set: noesis_runtime's build.rs should emit it via \
`cargo:lib_dir=...`. Did the noesis_runtime dependency build?",
);
match env::var("CARGO_CFG_TARGET_OS").as_deref() {
Ok("linux") => {
println!("cargo:rustc-link-arg=-Wl,-rpath,{lib_dir}");
}
Ok("windows") => {
let dll = Path::new(&lib_dir).join("Noesis.dll");
let out_dir = PathBuf::from(env::var("OUT_DIR").expect("OUT_DIR"));
if let Some(profile_dir) = out_dir.ancestors().nth(3) {
for sub in ["", "deps", "examples"] {
let dest = profile_dir.join(sub);
if dest.is_dir() {
let _ = std::fs::copy(&dll, dest.join("Noesis.dll"));
}
}
}
}
_ => {}
}
}