Skip to content

Commit

Permalink
Link against core
Browse files Browse the repository at this point in the history
# Conflicts:
#	rust/build.rs
  • Loading branch information
emesare committed Jul 26, 2024
1 parent 3dbf625 commit 85a26f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions rust/binaryninjacore-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name = "binaryninjacore-sys"
version = "0.1.0"
authors = ["Ryan Snyder <[email protected]>", "Kyle Martin <[email protected]>"]
build = "build.rs"
edition = "2021"
links = "binaryninjacore"

[build-dependencies]
bindgen = "^0.69.2"
3 changes: 1 addition & 2 deletions rust/binaryninjacore-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ fn main() {
println!("cargo:rustc-link-search={}", out_dir);
}

println!("cargo:rustc-link-lib=binaryninjacore");
println!("cargo:rustc-link-search={}", link_path.to_str().unwrap());
println!("cargo:path={}", link_path.to_str().unwrap());

let current_line = "#define BN_CURRENT_UI_ABI_VERSION ";
let minimum_line = "#define BN_MINIMUM_UI_ABI_VERSION ";
Expand Down
25 changes: 25 additions & 0 deletions rust/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::env;

fn main() {
// TODO : Enable the following when https://github.com/rust-lang/rust/issues/43781 stabilizes
// #[cfg(doc)]
Expand All @@ -9,4 +11,27 @@ fn main() {
"target/doc/under_construction.png",
);
let _ = std::fs::copy("../docs/img/logo.png", "target/doc/logo.png");

let Some(link_path) = env::var_os("DEP_BINARYNINJACORE_PATH") else {
// TODO: This needs to be moved into the sys crate?
panic!("no DEP_BINARYNINJA_PATH specified!");
};

println!("cargo::rustc-link-lib=dylib=binaryninjacore");

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

#[cfg(target_os = "windows")]
{
println!(
"cargo::rustc-link-search={}",
link_path.to_string_lossy()
);
}
}

0 comments on commit 85a26f2

Please sign in to comment.