Skip to content

Commit

Permalink
Add getrandom crate feature=js for KeyExpr (#1720)
Browse files Browse the repository at this point in the history
* Add getrandom crate feature=js for KeyExpr

* Add js feature flag to keyexpr and cargo machete ignore to metadata

* Add comment explaining getrandom

* Update commons/zenoh-keyexpr/Cargo.toml

---------

Co-authored-by: Luca Cominardi <[email protected]>
  • Loading branch information
Charles-Schleich and Mallets authored Jan 15, 2025
1 parent 16d5a00 commit 26d67de
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
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 @@ -103,6 +103,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" }
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]
ignored = ["getrandom"]

0 comments on commit 26d67de

Please sign in to comment.