Skip to content

Commit

Permalink
Try to fix rust workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
imbillow committed May 10, 2024
1 parent 37b123f commit 5c17b8c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ exclude = ["rizin/*"]

[build-dependencies]
bindgen = "0.69.4"
glob = "0.3"
itertools = "0.12.1"

[profile.dev]
rpath = true
Expand Down
32 changes: 18 additions & 14 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
#![feature(iter_collect_into)]

use crate::common::search_libs;
use bindgen::callbacks::{MacroParsingBehavior, ParseCallbacks};
use std::collections::HashSet;
use std::env;
use std::error::Error;
use std::path::PathBuf;

#[path = "build/common.rs"]
pub mod common;

const IGNORE_MACROS: [&str; 20] = [
"FE_DIVBYZERO",
"FE_DOWNWARD",
Expand Down Expand Up @@ -63,22 +69,15 @@ fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rustc-link-lib=dylib={}", lib);
}

let rizin_dir = PathBuf::from(env::var("HOME")?).join(".local");
let lib_dir = rizin_dir.join("lib64");
if lib_dir.exists() {
println!("cargo:rustc-link-search={}", lib_dir.to_str().unwrap());
}
let lib_dir = rizin_dir.join("lib");
if lib_dir.exists() {
println!("cargo:rustc-link-search={}", lib_dir.to_str().unwrap());
}

let (lib_dir, _, _) = search_libs(RZ_LIBRARIES, "RIZIN_DIR")?;
println!("cargo:rustc-link-search={}", lib_dir.to_str().unwrap());
println!("cargo:rerun-if-changed=wrapper.h");

let inc_dir = rizin_dir.join("include");
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.clang_args([
let builder = bindgen::Builder::default().header("wrapper.h");
let builder = if let Ok(dir) = env::var("RIZIN_DIR").or(env::var("HOME")) {
let rizin_dir = PathBuf::from(dir).join(".local");
let inc_dir = rizin_dir.join("include");
builder.clang_args([
"-I",
inc_dir.to_str().unwrap(),
"-I",
Expand All @@ -88,6 +87,11 @@ fn main() -> Result<(), Box<dyn Error>> {
"-I",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/",
])
} else {
builder
};

let bindings = builder
.derive_default(true)
.generate_inline_functions(true)
.blocklist_type("u128")
Expand Down
2 changes: 1 addition & 1 deletion il-tests/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::cmp::min;
use std::error::Error;
use std::fmt;
use std::fmt::{Display, Formatter};
use std::sync::{Arc, Mutex};
use std::sync::Arc;

use dashmap::DashMap;
use hex::ToHex;
Expand Down
2 changes: 1 addition & 1 deletion src/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,8 @@ impl<T> DerefMut for PVector<T> {

#[cfg(test)]
mod test {
use std::mem::size_of;
use crate::wrapper::*;
use std::mem::size_of;

#[test]
fn test_core() {
Expand Down

0 comments on commit 5c17b8c

Please sign in to comment.