From 2b24836e39284951a2d20707c765a53870a08a97 Mon Sep 17 00:00:00 2001 From: Kate Goldenring Date: Tue, 1 Oct 2024 12:58:29 -0700 Subject: [PATCH] fix: update rust artifact directory to wasm32-wasip1 Signed-off-by: Kate Goldenring --- component-model/examples/tutorial/README.md | 12 ++++++------ component-model/src/language-support/rust.md | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/component-model/examples/tutorial/README.md b/component-model/examples/tutorial/README.md index 8ab393e..b963bbe 100644 --- a/component-model/examples/tutorial/README.md +++ b/component-model/examples/tutorial/README.md @@ -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: @@ -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 @@ -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: diff --git a/component-model/src/language-support/rust.md b/component-model/src/language-support/rust.md index 658e21c..a6aa26b 100644 --- a/component-model/src/language-support/rust.md +++ b/component-model/src/language-support/rust.md @@ -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 { @@ -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 ``` @@ -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 { @@ -216,7 +216,7 @@ To run your command component: ```sh cargo component build -wasmtime run ./target/wasm32-wasi/debug/.wasm +wasmtime run ./target/wasm32-wasip1/debug/.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`.