Stream: wit-bindgen

Topic: Best way to share wit file between projects


view this post on Zulip CircuitSacul (Mar 07 2024 at 18:25):

Is there a recommended way to share a wit file between different projects? e.g. between the host system (rust), and the guest system?

view this post on Zulip Lann Martin (Mar 07 2024 at 18:36):

Not yet. This has been a pain for all of us but took a back seat to wasi 0.2 implementation work in the recent past. I think there will be some improvements in the relatively near future.

view this post on Zulip Lann Martin (Mar 07 2024 at 18:38):

I suppose I should make the simplest recommendation in case it isn't obvious: wit tooling can generally take a path to the directory holding the wit files; if your project structure allows for that kind of sharing then I recommend it :smile:

view this post on Zulip CircuitSacul (Mar 07 2024 at 18:49):

Thanks. I hope there's a nicer solution in the future.

My use case requires that it be shared between users and an arbitrary number of guest systems.

The best solution I could come up with so far is to:

  1. Have a separate repo to store the wit files
  2. Add that repo as a sub-repo to the host system, and bindgen from that path
  3. Add that repo as a sub-repo to the guest helper crate, which will do some fancy macro stuff to include_str it from path and inject it into the bindgen! macro directly. Then I can release the crate and it can be directly used by guest systems.

An alternative is to fetch the file at compile time, but depending on network access to github at compile-time seems like a bad idea.


Last updated: Nov 22 2024 at 16:03 UTC