From bd166bd9fb72e9a1b06074d596b074cf7ee8d83a Mon Sep 17 00:00:00 2001 From: Jack Nelson Date: Tue, 9 Jul 2024 23:35:53 -0400 Subject: [PATCH] convert dependencies and get working build --- Cargo.toml | 12 +++++++----- src/sha2.rs | 16 ++++++++-------- wheel/Cargo.toml | 1 - wheel/README.md | 14 -------------- 4 files changed, 15 insertions(+), 28 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a906b8b4..1f1e2f5c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,9 +26,6 @@ counters = [] # debugging and tracing of programs. pre-eval = [] -# On UNIX-based platforms, you may get a speed boost on `sha256` operations by building -# with OpenSSL.when enabled -openssl = ["dep:openssl"] [profile.release] lto = "thin" @@ -39,13 +36,18 @@ num-bigint = "0.4.3" num-traits = "0.2.15" num-integer = "0.1.45" chia-bls = "0.4.0" -sha2 = "0.10.8" -openssl = { version = "=0.10.55", features = ["vendored"], optional = true } hex-literal = "=0.4.1" # for secp sigs k256 = { version = "0.13.1", features = ["ecdsa"] } p256 = { version = "0.13.2", features = ["ecdsa"] } + +[target.'cfg(windows)'.dependencies] +sha2 = "0.10.8" + +[target.'cfg(unix)'.dependencies] +openssl = { version = "=0.10.55", features = ["vendored"] } + [dev-dependencies] rstest = "0.17.0" criterion = "0.5.1" diff --git a/src/sha2.rs b/src/sha2.rs index 15738958..06bb9823 100644 --- a/src/sha2.rs +++ b/src/sha2.rs @@ -1,15 +1,15 @@ -#[cfg(feature = "openssl")] -use openssl; - -#[cfg(not(feature = "openssl"))] +#[cfg(target_family = "windows")] use sha2::Digest; +#[cfg(target_family = "unix")] +use openssl; + #[derive(Default, Clone)] pub struct Sha256 { - #[cfg(feature = "openssl")] + #[cfg(target_family = "unix")] ctx: openssl::sha::Sha256, - #[cfg(not(feature = "openssl"))] + #[cfg(target_family = "windows")] ctx: sha2::Sha256, } @@ -21,11 +21,11 @@ impl Sha256 { self.ctx.update(buf.as_ref()); } pub fn finalize(self) -> [u8; 32] { - #[cfg(feature = "openssl")] + #[cfg(target_family = "unix")] { self.ctx.finish() } - #[cfg(not(feature = "openssl"))] + #[cfg(target_family = "windows")] { self.ctx.finalize().into() } diff --git a/wheel/Cargo.toml b/wheel/Cargo.toml index bfbdb996..d67017b5 100644 --- a/wheel/Cargo.toml +++ b/wheel/Cargo.toml @@ -19,4 +19,3 @@ clvmr = { path = ".." } pyo3 = { version = "=0.18.3", features = ["abi3-py38", "extension-module"] } [features] -openssl = ["clvmr/openssl"] diff --git a/wheel/README.md b/wheel/README.md index 271aa4fd..cc304861 100644 --- a/wheel/README.md +++ b/wheel/README.md @@ -15,22 +15,8 @@ While in the `wheel` directory, build `clvm_rs` into the current virtualenv with $ maturin develop --release ``` -On UNIX-based platforms, you may get a speed boost on `sha256` operations by building -with OpenSSL. - -``` -$ maturin develop --release --features=openssl -``` - - To build the wheel, do ``` $ maturin build --release ```` - -or - -``` -$ maturin build --release --features=openssl -```