-
Notifications
You must be signed in to change notification settings - Fork 79
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
feat: support no_std #250
base: main
Are you sure you want to change the base?
feat: support no_std #250
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool,
the hardest part is already done I think, now we just need to deal with some features
Cargo.toml
Outdated
|
||
# serde | ||
serde = { version = "1", optional = true, features = ["derive"] } | ||
serde_json = "1.0" | ||
serde_json = { version = "1.0", optional = true } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can use the alloc
feature
Cargo.toml
Outdated
std = ["anstyle", "colorchoice", "serde_json"] | ||
no_std = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we should also propagate std to everything
src/lib.rs
Outdated
#[cfg(feature = "std")] | ||
pub use colorchoice::ColorChoice; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move below mods again
src/tracing/mux.rs
Outdated
#[cfg(feature = "std")] | ||
#[error("error deserializing config: {0}")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this type works in no-std as long as the serde-json alloc feature is enabled
src/tracing/writer.rs
Outdated
#[cfg(feature = "std")] | ||
use anstyle::{AnsiColor, Color, Style}; | ||
#[cfg(feature = "std")] | ||
use colorchoice::ColorChoice; | ||
use std::{ | ||
collections::HashMap, | ||
io::{self, Write}, | ||
}; | ||
#[cfg(feature = "std")] | ||
use std::io::{self, Write}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we should rather feature gate the code that depends on this I assume
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few more nits
Cargo.toml
Outdated
@@ -33,16 +33,16 @@ clippy.lint_groups_priority = "allow" | |||
alloy-rpc-types-eth = "0.9" | |||
alloy-rpc-types-trace = "0.9" | |||
alloy-sol-types = "0.8" | |||
alloy-primitives = { version = "0.8", features = ["map"] } | |||
alloy-primitives = { version = "0.8", features = ["map-hashbrown"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map should be sufficient here
Cargo.toml
Outdated
@@ -52,5 +52,8 @@ boa_gc = { version = "0.20", optional = true } | |||
snapbox = { version = "0.6", features = ["term-svg"] } | |||
|
|||
[features] | |||
default = ["std"] | |||
std = ["alloy-primitives/std", "anstyle/std", "serde/std", "serde_json/std", "revm/std", "thiserror/std"] | |||
no_std = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't required because this is the same as no-default-features
no_std = [] |
src/lib.rs
Outdated
@@ -4,7 +4,7 @@ | |||
//! | |||
//! - `js-tracer`: Enables a JavaScript tracer implementation. This pulls in extra dependencies | |||
//! (such as `boa`, `tokio` and `serde_json`). | |||
|
|||
#![cfg_attr(not(feature = "std"), no_std)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to L17
src/tracing/js/bindings.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave JS unchanged, it can never support no_std. It may look like it works because tests pass but that's because you're running on a target that has std, and it is used by dependencies regardless of the no_std
status of this crate.
should close #248