From 04597e06cdb05948fb145378d23a4cb5a90f3c0f Mon Sep 17 00:00:00 2001 From: yrp Date: Sun, 14 Feb 2021 21:41:02 -0800 Subject: Fix rust plugin linking on Windows Windows requires the symbols from the core to crate the plugin dll. As these were gated behind the headless feature, these didn't exist, and thus linking failed. Enabling the headless feature was also insufficient, as headless features disabled CorePluginABIVersion function. This patch turns all the headless cfgs into headless or windows cfgs. --- rust/binaryninjacore-sys/build.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'rust/binaryninjacore-sys') diff --git a/rust/binaryninjacore-sys/build.rs b/rust/binaryninjacore-sys/build.rs index 24be4dac..126077d6 100644 --- a/rust/binaryninjacore-sys/build.rs +++ b/rust/binaryninjacore-sys/build.rs @@ -3,11 +3,11 @@ extern crate bindgen; use std::env; use std::path::PathBuf; -#[cfg(feature = "headless")] +#[cfg(any(windows, feature = "headless"))] use std::fs::File; -#[cfg(feature = "headless")] +#[cfg(any(windows, feature = "headless"))] use std::io::prelude::*; -#[cfg(feature = "headless")] +#[cfg(any(windows, feature = "headless"))] use std::io::BufReader; #[cfg(all(target_os = "macos", feature = "headless"))] @@ -16,10 +16,10 @@ static LASTRUN_PATH: (&str, &str) = ("HOME", "Library/Application Support/Binary #[cfg(all(target_os = "linux", feature = "headless"))] static LASTRUN_PATH: (&str, &str) = ("HOME", ".binaryninja/lastrun"); -#[cfg(all(windows, feature = "headless"))] +#[cfg(windows)] static LASTRUN_PATH: (&str, &str) = ("APPDATA", "Binary Ninja\\lastrun"); -#[cfg(feature = "headless")] +#[cfg(any(windows, feature = "headless"))] fn link_path() -> PathBuf { let home = PathBuf::from(env::var(LASTRUN_PATH.0).unwrap()); let lastrun = PathBuf::from(&home).join(LASTRUN_PATH.1); @@ -52,7 +52,7 @@ fn main() { // otherwise search the usual install paths let out_dir = env::var("OUT_DIR").unwrap(); - #[cfg(feature = "headless")] + #[cfg(any(windows, feature = "headless"))] let link_path = env::var("BINARYNINJADIR") .map(PathBuf::from) .unwrap_or_else(|_| link_path()); @@ -140,7 +140,7 @@ fn main() { println!("cargo:rustc-link-search={}", out_dir); } - #[cfg(feature = "headless")] + #[cfg(any(windows, feature = "headless"))] { println!("cargo:rustc-link-lib=binaryninjacore"); println!("cargo:rustc-link-search={}", link_path.to_str().unwrap()); -- cgit v1.3.1