| 1 | use std::path::PathBuf; |
| 2 | |
| 3 | fn main() { |
| 4 | let link_path = |
| 5 | std::env::var_os("DEP_BINARYNINJACORE_PATH").expect("DEP_BINARYNINJACORE_PATH specified"); |
| 6 | |
| 7 | println!("cargo::rustc-link-lib=dylib=binaryninjacore"); |
| 8 | println!("cargo::rustc-link-search={}", link_path.to_str().unwrap()); |
| 9 | |
| 10 | #[cfg(not(target_os = "windows"))] |
| 11 | { |
| 12 | println!( |
| 13 | "cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}", |
| 14 | link_path.to_string_lossy() |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR specified"); |
| 19 | let out_dir_path = PathBuf::from(out_dir); |
| 20 | |
| 21 | // Copy all binaries to OUT_DIR for unit tests. |
| 22 | let bin_dir: PathBuf = "fixtures/bin".into(); |
| 23 | if let Ok(entries) = std::fs::read_dir(bin_dir) { |
| 24 | for entry in entries { |
| 25 | let entry = entry.unwrap(); |
| 26 | let path = entry.path(); |
| 27 | if path.is_file() { |
| 28 | let file_name = path.file_name().unwrap(); |
| 29 | let dest_path = out_dir_path.join(file_name); |
| 30 | std::fs::copy(&path, &dest_path).expect("failed to copy binary to OUT_DIR"); |
| 31 | } |
| 32 | } |
| 33 | } |
| 34 | } |