Skip to content

Commit faad5c0

Browse files
committed
Adding README
Signed-off-by: Mark Rossett <[email protected]>
1 parent 3de3938 commit faad5c0

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

Justfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-adder:
44
init-subtractor:
55
cd components/subtractor && npm install
66

7-
build-subtractor:
7+
build-subtractor: init-subtractor
88
cd components/subtractor && npm run build:component
99

1010
build-calculator:
@@ -22,12 +22,12 @@ build-component: build-adder build-subtractor build-calculator
2222
compile-wit:
2323
wasm-tools component wit {{ justfile_directory() }}/example/calculator-composed.wit -w -o {{ justfile_directory() }}/example/calculator-composed-world.wasm
2424

25-
build-example:
25+
build-example: compile-wit
2626
cd example && \
2727
HYPERLIGHT_WASM_WORLD={{ justfile_directory() }}/example/calculator-composed-world.wasm \
2828
cargo build
2929

30-
run-example:
30+
run-example: compile-wit
3131
cd example && \
3232
HYPERLIGHT_WASM_WORLD={{ justfile_directory() }}/example/calculator-composed-world.wasm \
3333
cargo run

README.md

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1-
## Required tools
2-
3-
- Rust toolchain
4-
- Node.js
5-
- wasm-tools
6-
- wac
7-
- wasi-virt
8-
- hyperlight-wasm-aot (needed?)
1+
# `hyperlight-wasm` calculator example
2+
3+
THis is an example of a hyperlight-wasm application that runs a wasm component inside a hyperlight-sandbox that implements a calculator (similar to the component model example [here](https://github.com/bytecodealliance/component-docs/tree/main/component-model/examples/tutorial)).
4+
5+
The [calculator](./wit/calculator.wit) itself is comprised of three wasm components:
6+
- `calculator` - the main component that implements the calculator interface (written in Rust)
7+
- `adder` - a component that implements the addition operation (written in Rust)
8+
- `subtractor` - a component that implements the subtraction operation (written in Javascript)
9+
10+
The [example](./example/) program loads the composed calculator/wasm component into a hyperlight-sandbox along with a wasm runtime and invokes functions as hyperlight-guest calls.
11+
12+
## Requirements
13+
14+
To build and run this example, you need the following tools installed on your system:
15+
16+
- [Rust toolchain](https://www.rust-lang.org/tools/install) including `x86_unknown-none` target
17+
- https://www.rust-lang.org/tools/install
18+
- [Node.js](https://nodejs.org/en/download) (to build the [subtractor](./components/subtractor/) wasm component)
19+
- [wasm-tools](https://github.com/bytecodealliance/wasm-tools?tab=readme-ov-file#installation)
20+
- [wac](https://github.com/bytecodealliance/wac?tab=readme-ov-file#installation)
21+
- [cargo component](https://github.com/bytecodealliance/cargo-component?tab=readme-ov-file#installation)
22+
- hyperlight-wasm-aot
23+
- cargo install --git https://github.com/hyperlight-dev/hyperlight-wasm hyperlight-wasm-aot
24+
- [Just](https://github.com/casey/just?tab=readme-ov-file#installation)
25+
26+
## Running the example
27+
28+
- Build the guest component
29+
```bash
30+
just build-component
31+
```
32+
- Run the example program
33+
```bash
34+
just run-example
35+
```

0 commit comments

Comments
 (0)