Skip to content

Commit

Permalink
Merge pull request #159 from kate-goldenring/wasm32-wasip1-target
Browse files Browse the repository at this point in the history
fix: update rust artifact directory to wasm32-wasip1
  • Loading branch information
kate-goldenring authored Oct 9, 2024
2 parents 28155c9 + 2b24836 commit 94eb52f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions component-model/examples/tutorial/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ Use [`cargo-component`](https://github.com/bytecodealliance/cargo-component) and
(cd calculator && cargo component build --release)
(cd adder && cargo component build --release)
(cd command && cargo component build --release)
wac plug calculator/target/wasm32-wasi/release/calculator.wasm --plug adder/target/wasm32-wasi/release/adder.wasm -o composed.wasm
wac plug command/target/wasm32-wasi/release/command.wasm --plug composed.wasm -o final.wasm
wac plug calculator/target/wasm32-wasip1/release/calculator.wasm --plug adder/target/wasm32-wasip1/release/adder.wasm -o composed.wasm
wac plug command/target/wasm32-wasip1/release/command.wasm --plug composed.wasm -o final.wasm
```

Now, run the component with Wasmtime:
Expand All @@ -68,9 +68,9 @@ wasmtime run final.wasm 1 2 add

```sh
mkdir -p deps/docs
cp adder/target/wasm32-wasi/release/adder.wasm deps/docs/adder-impl.wasm
cp calculator/target/wasm32-wasi/release/calculator.wasm deps/docs/calculator-impl.wasm
cp command/target/wasm32-wasi/release/command.wasm deps/docs/command-impl.wasm
cp adder/target/wasm32-wasip1/release/adder.wasm deps/docs/adder-impl.wasm
cp calculator/target/wasm32-wasip1/release/calculator.wasm deps/docs/calculator-impl.wasm
cp command/target/wasm32-wasip1/release/command.wasm deps/docs/command-impl.wasm
```

Now we are ready to construct a WAC file to define our composition. Ours instantiates our three components, declaring
Expand Down Expand Up @@ -107,7 +107,7 @@ wac compose composition.wac -o final.wasm

> Note, instead of moving all the components to a `deps/docs` directory, you can pass the paths to the components inline
> ```sh
> wac compose --dep docs:adder-impl=./adder/target/wasm32-wasi/release/adder.wasm --dep docs:calculator-impl=./calculator/target/wasm32-wasi/release/calculator.wasm --dep docs:command-impl=./command/target/wasm32-wasi/release/command.wasm -o final.wasm composition.wac
> wac compose --dep docs:adder-impl=./adder/target/wasm32-wasip1/release/adder.wasm --dep docs:calculator-impl=./calculator/target/wasm32-wasip1/release/calculator.wasm --dep docs:command-impl=./command/target/wasm32-wasip1/release/command.wasm -o final.wasm composition.wac
> ```
Run the component with Wasmtime:
Expand Down
8 changes: 4 additions & 4 deletions component-model/src/language-support/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ $ cargo component build --release
You can use `wasm-tools component wit` to output the WIT package of the component:

```sh
$ wasm-tools component wit target/wasm32-wasi/release/add.wasm
$ wasm-tools component wit target/wasm32-wasip1/release/add.wasm
package root:component;

world root {
Expand All @@ -75,7 +75,7 @@ Rust bindings, bring in WASI worlds, and execute the component.

```sh
$ cd examples/example-host
$ cargo run --release -- 1 2 ../add/target/wasm32-wasi/release/add.wasm
$ cargo run --release -- 1 2 ../add/target/wasm32-wasip1/release/add.wasm
1 + 2 = 3
```

Expand Down Expand Up @@ -180,7 +180,7 @@ When you build this using `cargo component build`, the `add` interface remains i
# Do a release build to prune unused imports (e.g. WASI)
$ cargo component build --release
$ wasm-tools component wit ./target/wasm32-wasi/release/calculator.wasm
$ wasm-tools component wit ./target/wasm32-wasip1/release/calculator.wasm
package root:component;
world root {
Expand Down Expand Up @@ -216,7 +216,7 @@ To run your command component:

```sh
cargo component build
wasmtime run ./target/wasm32-wasi/debug/<name>.wasm
wasmtime run ./target/wasm32-wasip1/debug/<name>.wasm
```

> **WARNING:** If your program prints to standard out or error, you may not see the printed output! Some versions of `wasmtime` have a bug where they don't flush output streams before exiting. To work around this, add a `std::thread::sleep()` with a 10 millisecond delay before exiting `main`.
Expand Down

0 comments on commit 94eb52f

Please sign in to comment.