developmentseed / cql2-rs

Rust library for parsing the OGC CQL2 filter language
http://developmentseed.org/cql2-rs/
MIT License
5 stars 0 forks source link

Expose to WASM #11

Open bitner opened 2 months ago

gadomski commented 2 weeks ago

I think this is currently blocked by https://github.com/santhosh-tekuri/boon/pull/23 — I'm not "smart" on WASM, but when I checked wasm32-unknown-emscripten in cql2, I got:

$ cargo check --target wasm32-unknown-emscripten
--- >8 ---
    Checking boon v0.6.0
error[E0432]: unresolved import `loader::FileLoader`
   --> /Users/gadomski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/boon-0.6.0/src/lib.rs:121:14
    |
121 |     loader::{FileLoader, SchemeUrlLoader, UrlLoader},
    |              ^^^^^^^^^^
    |              |
    |              no `FileLoader` in `loader`
    |              help: a similar name exists in the module: `UrlLoader`
    |
note: found an item that was configured out
   --> /Users/gadomski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/boon-0.6.0/src/loader.rs:31:12
    |
31  | pub struct FileLoader;
    |            ^^^^^^^^^^
note: the item is gated here
   --> /Users/gadomski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/boon-0.6.0/src/loader.rs:30:1
    |
30  | #[cfg(not(target_arch = "wasm32"))]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0432`.
error: could not compile `boon` (lib) due to 1 previous error
kylebarron commented 2 weeks ago

You should compile to wasm32-unknown-unknown. That's the primary supported browser webassembly target for Rust

gadomski commented 2 weeks ago

You should compile to wasm32-unknown-unknown.

Yup good point, I'll be sure to target that when we can build out. I tried that first and ended up with a transitive dependency yelling at me, so that will take unpicking once boon is fixed:

error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/gadomski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.15/src/lib.rs:342:9
    |
342 | /         compile_error!("the wasm*-unknown-unknown targets are not supported by \
343 | |                         default, you may need to enable the \"js\" feature. \
344 | |                         For more information see: \
345 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

Imma remove this from the v0.2 milestone b/c we don't know how responsive the boon folks will be.

kylebarron commented 2 weeks ago

Well, fwiw that's a one-line change to fix that error https://github.com/kylebarron/parquet-wasm/blob/7ea19b91b9d026da19cb9aacc60c0befd6ce355b/Cargo.toml#L61