From 20c0a4b64377dd49949ad570453dfeebafcb38ac Mon Sep 17 00:00:00 2001 From: lazymio Date: Fri, 6 May 2022 14:46:50 +0200 Subject: [PATCH] Remove use_system_unicorn and build_with_cmake --- Cargo.toml | 10 ++++------ bindings/rust/build.rs | 30 ++++++++++-------------------- 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a7089d15..1d5cb17c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,12 +34,10 @@ bitflags = "1.3" libc = "0.2" [build-dependencies] -cc = { optional = true, version = "1.0" } -cmake = { optional = true, version = "0.1" } -pkg-config = { optional = true, version = "0.3" } +cc = { version = "1.0" } +cmake = { version = "0.1" } +pkg-config = { version = "0.3" } [features] -default = ["build_unicorn_cmake"] -build_unicorn_cmake = ["cc", "cmake"] -use_system_unicorn = ["pkg-config"] +default = [] dynamic_linkage = [] \ No newline at end of file diff --git a/bindings/rust/build.rs b/bindings/rust/build.rs index 9c917bef..1f5e2251 100644 --- a/bindings/rust/build.rs +++ b/bindings/rust/build.rs @@ -1,23 +1,16 @@ -#[cfg(feature = "use_system_unicorn")] use pkg_config; -#[cfg(feature = "build_unicorn_cmake")] use std::env; -#[cfg(feature = "build_unicorn_cmake")] use std::path::PathBuf; -#[cfg(feature = "build_unicorn_cmake")] use std::process::Command; -#[cfg(all(feature = "build_unicorn_cmake"))] fn ninja_available() -> bool { Command::new("ninja").arg("--version").spawn().is_ok() } -#[cfg(all(feature = "build_unicorn_cmake"))] fn msvc_cmake_tools_available() -> bool { Command::new("cmake").arg("--version").spawn().is_ok() && ninja_available() } -#[cfg(all(feature = "build_unicorn_cmake"))] fn setup_env_msvc(compiler: &cc::Tool) { // If PATH already contains what we need, skip this if msvc_cmake_tools_available() { @@ -67,7 +60,6 @@ fn setup_env_msvc(compiler: &cc::Tool) { } } -#[cfg(feature = "build_unicorn_cmake")] fn build_with_cmake() { let uc_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); let compiler = cc::Build::new().get_compiler(); @@ -119,14 +111,12 @@ fn build_with_cmake() { } fn main() { - if cfg!(feature = "use_system_unicorn") { - #[cfg(feature = "use_system_unicorn")] - { - let lib = pkg_config::Config::new() - .atleast_version("2") - .cargo_metadata(false) - .probe("unicorn") - .expect("Fail to find globally installed unicorn"); + match pkg_config::Config::new() + .atleast_version("2") + .cargo_metadata(false) + .probe("unicorn") + { + Ok(lib) => { for dir in lib.link_paths { println!("cargo:rustc-link-search=native={}", dir.to_str().unwrap()); } @@ -139,8 +129,8 @@ fn main() { println!("cargo:rustc-link-lib=m"); } } - } else { - #[cfg(feature = "build_unicorn_cmake")] - build_with_cmake(); - } + Err(_) => { + build_with_cmake(); + } + }; }