Skip to content

Commit

Permalink
feat(gate)!: wasmtime support (#669)
Browse files Browse the repository at this point in the history
#### Motivation and context

Enable support for
[wit](https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md)
and facilitate readiness for the upcoming specs.

#### Migration notes
`#[wasmedge_bindgen]` are replaced by wit bindings.

In the old version we were restricted to`#[wasmedge_bindgen]`, which was
only available in Rust and unique to WasmEdge.
```rust
#[wasmedge_bindgen]
fn add(a: u32, b: u32) -> u32 {
   a + b
}
```

In the new implementation, wasm modules written in any language that
uses the `wit` interface are now natively supported within `typegate`.
```wit
// wit/example.wit
package example:host;
world host {
  export add: func(a: u32, b: u32) -> u32;
}
```
An implementation (eg. in Rust) may look like this..
```rust
// src/lib.rs
wit_bindgen::generate!({ world: "host" });
struct MyLib;
impl Guest for MyLib {
    fn add(a: u32, b: u32) -> u32 {
        a + b
    }
}
export!(MyLib);
```

### Checklist

- [x] The change come with new or modified tests
- [x] Hard-to-understand functions have explanatory comments
- [ ] End-user documentation is updated to reflect the change

---------

Co-authored-by: Yohe-Am <56622350+Yohe-Am@users.noreply.github.com>
  • Loading branch information
michael-0acf4 and Yohe-Am committed Apr 21, 2024
1 parent 7593eb8 commit 98dac2a
Show file tree
Hide file tree
Showing 47 changed files with 1,992 additions and 13,215 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ jobs:
- uses: denoland/setup-deno@v1
with:
deno-version: ${{ env.DENO_VERSION }}
- name: Cache deno dir
uses: actions/cache@v4
with:
path: ${{ env.DENO_DIR }}
key: deno-mac-${{ hashFiles('**/deno.lock') }}
# - name: Cache deno dir
# uses: actions/cache@v4
# with:
# path: ${{ env.DENO_DIR }}
# key: deno-mac-${{ hashFiles('**/deno.lock') }}
- uses: metatypedev/setup-ghjk@2e8bbf084060a18828338a7cdd43fde6feb2a3cc
- name: Cache .venv dir
uses: actions/cache@v4
Expand Down Expand Up @@ -316,7 +316,7 @@ jobs:
NPM_CONFIG_REGISTRY=http://localhost:4873 deno cache --import-map typegate/import_map.json \
typegate/src/main.ts \
typegate/tests/utils/*.ts \
typegate/tests/runtimes/wasmedge/*.ts \
typegate/tests/runtimes/wasm/*.ts \
dev/deps.ts \
dev/utils.ts
deno --unstable-worker-options --unstable-net coverage ./coverage --lcov > coverage.lcov
Expand Down
Loading

0 comments on commit 98dac2a

Please sign in to comment.