Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Build and link unicorn from source. (#16)
Browse files Browse the repository at this point in the history
Patch submitted by m4b.
  • Loading branch information
ekse committed Jan 21, 2017
1 parent 3200d4e commit 1bdbb75
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "unicorn"]
path = unicorn
url = https://github.com/unicorn-engine/unicorn
branch = master
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ documentation = "http://ekse.github.io/unicorn/"
license = "GPL-2.0"
readme = "README.md"
include = ["src/*", "tests/*", "Cargo.toml", "COPYING", "README.md"]
build = "build.rs"
links = "unicorn"

[build-dependencies]
gcc = "0.3"

[dependencies]
bitflags = "0.6"
Expand Down
18 changes: 18 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extern crate gcc;

use std::path::{Path};
use std::process::Command;
use std::env;

fn main() {
if !Path::new("unicorn/.git").exists() {
let _ = Command::new("git").args(&["submodule", "update", "--init", "--depth", "5"])
.status();
}
let out_dir = env::var("OUT_DIR").unwrap();
let _ = Command::new("./make.sh").current_dir("unicorn").status();
let capstone = "libunicorn.a";
let _ = Command::new("cp").current_dir("unicorn").arg(&capstone).arg(&out_dir).status();
println!("cargo:rustc-link-search=native={}", out_dir);
println!("cargo:rustc-link-lib=static=unicorn");
}
1 change: 0 additions & 1 deletion src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::os::raw::c_char;
use unicorn_const::{Arch, MemRegion, Mode, Error, HookType, Query};
use {uc_handle, uc_hook};

#[link(name = "unicorn")]
extern "C" {
pub fn uc_version(major: *const u32, minor: *const u32) -> u32;
pub fn uc_arch_supported(arch: Arch) -> bool;
Expand Down
1 change: 1 addition & 0 deletions unicorn
Submodule unicorn added at 5a1e86

0 comments on commit 1bdbb75

Please sign in to comment.