diff options
| author | KyleMiles <krm504@nyu.edu> | 2022-01-27 22:43:28 -0500 |
|---|---|---|
| committer | KyleMiles <krm504@nyu.edu> | 2022-01-28 00:24:06 -0500 |
| commit | 6812c973c9fa9b4ad642ab81856c05f87bd6fcc4 (patch) | |
| tree | dace4156d03148bcaf02df138ab4e0d93e61bc6f /rust/examples/basic_script | |
| parent | 519c9db22367f2659d1a54599fab47e6313be06e (diff) | |
Format All Files
Diffstat (limited to 'rust/examples/basic_script')
| -rw-r--r-- | rust/examples/basic_script/build.rs | 79 |
1 files changed, 40 insertions, 39 deletions
diff --git a/rust/examples/basic_script/build.rs b/rust/examples/basic_script/build.rs index 7ad93884..5ba9bcde 100644 --- a/rust/examples/basic_script/build.rs +++ b/rust/examples/basic_script/build.rs @@ -14,54 +14,55 @@ static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun"); // Check last run location for path to BinaryNinja; Otherwise check the default install locations fn link_path() -> PathBuf { - use std::io::prelude::*; + use std::io::prelude::*; - let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap()); - let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1); + let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap()); + let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1); - File::open(lastrun) - .and_then(|f| { - let mut binja_path = String::new(); - let mut reader = BufReader::new(f); + File::open(lastrun) + .and_then(|f| { + let mut binja_path = String::new(); + let mut reader = BufReader::new(f); - reader.read_line(&mut binja_path)?; - Ok(PathBuf::from(binja_path.trim())) - }) - .unwrap_or_else(|_| { - #[cfg(target_os = "macos")] - return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS"); + reader.read_line(&mut binja_path)?; + Ok(PathBuf::from(binja_path.trim())) + }) + .unwrap_or_else(|_| { + #[cfg(target_os = "macos")] + return PathBuf::from("/Applications/Binary Ninja.app/Contents/MacOS"); - #[cfg(target_os = "linux")] - return home.join("binaryninja"); + #[cfg(target_os = "linux")] + return home.join("binaryninja"); - #[cfg(windows)] - return PathBuf::from(env::var("PROGRAMFILES").unwrap()).join("Vector35\\BinaryNinja\\"); - }) + #[cfg(windows)] + return PathBuf::from(env::var("PROGRAMFILES").unwrap()) + .join("Vector35\\BinaryNinja\\"); + }) } fn main() { - // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults - let install_path = env::var("BINARYNINJADIR") - .map(PathBuf::from) - .unwrap_or_else(|_| link_path()); + // Use BINARYNINJADIR first for custom BN builds/configurations (BN devs/build server), fallback on defaults + let install_path = env::var("BINARYNINJADIR") + .map(PathBuf::from) + .unwrap_or_else(|_| link_path()); - #[cfg(target_os = "linux")] - println!( - "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1", - install_path.to_str().unwrap(), - install_path.to_str().unwrap(), - ); + #[cfg(target_os = "linux")] + println!( + "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-l:libbinaryninjacore.so.1", + install_path.to_str().unwrap(), + install_path.to_str().unwrap(), + ); - #[cfg(target_os = "macos")] - println!( - "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore", - install_path.to_str().unwrap(), - install_path.to_str().unwrap(), - ); + #[cfg(target_os = "macos")] + println!( + "cargo:rustc-link-arg=-Wl,-rpath,{},-L{},-lbinaryninjacore", + install_path.to_str().unwrap(), + install_path.to_str().unwrap(), + ); - #[cfg(target_os = "windows")] - { - println!("cargo:rustc-link-lib=binaryninjacore"); - println!("cargo:rustc-link-search={}", install_path.to_str().unwrap()); - } + #[cfg(target_os = "windows")] + { + println!("cargo:rustc-link-lib=binaryninjacore"); + println!("cargo:rustc-link-search={}", install_path.to_str().unwrap()); + } } |
