Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WARP: Update README with macOS library path instructions #6256

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion plugins/warp/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#![allow(unused_imports)]
use std::path::PathBuf;
use std::process::Command;
use std::path::Path;

#[cfg(feature = "test")]
fn compile_rust(file: PathBuf) -> bool {
Expand All @@ -18,10 +19,48 @@ fn compile_rust(file: PathBuf) -> bool {
}

fn main() {
if let Some(link_path) = option_env!("BINARYNINJADIR") {

let binja_base_dir: &str = option_env!("DEP_BINARYNINJACORE_BASE_DIR").unwrap_or_else(|| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our build system needs to set its own paths, so unfortunately we can't do lookups like this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would work fine: 5239ad6

// If the environment variable is not set, try the default locations from
// https://docs.binary.ninja/guide/#binary-path

#[cfg(target_os = "macos")]
{
let default = "/Applications/Binary Ninja.app/";
if Path::new(default).exists() {
return default
}
}

#[cfg(target_os = "windows")]
{
let default = r"C:\Program Files\Vector35\BinaryNinja";
if Path::new(default).exists() {
return default
}
// Nothing at default path, check user path
if let Some(local_app_data) = std::env::var_os("LOCALAPPDATA") {
let user_path = Path::new(&local_app_data).join("Vector35").join("BinaryNinja");
if user_path.exists() {
return user_path.to_str().unwrap()
}
}
}

panic!("DEP_BINARYNINJACORE_BASE_DIR must be set to the base directory of the Binary Ninja installation");
});

if let link_path = binja_base_dir {
println!("cargo::rustc-link-lib=dylib=binaryninjacore");
println!("cargo::rustc-link-search={}", link_path);

#[cfg(target_os = "macos")]
{
// On macOS the binaryninjacore dylib is in the MacOS directory
println!("cargo::rustc-link-search={}/Contents/MacOS", link_path);
println!("cargo::rustc-link-arg=-Wl,-rpath,{0}/Contents/MacOS,-L{0}/Contents/MacOS", link_path);
}

#[cfg(not(target_os = "windows"))]
{
println!("cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}", link_path);
Expand Down