@@ -43,7 +43,7 @@ below][hosts].
43
43
44
44
The ` wit-bindgen ` project extensively uses [ WIT] definitions to describe imports
45
45
and exports. The items supported by [ WIT] directly map to the component model
46
- which allows core WebAssembly binaries produce by native compilers to be
46
+ which allows core WebAssembly binaries produced by native compilers to be
47
47
transformed into a component. All imports into a WebAssembly binary and all
48
48
exports must be described with [ WIT] . An example file looks like:
49
49
@@ -180,13 +180,13 @@ The Rust compiler supports a native `wasm32-wasi` target and can be added to any
180
180
` rustup ` -based toolchain with:
181
181
182
182
``` sh
183
- $ rustup target add wasm32-wasi
183
+ rustup target add wasm32-wasi
184
184
```
185
185
186
186
Projects can then depend on ` wit-bindgen ` by executing:
187
187
188
188
``` sh
189
- $ cargo add --git https://github.com/bytecodealliance/wit-bindgen wit-bindgen-guest-rust
189
+ cargo add --git https://github.com/bytecodealliance/wit-bindgen wit-bindgen-guest-rust
190
190
```
191
191
192
192
WIT files are currently added to a ` wit/ ` folder adjacent to your ` Cargo.toml `
@@ -219,8 +219,8 @@ doc` you can also explore the generated code.
219
219
This project can then be built with:
220
220
221
221
``` sh
222
- $ cargo build - --target wasm32-wasi
223
- $ wasm-tools component new ./target/wasm32-wasi/debug/my-project.wasm \
222
+ cargo build --target wasm32-wasi
223
+ wasm-tools component new ./target/wasm32-wasi/debug/my-project.wasm \
224
224
-o my-component.wasm --adapt ./wasi_snapshot_preview1.wasm
225
225
```
226
226
@@ -229,11 +229,11 @@ component runtime. Using `wasm-tools` you can inspect the binary as well, for
229
229
example inferring the WIT world that is the component:
230
230
231
231
``` sh
232
- $ wasm-tools component wit my-component.wasm
233
- default world my-component {
234
- import print: func(msg: string)
235
- export run: func ()
236
- }
232
+ wasm-tools component wit my-component.wasm
233
+ # default world my-component {
234
+ # import print: func(msg: string)
235
+ # export run: func()
236
+ # }
237
237
```
238
238
239
239
which in this case, as expected, is the same as the input world.
@@ -251,10 +251,10 @@ project to use. These files are generated with the [`wit-bindgen` CLI
251
251
command] [ cli-install ] in this repository.
252
252
253
253
``` sh
254
- $ wit-bindgen c ./wit
255
- Generating " host.c"
256
- Generating " host.h"
257
- Generating " host_component_type.o"
254
+ wit-bindgen c ./wit
255
+ # Generating "host.c"
256
+ # Generating "host.h"
257
+ # Generating "host_component_type.o"
258
258
```
259
259
260
260
Some example code using this would then look like
@@ -276,14 +276,14 @@ This can then be compiled with `clang` from the [WASI SDK] and assembled into a
276
276
component with:
277
277
278
278
``` sh
279
- $ clang host.c host_component_type.o my-component.c -o my-core.wasm -mexec-model=reactor
280
- $ wasm-tools component new ./my-core.wasm -o my-component.wasm
279
+ clang host.c host_component_type.o my-component.c -o my-core.wasm -mexec-model=reactor
280
+ wasm-tools component new ./my-core.wasm -o my-component.wasm
281
281
```
282
282
283
283
Like with Rust, you can then inspect the output binary:
284
284
285
285
``` sh
286
- $ wasm-tools component wit ./my-component.wasm
286
+ wasm-tools component wit ./my-component.wasm
287
287
```
288
288
289
289
0 commit comments