Stream: wit-bindgen

Topic: (rust-guest) Exporting component when passing dir to path


view this post on Zulip r-muhairi (Jan 22 2023 at 18:41):

Hi, passing a directory path to the generate! macro of the guest-rust crate seems to not generate a export macro for the world, rendering the re-implemented use keyword unusable.

is this intentional? and if so how do I export the world?

view this post on Zulip Ramon Klass (Jan 22 2023 at 18:49):

https://github.com/bytecodealliance/wit-bindgen/blob/main/crates/wit-bindgen-demo/src/lib.rs#L9

the current version expects the wit file to be in ./wits/{name}.wit and you specify the name without an ending

A language binding generator for WebAssembly interface types - wit-bindgen/lib.rs at main · bytecodealliance/wit-bindgen

view this post on Zulip r-muhairi (Jan 22 2023 at 18:52):

Yes, but if the wits directory contains a deps directory it does generate however without the export_${world} macro.

view this post on Zulip r-muhairi (Jan 22 2023 at 19:04):

And if there were multiple files (using with pkg) no export_${world} macro is generated

Consider this test
https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-parser/tests/ui/multi-file

Low level tooling for WebAssembly in Rust. Contribute to bytecodealliance/wasm-tools development by creating an account on GitHub.

view this post on Zulip r-muhairi (Jan 22 2023 at 19:09):

For the deps-directory, this wit-parser test highlights it as well
https://github.com/bytecodealliance/wasm-tools/tree/main/crates/wit-parser/tests/ui/foreign-deps

Low level tooling for WebAssembly in Rust. Contribute to bytecodealliance/wasm-tools development by creating an account on GitHub.

Last updated: Dec 23 2024 at 13:07 UTC