Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kassane/wamr-zig
Zig bindings from WebAssembly Micro Runtime (WAMR)
https://github.com/kassane/wamr-zig
embedded wamr wasm webassembly zig-package
Last synced: about 2 months ago
JSON representation
Zig bindings from WebAssembly Micro Runtime (WAMR)
- Host: GitHub
- URL: https://github.com/kassane/wamr-zig
- Owner: kassane
- License: apache-2.0
- Created: 2024-08-31T12:31:25.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-09-08T17:59:17.000Z (5 months ago)
- Last Synced: 2024-12-10T19:27:18.062Z (about 2 months ago)
- Topics: embedded, wamr, wasm, webassembly, zig-package
- Language: Zig
- Homepage:
- Size: 473 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WAMR-zig
### Overview
Based on [WAMR Rust SDK](https://github.com/bytecodealliance/wamr-rust-sdk). It is the wrapper
of [*wasm_export.h*](https://github.com/bytecodealliance/wasm-micro-runtime/blob/main/core/iwasm/include/wasm_export.h) but with Zig style.### Requirements
- [Zig](https://ziglang.org/download/) v0.13.0 or master.
- [CMake](https://cmake.org/download/) v3.12.0 or master.
- [LLVM libs](https://github.com/llvm/llvm-project/releases) v16.0.0 or master.#### Core concepts
- *Runtime*. It is the environment that hosts all the wasm modules. Each process has one runtime instance.
- *Module*. It is the compiled .wasm or .aot. It can be loaded into runtime and instantiated into instance.
- *Instance*. It is the running instance of a module. It can be used to call export functions.
- *Function*. It is the exported function.#### WASI concepts
- *WASIArgs*. It is used to configure the WASI environment.
- *pre-open*. All files and directories in the list will be opened before the .wasm or .aot loaded.
- *allowed address*. All ip addresses in the *allowed address* list will be allowed to connect with a socket.
- *allowed DNS*.### How to use
- **New project**
```bash
# Create directory
$ mkdir project-name
$ cd project-name
$ zig init
# Add dependency in zon file
$ zig fetch --save=wamr-zig git+https://github.com/wamr-zig/wamr-zig
```
Add in **build.zig**
```zig
const std = @import("std");pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});const wamr_zig = b.dependency("wamr-zig", .{
.target = target,
.optimize = optimize,
});// your project
[exe|lib].root_module.addImport("wamr", wamr_zig.module("wamr"));
}
```