diff --git a/docs/tutorial-create-hello-world.md b/docs/tutorial-create-hello-world.md index 8e290aae76..6f2d9cb6da 100644 --- a/docs/tutorial-create-hello-world.md +++ b/docs/tutorial-create-hello-world.md @@ -1,3 +1,63 @@ # Creating `hello-world.wasm` -... more coming soon +There are a number of ways to create `.wasm` files but for the purposes of this +tutorial, we'll be using the Rust toolchain. You can find more information on +creating `.wasm` files from other languages in the +[Writing WebAssembly section](./wasm.md). + +To build WebAssembly binaries with Rust, you'll need the standard Rust toolchain. + +[Follow these instructions to install `rustc`, `rustup` and `cargo`](https://www.rust-lang.org/tools/install) + +Next, you should add WebAssembly as a build target for cargo like so: + +```sh +$ rustup target add wasm32-wasi +``` + +Finally, create a new Rust project called 'hello-world'. You can do this by running: + +```sh +$ cargo new hello-world +``` + +After that, the hello-world folder should look like this. + +```text +hello-world/ +├── Cargo.lock +├── Cargo.toml +└── src + └── main.rs +``` + +And the `main.rs` file inside the `src` folder should contain the following rust code. + +```rust +fn main() { + println!("Hello, world!"); +} + +``` + +Now, we can tell `cargo` to build a WebAssembly file: + +```sh +$ cargo build --target wasm32-wasi +``` + +Now, in the `target` folder, there's a `hello-world.wasm` file. You can find it here: + +```text +hello-world/ +├── Cargo.lock +├── Cargo.toml +├── src +└── target + └── ... + └── wasm32-wasi + └── debug + └── ... + └── hello-world.wasm + +``` diff --git a/docs/tutorial-run-hello-world.md b/docs/tutorial-run-hello-world.md index ffe03c7075..5cd08e3806 100644 --- a/docs/tutorial-run-hello-world.md +++ b/docs/tutorial-run-hello-world.md @@ -1,3 +1,28 @@ # Running `hello-world.wasm` with Wasmtime -... more coming soon +## Installing Wasmtime + +The Wasmtime CLI can be installed on Linux and macOS with a small install +script: + +```sh +$ curl https://wasmtime.dev/install.sh -sSf | bash +``` + +You can find more information about installing the Wasmtime CLI in the +[CLI Installation section](./cli-install.md) + +## Running `hello-world.wasm` + +There are a number of ways to run a `.wasm` file with Wasmtime. In this +tutorial, we'll be using the CLI, Wasmtime can also be embedded in your +applications. More information on this can be found in the +[Embedding Wasmtime section](./embed.md). + +If you've built the `hello-world.wasm` file (the instructions for doing so are in the +[previous section](./tutorial-create-hello-world.md)), +you can run it with Wasmtime from the command line like so: + +```sh +$ wasmtime target/wasm32-wasi/debug/hello-world.wasm +```