From f7ef878981eaebc11229c95204859a7c2a2a16ad Mon Sep 17 00:00:00 2001 From: plebhash Date: Sat, 25 May 2024 18:46:28 -0300 Subject: [PATCH] make no_std into an optional feature --- protocols/v2/binary-sv2/serde-sv2/Cargo.toml | 3 +++ protocols/v2/binary-sv2/serde-sv2/src/lib.rs | 2 +- protocols/v2/codec-sv2/Cargo.toml | 1 + protocols/v2/codec-sv2/src/lib.rs | 2 +- protocols/v2/const-sv2/Cargo.toml | 3 +++ protocols/v2/const-sv2/src/lib.rs | 2 +- protocols/v2/framing-sv2/Cargo.toml | 1 + protocols/v2/framing-sv2/src/lib.rs | 2 +- protocols/v2/subprotocols/common-messages/Cargo.toml | 1 + protocols/v2/subprotocols/common-messages/src/lib.rs | 2 +- protocols/v2/subprotocols/job-declaration/Cargo.toml | 1 + protocols/v2/subprotocols/job-declaration/src/lib.rs | 2 +- protocols/v2/subprotocols/mining/Cargo.toml | 1 + protocols/v2/subprotocols/mining/src/lib.rs | 2 +- protocols/v2/subprotocols/template-distribution/Cargo.toml | 1 + protocols/v2/subprotocols/template-distribution/src/lib.rs | 2 +- 16 files changed, 20 insertions(+), 8 deletions(-) diff --git a/protocols/v2/binary-sv2/serde-sv2/Cargo.toml b/protocols/v2/binary-sv2/serde-sv2/Cargo.toml index 5e01eb2d3..07c52d664 100644 --- a/protocols/v2/binary-sv2/serde-sv2/Cargo.toml +++ b/protocols/v2/binary-sv2/serde-sv2/Cargo.toml @@ -13,3 +13,6 @@ repository = "https://github.com/stratum-mining/stratum" [dependencies] serde = { version = "1.0.89", features = ["derive", "alloc"], default-features = false } buffer_sv2 = {version = "^1.0.0", path = "../../../../utils/buffer"} + +[features] +no_std = [] diff --git a/protocols/v2/binary-sv2/serde-sv2/src/lib.rs b/protocols/v2/binary-sv2/serde-sv2/src/lib.rs index a573bf3bb..004a4dfce 100644 --- a/protocols/v2/binary-sv2/serde-sv2/src/lib.rs +++ b/protocols/v2/binary-sv2/serde-sv2/src/lib.rs @@ -72,7 +72,7 @@ //! [rkyv1]: https://docs.rs/rkyv/0.4.3/rkyv //! [rkyv2]: https://davidkoloski.me/blog/rkyv-is-faster-than/ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] #[macro_use] extern crate alloc; diff --git a/protocols/v2/codec-sv2/Cargo.toml b/protocols/v2/codec-sv2/Cargo.toml index 9e2bddf1f..b3db39783 100644 --- a/protocols/v2/codec-sv2/Cargo.toml +++ b/protocols/v2/codec-sv2/Cargo.toml @@ -21,3 +21,4 @@ tracing = { version = "0.1"} [features] with_serde = ["binary_sv2/with_serde", "serde", "framing_sv2/with_serde", "buffer_sv2/with_serde"] with_buffer_pool = ["framing_sv2/with_buffer_pool"] +no_std = [] \ No newline at end of file diff --git a/protocols/v2/codec-sv2/src/lib.rs b/protocols/v2/codec-sv2/src/lib.rs index 0a2492890..c0594f9c1 100644 --- a/protocols/v2/codec-sv2/src/lib.rs +++ b/protocols/v2/codec-sv2/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] extern crate alloc; diff --git a/protocols/v2/const-sv2/Cargo.toml b/protocols/v2/const-sv2/Cargo.toml index af3067193..8736d91e0 100644 --- a/protocols/v2/const-sv2/Cargo.toml +++ b/protocols/v2/const-sv2/Cargo.toml @@ -14,3 +14,6 @@ secp256k1 = { version = "0.28.2", default-features = false, features =["hashes", #[dev-dependencies] #cbindgen = "0.16.0" + +[features] +no_std = [] diff --git a/protocols/v2/const-sv2/src/lib.rs b/protocols/v2/const-sv2/src/lib.rs index 507f63532..c9cda8277 100644 --- a/protocols/v2/const-sv2/src/lib.rs +++ b/protocols/v2/const-sv2/src/lib.rs @@ -1,5 +1,5 @@ //! Central repository for all the sv2 constants -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] pub const EXTENSION_TYPE_NO_EXTENSION: u16 = 0; diff --git a/protocols/v2/framing-sv2/Cargo.toml b/protocols/v2/framing-sv2/Cargo.toml index 67465688d..04f4c53dd 100644 --- a/protocols/v2/framing-sv2/Cargo.toml +++ b/protocols/v2/framing-sv2/Cargo.toml @@ -17,5 +17,6 @@ binary_sv2 = { version = "^1.0.0", path = "../../../protocols/v2/binary-sv2/bina buffer_sv2 = { version = "^1.0.0", path = "../../../utils/buffer", optional=true } [features] +no_std = [] with_serde = ["binary_sv2/with_serde", "serde", "buffer_sv2/with_serde"] with_buffer_pool = ["binary_sv2/with_buffer_pool", "buffer_sv2"] diff --git a/protocols/v2/framing-sv2/src/lib.rs b/protocols/v2/framing-sv2/src/lib.rs index 33dd11fe2..cf792e65d 100644 --- a/protocols/v2/framing-sv2/src/lib.rs +++ b/protocols/v2/framing-sv2/src/lib.rs @@ -19,7 +19,7 @@ //! //! The `with_serde` feature flag is only used for the Message Generator, and deprecated for any other kind of usage. It will likely be fully deprecated in the future. -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] extern crate alloc; /// SV2 framing types diff --git a/protocols/v2/subprotocols/common-messages/Cargo.toml b/protocols/v2/subprotocols/common-messages/Cargo.toml index 2f803c25e..3bbde6bfc 100644 --- a/protocols/v2/subprotocols/common-messages/Cargo.toml +++ b/protocols/v2/subprotocols/common-messages/Cargo.toml @@ -18,5 +18,6 @@ quickcheck_macros = { version = "1", optional=true } serde_repr = {version= "0.1.10", optional=true} [features] +no_std = [] with_serde = ["binary_sv2/with_serde", "serde", "serde_repr"] prop_test = ["quickcheck"] diff --git a/protocols/v2/subprotocols/common-messages/src/lib.rs b/protocols/v2/subprotocols/common-messages/src/lib.rs index e720306ab..cc0df87a2 100644 --- a/protocols/v2/subprotocols/common-messages/src/lib.rs +++ b/protocols/v2/subprotocols/common-messages/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] //! Common messages for [stratum v2][Sv2] //! The following protocol messages are common across all of the sv2 (sub)protocols. diff --git a/protocols/v2/subprotocols/job-declaration/Cargo.toml b/protocols/v2/subprotocols/job-declaration/Cargo.toml index 9db52a792..f09173fb6 100644 --- a/protocols/v2/subprotocols/job-declaration/Cargo.toml +++ b/protocols/v2/subprotocols/job-declaration/Cargo.toml @@ -14,4 +14,5 @@ binary_sv2 = {version = "^1.0.0", path = "../../../../protocols/v2/binary-sv2/bi const_sv2 = {version = "^1.0.0", path = "../../../../protocols/v2/const-sv2"} [features] +no_std = [] with_serde = ["binary_sv2/with_serde", "serde"] diff --git a/protocols/v2/subprotocols/job-declaration/src/lib.rs b/protocols/v2/subprotocols/job-declaration/src/lib.rs index 2f4bc42cc..fa03ca00a 100644 --- a/protocols/v2/subprotocols/job-declaration/src/lib.rs +++ b/protocols/v2/subprotocols/job-declaration/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] //! # Job Declaration Protocol //! diff --git a/protocols/v2/subprotocols/mining/Cargo.toml b/protocols/v2/subprotocols/mining/Cargo.toml index 493b77d63..4e84417bd 100644 --- a/protocols/v2/subprotocols/mining/Cargo.toml +++ b/protocols/v2/subprotocols/mining/Cargo.toml @@ -20,4 +20,5 @@ quickcheck = "1.0.3" quickcheck_macros = "1" [features] +no_std = [] with_serde = ["binary_sv2/with_serde", "serde"] diff --git a/protocols/v2/subprotocols/mining/src/lib.rs b/protocols/v2/subprotocols/mining/src/lib.rs index bfd0e4114..e82809a79 100644 --- a/protocols/v2/subprotocols/mining/src/lib.rs +++ b/protocols/v2/subprotocols/mining/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] //! # Mining Protocol //! ## Channels diff --git a/protocols/v2/subprotocols/template-distribution/Cargo.toml b/protocols/v2/subprotocols/template-distribution/Cargo.toml index 38cd6f56f..0b8a36a9c 100644 --- a/protocols/v2/subprotocols/template-distribution/Cargo.toml +++ b/protocols/v2/subprotocols/template-distribution/Cargo.toml @@ -17,5 +17,6 @@ quickcheck = { version = "1.0.3", optional=true } quickcheck_macros = { version = "1", optional=true } [features] +no_std = [] with_serde = ["binary_sv2/with_serde", "serde"] prop_test = ["quickcheck"] diff --git a/protocols/v2/subprotocols/template-distribution/src/lib.rs b/protocols/v2/subprotocols/template-distribution/src/lib.rs index 2f1549f2d..11f33afe3 100644 --- a/protocols/v2/subprotocols/template-distribution/src/lib.rs +++ b/protocols/v2/subprotocols/template-distribution/src/lib.rs @@ -1,4 +1,4 @@ -#![no_std] +#![cfg_attr(feature = "no_std", no_std)] //! # Template Distribution Protocol //! The Template Distribution protocol is used to receive updates of the block template to use in