Stream: cargo-component

Topic: How should I import wasi:cli?


view this post on Zulip Damian Reeves (Jun 03 2024 at 20:41):

For wasi components do I need to add the wit files for the WASI components or are they all intrinsically included?

view this post on Zulip Alex Crichton (Jun 03 2024 at 20:54):

Generally they're included through an adapter, e.g. wasi_snapshot_preview1.command.wasm. If you're using Rust you can also include them via the wasi crate on crates.io. For other languages if you're not using an adapter you'll need to copy them in

view this post on Zulip Damian Reeves (Jun 03 2024 at 21:04):

Thanks for the response.
If I want to write to stdout is this what I need to do instead of simply calling println!?
Also are there any examples out there of using this with cargo component?

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:05):

Using println! should work by default with cargo component

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:06):

As for an example, I'm not sure if you're looking for something specific? cargo component new foo followed by cargo component run shows println! working for me

view this post on Zulip Damian Reeves (Jun 03 2024 at 21:07):

I'm finding whenever I include a println! in my built cargo component and use it in a jco built use in a JavaScript app that the app hangs on the println. If I remove the println, I get no hang.

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:08):

This might be related to jco then rather than cargo component?

view this post on Zulip Damian Reeves (Jun 03 2024 at 21:09):

Would I need the wasi, dependencies in my cargo components though?

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:10):

Sorry I'm not sure what you mean by that? cargo component build will produce a component which you can feed to jco as-is, no need to pull anything else along. The cargo component tools is a means by which to produce a component from rust source code, but once you have the component it's up to you where to put it

view this post on Zulip Damian Reeves (Jun 03 2024 at 21:12):

Yeah that's what I thought. I was just thinking that possibly the hang was because I didn't link in something I need to.

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:16):

ah no you should be good in that respect

view this post on Zulip Alex Crichton (Jun 03 2024 at 21:17):

once you have a component it's a standalone thing which is runnable or not given its imports

view this post on Zulip Damian Reeves (Jun 03 2024 at 21:19):

Thanks.


Last updated: Nov 25 2024 at 19:03 UTC