Skip to content

Commit 755af93

Browse files
committed
use features to control what we link against
1 parent d1f3463 commit 755af93

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \
5555
. ./activate && \
5656
pip install maturin && \
57-
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 --cargo-extra-args="--features=openssl" \
57+
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 --cargo-extra-args="--features=openssl,libgmp10" \
5858
'
5959
6060
- name: Upload artifacts

.github/workflows/build-test.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
. ./activate && \
9090
pip install --upgrade pip && \
9191
pip install maturin && \
92-
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 --cargo-extra-args="--features=openssl" \
92+
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 --cargo-extra-args="--features=openssl,libgmp3" \
9393
'
9494
9595
- name: Build Windows with maturin on Python ${{ matrix.python }}
@@ -99,12 +99,12 @@ jobs:
9999
. .\venv\Scripts\Activate.ps1
100100
ln -s venv\Scripts\Activate.ps1 activate
101101
git clone https://github.com/Chia-Network/mpir_gc_x64.git --depth 1
102-
maturin build --no-sdist -i python --release --strip
102+
maturin build --no-sdist -i python --release --strip --cargo-extra-args="--features=mpir"
103103
# this will install into the venv
104104
# it'd be better to use the wheel, but I can't figure out how to do that
105105
# TODO: figure this out
106106
# this does NOT work: pip install target/wheels/clvm_rs-*.whl
107-
maturin develop --release
107+
maturin develop --release --cargo-extra-args="--features=mpir"
108108
# the line above also doesn't seem to work
109109
110110
- name: Install clvm_rs wheel
@@ -232,11 +232,11 @@ jobs:
232232
with:
233233
toolchain: nightly
234234
- name: install GMP
235-
run: sudo apt install libgmp3-dev
235+
run: sudo apt install libgmp-dev
236236
- name: cargo-fuzz
237237
run: cargo +nightly install cargo-fuzz
238238
- name: build
239-
run: cargo +nightly fuzz build
239+
run: cargo +nightly fuzz build --cargo-extra-args="--features=openssl"
240240

241241
unit_tests:
242242
runs-on: ubuntu-20.04
@@ -251,6 +251,6 @@ jobs:
251251
toolchain: stable
252252
components: rustfmt, clippy
253253
- name: install GMP
254-
run: sudo apt install libgmp3-dev
254+
run: sudo apt install libgmp-dev
255255
- name: cargo test
256256
run: cargo test

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@ lto = true
1818

1919
[features]
2020
extension-module = ["pyo3/extension-module"]
21-
default = ["extension-module"]
21+
libgmp = []
22+
libgmp3 = []
23+
libgmp10 = []
24+
mpir = []
25+
default = ["extension-module", "libgmp"]
2226

2327
[dependencies]
2428
hex = "=0.4.3"

build.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1+
use std::env;
2+
13
fn main() {
2-
#[cfg(target_os = "windows")]
3-
{
4+
if env::var_os("CARGO_FEATURE_MPIR").is_some() {
45
println!("cargo:rustc-link-lib=mpir");
56
println!("cargo:rustc-link-search=mpir_gc_x64");
7+
} else if env::var_os("CARGO_FEATURE_LIBGMP3").is_some() {
8+
println!("cargo:rustc-link-lib=libgmp.so.3");
9+
} else if env::var_os("CARGO_FEATURE_LIBGMP10").is_some() {
10+
println!("cargo:rustc-link-lib=libgmp.so.10");
11+
} else if env::var_os("CARGO_FEATURE_LIBGMP").is_some() {
12+
println!("cargo:rustc-link-lib=gmp");
613
}
14+
715
#[cfg(target_os = "linux")]
816
{
9-
println!("cargo:rustc-link-lib=gmp");
1017
println!("cargo:rustc-link-search=/usr/lib64");
1118
println!("cargo:rustc-link-search=/usr/lib");
1219
}
1320
#[cfg(target_os = "macos")]
1421
{
15-
println!("cargo:rustc-link-lib=gmp");
1622
println!("cargo:rustc-link-search=/opt/homebrew/lib");
1723
}
1824
}

0 commit comments

Comments
 (0)