Skip to content

Commit

Permalink
Add an optional solver feature
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 committed Jan 7, 2024
1 parent e60748a commit da26c34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/equihash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,18 @@ license = "MIT OR Apache-2.0"
edition = "2021"
rust-version = "1.56.1"

[features]
default = []

## Builds the C++ tromp solver and Rust FFI layer.
solver = ["dep:cc"]

[dependencies]
blake2b_simd = "1"
byteorder = "1"

[build-dependencies]
cc = "1"
cc = { version = "1", optional = true }

[dev-dependencies]
hex = "0.4"
Expand Down
2 changes: 2 additions & 0 deletions components/equihash/build.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
//! Build script for the equihash tromp solver in C.
fn main() {
#[cfg(feature = "solver")]
cc::Build::new()
.include("tromp/")
.file("tromp/equi_miner.c")
.compile("equitromp");

// Tell Cargo to only rerun this build script if the tromp C files or headers change.
#[cfg(feature = "solver")]
println!("cargo:rerun-if-changed=tromp");
}
2 changes: 2 additions & 0 deletions components/equihash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ mod test_vectors;

pub use verify::{is_valid_solution, Error};

#[cfg(feature = "solver")]
mod blake2b;
#[cfg(feature = "solver")]
pub mod tromp;

0 comments on commit da26c34

Please sign in to comment.