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
Feature/wasm #351
Feature/wasm #351
Conversation
Thanks. But I don't think it is a good idea to depend on docs for messages that it is supported only on certain targets with a feature gate. I'm looking for a better way of doing this. |
Agreed, I don't like it too. Maybe hide #[cfg(any(
not(target_arch = "wasm32"),
all(
target_arch = "wasm32",
any(feature = "stdweb", feature = "wasm-bindgen")
)
))]
pub fn new_v4() -> Self { ... } ... , remove |
Did update this PR and gated all v3, v4, v5 modules behind features. If you target
|
Signed-off-by: Robert Vojta <rvojta@me.com>
Signed-off-by: Robert Vojta <rvojta@me.com>
Signed-off-by: Robert Vojta <rvojta@me.com>
Signed-off-by: Robert Vojta <rvojta@me.com>
Currently this doesn't test the crate on wasm-* but just the features. We need to add another build to the CI so that it will run all the tests (or just the feature-gated ones) on wasm. |
@Dylan-DPC can you elaborate on tests pls? There're two options: a) make a crate buildable for If a) is the right answer then I don't understand what do you mean with tests. Because you can't do things like Also I don't think b) needs to be added. |
Signed-off-by: Robert Vojta <rvojta@me.com>
|
Signed-off-by: Robert Vojta <rvojta@me.com>
Did add builds for the |
Thanks for the PR @zrzka. Personally I'm not a fan of adding transitive Right now, I think depending on If we're going to support random uuids in wasm then I think we should do it without needing any special feature gates. |
This will test only the features, it won't test whether uuid works on the wasm architectures or not, which could lead to false truths. |
@KodrAus not sure if you can do it without feature gates now, because there's Anyway, I'm fine with adding I'm going to close this PR, trash branch. Decide if you'd like to keep #350 open and if not, feel free to close it. |
@KodrAus I don't think you can do it without the feature gates, and since the rand features are different depending on whether they want stdweb or bindgen. I don't see another way of doing this at this point. |
@Dylan-DPC is right :) Anyway, I have fixed my issue with this commit, works for me. Ugly as well, but at least it works. |
@zrzka So it looks like this is actually the way we're recommending doing this right now, so if you'd like to re-open this PR as-is then I'm on board with the approach. Sorry about the misdirection here :) I can live with a solution that has drawbacks if it's consistent with what other libraries are doing. |
@KodrAus np, next week. |
Signed-off-by: Robert Vojta <rvojta@me.com>
Restored & reopened as requested. Summary:
|
This fails on stable & beta with an issue on stdweb:
|
Signed-off-by: Robert Vojta <rvojta@me.com>
Yep, |
Yeah they fixed the issue in this commit (koute/stdweb@f1fc5e3) and it will work on stable once it is released. |
bors: r+ |
351: Feature/wasm r=Dylan-DPC a=zrzka # Description This PR adds two new features: * `stdweb` * `wasm-bindgen` These features are kind of _passthrough_ features, because they do nothing in the `uuid` crate itself. They're just passed to the `rand` crate to make the `uuid` crate working for the `wasm32-unknown-unknown` target. # Motivation I'm unable to generate random UUID (v4) when this crate is compiled for the `wasm32-unknown-unknown` target. # Tests I just added these features ... ``` - cargo test --features "v3" - cargo test --features "v3 stdweb" - cargo test --features "v3 wasm-bindgen" ``` ... for all `v3` & `v4` & `v5` (`rand` crate is used in all these features) to the `script` section in the `.travis.yml`. Not sure if it makes sense, but it can demonstrate that it's buildable at least. I don't think that more tests are required unless you'd like to bring the whole `wasm-bindgen`, `wasm-pack`, ... machinery here. And it has no sense to do it, because goal of this PR is not to publish `uuid-rs` NPM package, just add the ability to compile & use it from the `wasm32-unknown-unknown` target. # Related Issue(s) * #350 * [now() doesn't work](balena-io-modules/balena-temen#37) # Manual tests My Cargo.toml: ``` [dependencies] uuid = { features = ["v4"], git = "https://github.com/zrzka/uuid.git", branch = "feature/wasm" } [target.wasm32-unknown-unknown.dependencies] uuid = { features = ["wasm-bindgen"], git = "https://github.com/zrzka/uuid.git", branch = "feature/wasm" } ``` My `index.js`: ``` const bt = require('balena-temen'); console.log( bt.evaluate({ "id": { "$$eval": "uuidv4()" } }) ); ``` [uuidv4() implementation](https://github.com/balena-io-modules/balena-temen/blob/master/src/builtin/function/uuidv4.rs#L9-L11). Output: ``` { id: 'cefa2919-ff48-48ef-a231-e13697e23ed2' } ``` Co-authored-by: Robert Vojta <rvojta@me.com>
Description
This PR adds two new features:
stdweb
wasm-bindgen
These features are kind of passthrough features, because they do nothing in the
uuid
crate itself. They're just passed to therand
crate to make theuuid
crate working for thewasm32-unknown-unknown
target.Motivation
I'm unable to generate random UUID (v4) when this crate is compiled for the
wasm32-unknown-unknown
target.Tests
I just added these features ...
... for all
v3
&v4
&v5
(rand
crate is used in all these features) to thescript
section in the.travis.yml
.Not sure if it makes sense, but it can demonstrate that it's buildable at least.
I don't think that more tests are required unless you'd like to bring the whole
wasm-bindgen
,wasm-pack
, ... machinery here. And it has no sense to do it, because goal of this PR is not to publishuuid-rs
NPM package, just add the ability to compile & use it from thewasm32-unknown-unknown
target.Related Issue(s)
Manual tests
My Cargo.toml:
My
index.js
:uuidv4() implementation.
Output: