Skip to content

Commit 543cb4c

Browse files
Document the now three ways to use the wasi crate. (#99)
* Document the now three ways to use the wasi crate. Update the documentation to prominently describe the new wasm32-wasip2 target, to mention cargo component, and to put the existing wasm32-wasip1 with adapter approach in context. * Update README.md Co-authored-by: Pat Hickey <[email protected]> --------- Co-authored-by: Pat Hickey <[email protected]>
1 parent 1a65fdc commit 543cb4c

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,30 @@ fn main() {
4646
}
4747
```
4848

49-
This crate is intended to target [components] but today you need to go through
50-
the intermediate build step of a core WebAssembly module using the `wasm32-wasip1`
51-
target:
49+
This crate can currently be used in three main ways.
50+
51+
- One is to use it and compile for the [`wasm32-wasip2` target] in Rust 1.82 and later.
52+
This is the simplest approach, as all the tools needed are included in the
53+
Rust tooling, however it doesn't yet support some of the features of the
54+
other approaches.
55+
56+
- Another is to use it and compile using [`cargo component`]. This is essentially
57+
the same as the next option, except that `cargo component` handles most of the
58+
steps for you. `cargo component` also has a number of additional features for
59+
working with dependencies and custom WIT interfaces.
60+
61+
- And the third is to compile for the `wasm32-wasip1` target, and then adapt
62+
the resulting modules into component using `wasm-tools component new`; see
63+
the next section here for details.
64+
65+
[`wasm32-wasip2` target]: https://blog.rust-lang.org/2024/11/26/wasip2-tier-2.html
66+
[`cargo component`]: https://github.com/bytecodealliance/cargo-component
67+
68+
## Building with wasm32-wasip1 and `cargo component new`.
69+
70+
The `wasm32-wasip2` target works with a simple `cargo build --target=wasm32-wasip2`
71+
and doesn't need a lot of documentation here, and `cargo component` has its own
72+
documentation, so here we have some documentation for the `wasm32-wasip1` way.
5273

5374
```
5475
$ cargo build --target wasm32-wasip1

0 commit comments

Comments
 (0)