Skip to content

Commit 2441c43

Browse files
authored
Make openssl a feature rather than a platform choice. (#153)
1 parent ab57404 commit 2441c43

File tree

7 files changed

+29
-18
lines changed

7 files changed

+29
-18
lines changed

.github/workflows/benchmark.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch
7474
python -m pip install ./clvm_tools
7575
python -m pip install colorama
76-
maturin develop --release
76+
maturin develop --release --cargo-extra-args="--features=openssl"
7777
7878
- name: Run benchmarks
7979
if: ${{ !startsWith(matrix.os, 'windows') }}
@@ -119,7 +119,7 @@ jobs:
119119
git clone https://github.com/Chia-Network/clvm_tools.git --branch=main --single-branch
120120
python -m pip install ./clvm_tools
121121
python -m pip install colorama
122-
maturin develop --release
122+
maturin develop --release --cargo-extra-args="--features=openssl"
123123
124124
- name: Run cost checks
125125
run: |

.github/workflows/build-arm64-wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \
5353
. ./activate && \
5454
pip install maturin && \
55-
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 \
55+
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 --cargo-extra-args="--features=openssl" \
5656
'
5757
5858
- name: Upload artifacts

.github/workflows/build-m1-wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
. ./venv/bin/activate
4444
export PATH=~/.cargo/bin:$PATH
4545
arch -arm64 pip install maturin
46-
arch -arm64 maturin build --no-sdist -i python --release --strip
46+
arch -arm64 maturin build --no-sdist -i python --release --strip --cargo-extra-args="--features=openssl"
4747
4848
- name: Install clvm_rs wheel
4949
run: |

.github/workflows/build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
python -m venv venv
5151
ln -s venv/bin/activate
5252
. ./activate
53-
maturin build --no-sdist -i python --release --strip
53+
maturin build --no-sdist -i python --release --strip --cargo-extra-args="--features=openssl"
5454
5555
# - name: Build Linux with maturin on Python ${{ matrix.python }}
5656
# if: startsWith(matrix.os, 'ubuntu')
@@ -86,7 +86,7 @@ jobs:
8686
. ./activate && \
8787
pip install --upgrade pip && \
8888
pip install maturin && \
89-
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 \
89+
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 --cargo-extra-args="--features=openssl" \
9090
'
9191
9292
- name: Build Windows with maturin on Python ${{ matrix.python }}

Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ num-bigint = "=0.4.0"
2727
num-traits = "=0.2.14"
2828
num-integer = "=0.1.44"
2929
bls12_381 = "=0.5.0"
30-
3130
sha2 = "=0.9.5"
32-
33-
[target.'cfg(unix)'.dependencies]
34-
openssl = { version = "0.10.35", features = ["vendored"] }
31+
openssl = { version = "0.10.35", features = ["vendored"], optional = true }
3532

3633
[target.'cfg(target_family="wasm")'.dependencies]
3734
wasm-bindgen = "=0.2.75"

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,26 @@ Build `clvm_rs` directly into the current virtualenv with
1515
$ maturin develop --release
1616
```
1717

18+
On UNIX-based platforms, you may get a speed boost on `sha256` operations by building
19+
with OpenSSL.
20+
21+
```
22+
$ maturin develop --release --cargo-extra-args="--features=openssl"
23+
```
24+
25+
1826
To build the wheel, do
1927

2028
```
2129
$ maturin build --release --no-sdist
2230
````
2331
32+
or
33+
34+
```
35+
$ maturin build --release --no-sdist --cargo-extra-args="--features=openssl"
36+
```
37+
2438
2539
WASM
2640
----
@@ -34,7 +48,7 @@ $ cargo install wasm-pack
3448
Then build with
3549
3650
```
37-
$ wasm-pack build --release
51+
$ wasm-pack build --release
3852
```
3953
4054

src/sha2.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#[cfg(not(unix))]
1+
#[cfg(not(openssl))]
22
use sha2::{Digest, Sha256 as Ctx};
33

4-
#[cfg(unix)]
4+
#[cfg(openssl)]
55
use openssl::sha;
66

77
// WINDOWS PART
88

9-
#[cfg(not(unix))]
9+
#[cfg(not(openssl))]
1010
#[derive(Clone)]
1111
pub struct Sha256 {
1212
ctx: Ctx,
1313
}
1414

15-
#[cfg(not(unix))]
15+
#[cfg(not(openssl))]
1616
impl Sha256 {
1717
pub fn new() -> Sha256 {
1818
Sha256 { ctx: Ctx::new() }
@@ -25,15 +25,15 @@ impl Sha256 {
2525
}
2626
}
2727

28-
// UNIX PART
28+
// OPENSSL PART
2929

30-
#[cfg(unix)]
30+
#[cfg(openssl)]
3131
#[derive(Clone)]
3232
pub struct Sha256 {
3333
ctx: sha::Sha256,
3434
}
3535

36-
#[cfg(unix)]
36+
#[cfg(openssl)]
3737
impl Sha256 {
3838
pub fn new() -> Sha256 {
3939
Sha256 {

0 commit comments

Comments
 (0)