From 622389ff17259e92a00077630cf36786f9604acf Mon Sep 17 00:00:00 2001 From: "Paul H. Liu" Date: Fri, 10 Jan 2025 19:34:56 -0800 Subject: [PATCH] Separate features for wasm32_unknown_unknown_custom, wasm32_unknown_unknown_js, and wasm32_unknown_unknown_custom_or_js. --- Cargo.toml | 4 +++- src/lib.rs | 11 ++++++++--- src/rand.rs | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 494b708a8d..66e96071af 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/lib.rs b/src/lib.rs index 830b0898ce..e38428a4ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -43,12 +43,17 @@ //! std //! Enable features that use libstd, in particular //! std::error::Error integration. Implies `alloc`. -//! wasm32_unknown_unknown_js +//! wasm32_unknown_unknown_custom_or_js //! 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. +//! wasm32_unknown_unknown_js +//! Enable both `wasm32_unknown_unknown_custom_or_js` and the `getrandom` +//! crate's `js` feature. +//! wasm32_unknown_unknown_custom +//! Enable both `wasm32_unknown_unknown_custom_or_js` and the `getrandom` +//! crate's `custom` feature. //! // When running mk/package.sh, don't actually build any code. diff --git a/src/rand.rs b/src/rand.rs index 8a67117bcb..23888aba70 100644 --- a/src/rand.rs +++ b/src/rand.rs @@ -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") ) ), ))]