use std::env;
use std::fs;
use std::path::PathBuf;
fn main() {
if env::var("CARGO_CFG_DOCS_RS").is_ok() {
return;
}
let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set");
let profile_dir = PathBuf::from(&out_dir)
.ancestors().nth(3)
.expect("Failed to get profile dir").to_path_buf();
let so_name = format!(
"libmumuregex{}",
std::env::consts::DLL_SUFFIX );
let from = profile_dir.join(&so_name);
let project_root = profile_dir.parent().and_then(|p| p.parent()).unwrap().to_path_buf();
let to = project_root.join(&so_name);
if from.exists() {
match fs::copy(&from, &to) {
Ok(_) => println!("cargo:warning=Copied {:?} -> {:?}", from, to),
Err(e) => println!("cargo:warning=Failed to copy plugin: {e}"),
}
} else {
println!("cargo:warning=Did not find plugin to copy: {:?}", from);
}
}