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

Add getrandom crate feature=js for KeyExpr #1720

Merged
merged 4 commits into from
Jan 15, 2025
Merged
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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ form_urlencoded = "1.2.1"
futures = "0.3.30"
futures-util = { version = "0.3.30", default-features = false } # Default features are disabled due to some crates' requirements
git-version = "0.3.9"
getrandom = { version = "0.2" }
Copy link
Member

@Mallets Mallets Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getrandom is added as dependency but no change in this PR seems to use it.
What's the role of this dependency alone, which makes fail the CI?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rand uses getrandom under the hood, and get random has the library feature that we need to enable to get the keyexpr package to compile to wasm successfully.
Ive added an ignore for cargo machete which should fix the CI check

hashbrown = "0.14"
hex = { version = "0.4.3", default-features = false } # Default features are disabled due to usage in no_std crates
hmac = { version = "0.12.1", features = ["std"] }
Expand Down
8 changes: 8 additions & 0 deletions commons/zenoh-keyexpr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ default = ["std"]
std = ["zenoh-result/std", "dep:schemars"]
internal = []
unstable = []
js = ["getrandom/js"]

[dependencies]
keyed-set = { workspace = true }
Expand All @@ -36,6 +37,9 @@ schemars = { workspace = true, optional = true }
serde = { workspace = true, features = ["alloc"] }
token-cell = { workspace = true }
zenoh-result = { workspace = true }
# NOTE: getrandom needs to be explicitly added here in order to enable the `js` feature when compiling the rand crate to WASM
# more information: https://docs.rs/getrandom/latest/getrandom/#webassembly-support
getrandom = { workspace = true }

[target.'cfg(not(features = "std"))'.dependencies]
hashbrown = { workspace = true }
Expand All @@ -50,3 +54,7 @@ rand = { workspace = true, features = ["default"] }
[[bench]]
name = "keyexpr_tree"
harness = false

# NOTE: for the above reason, we need to explicitly ignore getrandom in the CI because it's an indirect dependency which is not used directly by zenoh.
[package.metadata.cargo-machete]
Mallets marked this conversation as resolved.
Show resolved Hide resolved
ignored = ["getrandom"]
Loading