Skip to content

Commit

Permalink
use features to control what we link against
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed Dec 19, 2021
1 parent d1f3463 commit 755af93
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-arm64-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
if [ ! -f "activate" ]; then ln -s venv/bin/activate; fi && \
. ./activate && \
pip install maturin && \
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 --cargo-extra-args="--features=openssl" \
CC=gcc maturin build --no-sdist --release --strip --manylinux 2014 --cargo-extra-args="--features=openssl,libgmp10" \
'
- name: Upload artifacts
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
. ./activate && \
pip install --upgrade pip && \
pip install maturin && \
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 --cargo-extra-args="--features=openssl" \
CC=gcc maturin build --no-sdist --release --strip --manylinux 2010 --cargo-extra-args="--features=openssl,libgmp3" \
'
- name: Build Windows with maturin on Python ${{ matrix.python }}
Expand All @@ -99,12 +99,12 @@ jobs:
. .\venv\Scripts\Activate.ps1
ln -s venv\Scripts\Activate.ps1 activate
git clone https://github.com/Chia-Network/mpir_gc_x64.git --depth 1
maturin build --no-sdist -i python --release --strip
maturin build --no-sdist -i python --release --strip --cargo-extra-args="--features=mpir"
# this will install into the venv
# it'd be better to use the wheel, but I can't figure out how to do that
# TODO: figure this out
# this does NOT work: pip install target/wheels/clvm_rs-*.whl
maturin develop --release
maturin develop --release --cargo-extra-args="--features=mpir"
# the line above also doesn't seem to work
- name: Install clvm_rs wheel
Expand Down Expand Up @@ -232,11 +232,11 @@ jobs:
with:
toolchain: nightly
- name: install GMP
run: sudo apt install libgmp3-dev
run: sudo apt install libgmp-dev
- name: cargo-fuzz
run: cargo +nightly install cargo-fuzz
- name: build
run: cargo +nightly fuzz build
run: cargo +nightly fuzz build --cargo-extra-args="--features=openssl"

unit_tests:
runs-on: ubuntu-20.04
Expand All @@ -251,6 +251,6 @@ jobs:
toolchain: stable
components: rustfmt, clippy
- name: install GMP
run: sudo apt install libgmp3-dev
run: sudo apt install libgmp-dev
- name: cargo test
run: cargo test
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ lto = true

[features]
extension-module = ["pyo3/extension-module"]
default = ["extension-module"]
libgmp = []
libgmp3 = []
libgmp10 = []
mpir = []
default = ["extension-module", "libgmp"]

[dependencies]
hex = "=0.4.3"
Expand Down
14 changes: 10 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
use std::env;

fn main() {
#[cfg(target_os = "windows")]
{
if env::var_os("CARGO_FEATURE_MPIR").is_some() {
println!("cargo:rustc-link-lib=mpir");
println!("cargo:rustc-link-search=mpir_gc_x64");
} else if env::var_os("CARGO_FEATURE_LIBGMP3").is_some() {
println!("cargo:rustc-link-lib=libgmp.so.3");
} else if env::var_os("CARGO_FEATURE_LIBGMP10").is_some() {
println!("cargo:rustc-link-lib=libgmp.so.10");
} else if env::var_os("CARGO_FEATURE_LIBGMP").is_some() {
println!("cargo:rustc-link-lib=gmp");
}

#[cfg(target_os = "linux")]
{
println!("cargo:rustc-link-lib=gmp");
println!("cargo:rustc-link-search=/usr/lib64");
println!("cargo:rustc-link-search=/usr/lib");
}
#[cfg(target_os = "macos")]
{
println!("cargo:rustc-link-lib=gmp");
println!("cargo:rustc-link-search=/opt/homebrew/lib");
}
}

0 comments on commit 755af93

Please sign in to comment.