Skip to content

Commit

Permalink
convert dependencies and get working build
Browse files Browse the repository at this point in the history
  • Loading branch information
jack60612 committed Jul 10, 2024
1 parent 64964f8 commit bd166bd
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 28 deletions.
12 changes: 7 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions src/sha2.rs
Original file line number Diff line number Diff line change
@@ -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,
}

Expand All @@ -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()
}
Expand Down
1 change: 0 additions & 1 deletion wheel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ clvmr = { path = ".." }
pyo3 = { version = "=0.18.3", features = ["abi3-py38", "extension-module"] }

[features]
openssl = ["clvmr/openssl"]
14 changes: 0 additions & 14 deletions wheel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

0 comments on commit bd166bd

Please sign in to comment.