Stream: general

Topic: wit-bindgen command line


view this post on Zulip Phantom (Jul 17 2024 at 01:28):

I am new to wit bindgen and trying to get my feet wet. I have created my own .wit file and trying to use the wit-bindgen command line to generate rust bindings. But I am afraid I don't know what I need to supply with the --with flag. I basically want to do wit-bindgen rust hello.wit. But it says I absolutely need to provide --with flag. How can I get around this? Thanks in advance.

view this post on Zulip Christof Petig (Jul 17 2024 at 12:20):

Phantom said:

I am new to wit bindgen and trying to get my feet wet. I have created my own .wit file and trying to use the wit-bindgen command line to generate rust bindings. But I am afraid I don't know what I need to supply with the --with flag. I basically want to do wit-bindgen rust hello.wit. But it says I absolutely need to provide --with flag. How can I get around this? Thanks in advance.

I would recommend to use the github version of wit-bindgen as the with argument became optional again. Otherwise just provide your interface =generate to --with. I never figured out the syntax for multiple interfaces, though.

view this post on Zulip Phantom (Jul 17 2024 at 22:12):

Christof Petig said:

Phantom said:

I am new to wit bindgen and trying to get my feet wet. I have created my own .wit file and trying to use the wit-bindgen command line to generate rust bindings. But I am afraid I don't know what I need to supply with the --with flag. I basically want to do wit-bindgen rust hello.wit. But it says I absolutely need to provide --with flag. How can I get around this? Thanks in advance.

I would recommend to use the github version of wit-bindgen as the with argument became optional again. Otherwise just provide your interface =generate to --with. I never figured out the syntax for multiple interfaces, though.

Thanks for the response. So I built the wit-bindgen crate and used the binary under target. But looks like the --with is mandatory. I tried ./wit-bindgen rust --with generate= myinterface mywasm.wit.

It complains about my usage of the --with flag. What am I doing wrong?

view this post on Zulip Christof Petig (Jul 18 2024 at 05:43):

Yesterday's wit-bindgen release should also work. The with syntax is package:sub/interface=generate but I am still surprised that it isn't optional: https://github.com/bytecodealliance/wit-bindgen/pull/999

This commit fixes the --with option in the Rust generate from changes in #972. Notably the fixes here are: The --with option is no longer required. Multiple --with options are now accepted again. ...

view this post on Zulip Alex Crichton (Jul 18 2024 at 14:28):

With Rust code if possible it's recommended to use the wit_bindgen::generate! macro as a crate dependencey, but otherwise yes there were some problems with the release-before-last of wit-bindgen-the-CLI which should be improved now. The CLI should recommend extra flags you need to pass. You might be interested in the --generate-all CLI flag.

view this post on Zulip Phantom (Jul 19 2024 at 03:08):

Alex Crichton said:

With Rust code if possible it's recommended to use the wit_bindgen::generate! macro as a crate dependencey, but otherwise yes there were some problems with the release-before-last of wit-bindgen-the-CLI which should be improved now. The CLI should recommend extra flags you need to pass. You might be interested in the --generate-all CLI flag.

Thanks. The latest pull works with --generate-all.


Last updated: Nov 22 2024 at 16:03 UTC