Uh oh!
There was an error while loading. Please reload this page.
Put stdweb dependency behind a target feature - #336
Conversation
| i128_support = [] # enables i128 and u128 support | ||
| serde-1 = ["serde", "serde_derive"] | ||
| wasm-stdweb = ["stdweb"] |
There was a problem hiding this comment.
Shouldn't we just call it stdweb, or rather just use cfg(feature="stdweb") since that is already an optional dependency?
There was a problem hiding this comment.
That would be my choice, but cargo does not support features that have the same name as dependencies. We have the same problem with serde, which has serde-1 as feature flag.
There was a problem hiding this comment.
I didn't know using the name of an optional dependency was possible, much better!
| - cargo --list | egrep "^\s*web$" -q || cargo install cargo-web | ||
| script: | ||
| - cargo web test --target wasm32-unknown-unknown --nodejs | ||
| - cargo web test --target wasm32-unknown-unknown --nodejs --features=wasm-stdweb |
This is also theoretically the wrong fix unfortunately. What the stdlib does when the feature flag is enabled is assume that an FFI function exists, and calls it. In other words, something like: #[cfg(feature = "foo")]extern"C"{fnrand() -> usize;} |
pitdicker
commented
Mar 26, 2018
I don't completely follow what you mean, @tomaka. Can you say a bit more about what is exactly wrong? |
dhardy
commented
Mar 26, 2018
He means that |
quininer
commented
Mar 26, 2018
I don't understand. |
The general problem is assuming that With this PR, if you use a library A that depends on |
pitdicker
commented
Mar 26, 2018
But then are we not ok now? With this PR |
dhardy
commented
Mar 26, 2018
So do we want optional Then I'll answer that: no. We are planning on letting users replace |
Here is the whole background of the discussion if you are motivated for some lecture: rust-lang/rust#47102 |
dhardy
commented
Mar 26, 2018
If and only if library A depends on the The status (after merging this PR) is thus that any attempt to use Rand when targetting |
tomaka
commented
Mar 26, 2018
The problem is that it's not A's job to decide whether to enable the |
pitdicker
commented
Mar 26, 2018
That seems like a good, although theoretical concern. If somewhere in the dependency chain A decides But when things are worked out a bit more around WebAssembly, and we have a solution for #313, I think we can revisit this and move more in the direction you have in mind. But for now this simply solves a practical problem. |
dhardy
commented
Mar 26, 2018
There are two solutions to that:
Oh, I see @pitdicker got here before I did 👍 |
dhardy
commented
Mar 26, 2018
BTW rebase and merge? |
Put stdweb dependency behind a target feature
See #272 (comment), cc @tomaka, @quininer