Skip to content

Commit

Permalink
Separate features for wasm32_unknown_unknown_custom, wasm32_unknown_u…
Browse files Browse the repository at this point in the history
…nknown_js, and wasm32_unknown_unknown_custom_or_js.
  • Loading branch information
ninegua committed Jan 11, 2025
1 parent d2e401f commit 622389f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ std = ["alloc"]
unstable-testing-arm-no-hw = []
unstable-testing-arm-no-neon = []
test_logging = []
wasm32_unknown_unknown_js = ["getrandom/js"]
wasm32_unknown_unknown_custom_or_js = []
wasm32_unknown_unknown_custom = ["wasm32_unknown_unknown_custom_or_js", "getrandom/custom"]
wasm32_unknown_unknown_js = ["wasm32_unknown_unknown_custom_or_js", "getrandom/js"]

# XXX: debug = false because of https://github.com/rust-lang/rust/issues/34122

Expand Down
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,17 @@
//! <tr><td><code>std</code>
//! <td>Enable features that use libstd, in particular
//! <code>std::error::Error</code> integration. Implies `alloc`.
//! <tr><td><code>wasm32_unknown_unknown_js</code>
//! <tr><td><code>wasm32_unknown_unknown_custom_or_js</code>
//! <td>When this feature is enabled, for the wasm32-unknown-unknown target,
//! Web APIs will be used to implement features like `ring::rand` that
//! require an operating environment of some kind. This has no effect
//! for any other target. This enables the `getrandom` crate's `js`
//! feature.
//! for any other target.
//! <tr><td><code>wasm32_unknown_unknown_js</code>
//! <td>Enable both `wasm32_unknown_unknown_custom_or_js` and the `getrandom`
//! crate's `js` feature.
//! <tr><td><code>wasm32_unknown_unknown_custom</code>
//! <td>Enable both `wasm32_unknown_unknown_custom_or_js` and the `getrandom`
//! crate's `custom` feature.
//! </table>
// When running mk/package.sh, don't actually build any code.
Expand Down
2 changes: 1 addition & 1 deletion src/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl crate::sealed::Sealed for SystemRandom {}
target_arch = "wasm32",
any(
target_os = "wasi",
all(target_os = "unknown", feature = "wasm32_unknown_unknown_js")
all(target_os = "unknown", feature = "wasm32_unknown_unknown_custom_or_js")
)
),
))]
Expand Down

0 comments on commit 622389f

Please sign in to comment.