Ensure that a WebAssembly target for Rust is installed. wasm32-wasi
is useful
for debugging because it can log to the console, while wasm32-unknown-unknown
works for making minimal, standalone WebAssembly modules. Either can be used in
the following commands.
$ rustup target install wasm32-wasi
To build:
$ cargo build --target wasm32-wasi --release
Wasmtime is used as the WebAssembly runtime to test it here, but Wasmer and WAVM can also be used with very similar syntax.
To test:
$ wasmtime run --invoke wad_main target/wasm32-wasi/release/rust_wad_examples.wasm
Battle Damaged Sci-fi Helmet - PBR by theblueturtle_, published under a Creative Commons Attribution-NonCommercial license
https://sketchfab.com/models/b81008d513954189a063ff901f7abfe4