-
Notifications
You must be signed in to change notification settings - Fork 256
Add dummy feature #71
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
Changes from 4 commits
c7ab9c3
ef9a51d
fe15f9a
c94d48b
9f60f15
e11f251
3ddf409
b7da463
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,7 +36,7 @@ | |
| //! systems are using the recommended interface and respect maximum buffer | ||
| //! sizes. | ||
| //! | ||
| //! ## Support for WebAssembly and ams.js | ||
| //! ## Support for WebAssembly and asm.js | ||
| //! | ||
| //! The three Emscripten targets `asmjs-unknown-emscripten`, | ||
| //! `wasm32-unknown-emscripten` and `wasm32-experimental-emscripten` use | ||
|
|
@@ -46,7 +46,9 @@ | |
| //! methods directly, using either `stdweb` or `wasm-bindgen` depending on what | ||
| //! features are activated for this crate. Note that if both features are | ||
| //! enabled `wasm-bindgen` will be used. If neither feature is enabled, | ||
| //! `getrandom` will always fail. | ||
| //! compiling `getrandom` will result in a compilation error. It can be disabled | ||
|
newpavlov marked this conversation as resolved.
Outdated
|
||
| //! by enabling the `dummy` feature, with which `getrandom` will use an always | ||
|
newpavlov marked this conversation as resolved.
Outdated
|
||
| //! failing implementation. | ||
| //! | ||
| //! The WASI target `wasm32-wasi` uses the `__wasi_random_get` function defined | ||
| //! by the WASI standard. | ||
|
|
@@ -225,18 +227,30 @@ cfg_if! { | |
| target_env = "sgx", | ||
| )))] { | ||
| #[path = "rdrand.rs"] mod imp; | ||
| } else if #[cfg(target_arch = "wasm32")] { | ||
| // ideally we would like to use `target = "wasm32-unknown-unknown"`, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I find something like: ...
} else if #[cfg(all(target_arch = "wasm32", feature = "wasm-bindgen"))] {
#[path = "wasm32_bindgen.rs"] mod imp;
} else if #[cfg(all(target_arch = "wasm32", feature = "stdweb"))] {
#[path = "wasm32_stdweb.rs"] mod imp;
} else if #[cfg(feature = "dummy")] {
#[path = "dummy.rs"] mod imp;
} else {
compile_error!("\
...to be a little more readable. It avoids nested In theory, a new
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure about not needing the |
||
| // but unfortunately it does not work, see: | ||
| // https://github.com/rust-lang/rust/issues/63217 | ||
| } else if #[cfg(all( | ||
| target_arch = "wasm32", | ||
| target_os = "unknown", | ||
| any(feature = "wasm-bindgen", feature = "stdweb"), | ||
| ))] { | ||
| cfg_if! { | ||
| if #[cfg(feature = "wasm-bindgen")] { | ||
| #[path = "wasm32_bindgen.rs"] mod imp; | ||
| } else if #[cfg(feature = "stdweb")] { | ||
| #[path = "wasm32_stdweb.rs"] mod imp; | ||
| } else { | ||
| #[path = "dummy.rs"] mod imp; | ||
| #[path = "wasm32_stdweb.rs"] mod imp; | ||
| } | ||
| } | ||
| } else { | ||
| } else if #[cfg(feature = "dummy")] { | ||
| #[path = "dummy.rs"] mod imp; | ||
| } else { | ||
| compile_error!("\ | ||
| target is not supported, you may enable dummy implementation \ | ||
| using the `dummy` feature or overwrite `getrandom` crate with \ | ||
| a custom one which supports your target using `[replace]` or \ | ||
|
newpavlov marked this conversation as resolved.
Outdated
|
||
| `[patch]` section in your `Cargo.toml`\ | ||
| "); | ||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.