From 963ddd26a89490458e31d9d553dffafe5e350e96 Mon Sep 17 00:00:00 2001 From: Henry Gressmann Date: Mon, 29 Jan 2024 22:38:06 +0100 Subject: chore: add more examples, refactoring Signed-off-by: Henry Gressmann --- examples/wasm-rust.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'examples/wasm-rust.rs') diff --git a/examples/wasm-rust.rs b/examples/wasm-rust.rs index 112222c..b57a1da 100644 --- a/examples/wasm-rust.rs +++ b/examples/wasm-rust.rs @@ -1,6 +1,22 @@ use color_eyre::eyre::Result; use tinywasm::{Extern, FuncContext, Imports, MemoryStringExt, Module, Store}; +/// Examples of using WebAssembly compiled from Rust with tinywasm. +/// +/// These examples are meant to be run with `cargo run --example wasm-rust `. +/// For example, `cargo run --example wasm-rust hello`. +/// +/// To run these, you first need to compile the Rust examples to WebAssembly: +/// +/// ```sh +/// ./examples/rust/build.sh +/// ``` +/// +/// This requires the `wasm32-unknown-unknown` target, `binaryen` and `wabt` to be installed. +/// `rustup target add wasm32-unknown-unknown`. +/// https://github.com/WebAssembly/wabt +/// https://github.com/WebAssembly/binaryen +/// fn main() -> Result<()> { let args = std::env::args().collect::>(); if args.len() < 2 { -- cgit v1.3.1