Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the -sys crate optional #703

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[features]
default = ["std"]
std = ["alloc", "secp256k1-sys/std"]
default = ["sys-std"]
std = ["alloc"]
alloc = []
sys-std = ["std", "sys-alloc", "secp256k1-sys/std"]
# allow use of Secp256k1::new and related API that requires an allocator
alloc = ["secp256k1-sys/alloc"]
sys-alloc = ["secp256k1-sys/alloc"]
hashes-std = ["std", "hashes/std"]
rand-std = ["std", "rand", "rand/std", "rand/std_rng"]
recovery = ["secp256k1-sys/recovery"]
Expand All @@ -36,7 +38,7 @@ global-context = ["std"]
global-context-less-secure = ["global-context"]

[dependencies]
secp256k1-sys = { version = "0.10.0", default-features = false, path = "./secp256k1-sys" }
secp256k1-sys = { version = "0.10.0", default-features = false, path = "./secp256k1-sys", optional = true }
serde = { version = "1.0.103", default-features = false, optional = true }

# You likely only want to enable these if you explicitly do not want to use "std", otherwise enable
Expand All @@ -59,15 +61,15 @@ unexpected_cfgs = { level = "deny", check-cfg = ['cfg(bench)', 'cfg(secp256k1_fu

[[example]]
name = "sign_verify_recovery"
required-features = ["recovery", "hashes-std"]
required-features = ["recovery", "hashes-std", "secp256k1-sys"]

[[example]]
name = "sign_verify"
required-features = ["hashes-std"]
required-features = ["hashes-std", "secp256k1-sys"]

[[example]]
name = "generate_keys"
required-features = ["rand-std"]
required-features = ["rand-std", "secp256k1-sys"]

[workspace]
members = ["secp256k1-sys"]
Expand Down
14 changes: 7 additions & 7 deletions contrib/_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -ex

REPO_DIR=$(git rev-parse --show-toplevel)
FEATURES="hashes global-context lowmemory rand recovery serde std alloc hashes-std rand-std"
FEATURES="hashes global-context lowmemory rand recovery serde std alloc hashes-std rand-std secp256k1-sys"

cargo --version
rustc --version
Expand Down Expand Up @@ -62,17 +62,17 @@ if [ "$DO_FEATURE_MATRIX" = true ]; then
fi

# Examples
cargo run --locked --example sign_verify --features=hashes-std
cargo run --locked --example sign_verify_recovery --features=recovery,hashes-std
cargo run --locked --example generate_keys --features=rand-std
cargo run --locked --example sign_verify --features=hashes-std,secp256k1-sys
cargo run --locked --example sign_verify_recovery --features=recovery,hashes-std,secp256k1-sys
cargo run --locked --example generate_keys --features=rand-std,secp256k1-sys
fi

if [ "$DO_LINT" = true ]
then
cargo clippy --locked --all-features --all-targets -- -D warnings
cargo clippy --locked --example sign_verify --features=hashes-std -- -D warnings
cargo clippy --locked --example sign_verify_recovery --features=recovery,hashes-std -- -D warnings
cargo clippy --locked --example generate_keys --features=rand-std -- -D warnings
cargo clippy --locked --example sign_verify --features=hashes-std,secp256k1-sys -- -D warnings
cargo clippy --locked --example sign_verify_recovery --features=recovery,hashes-std,secp256k1-sys -- -D warnings
cargo clippy --locked --example generate_keys --features=rand-std,secp256k1-sys -- -D warnings
fi

# Build the docs if told to (this only works with the nightly toolchain)
Expand Down
Loading
Loading