ユーザ用ツール

サイト用ツール


wasi

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
wasi [2023/03/12 11:35] nullponwasi [2025/01/11 11:51] (現在) nullpon
行 1: 行 1:
-====== WASI ======+<markdown> 
 +WASI
  
 wasiはブラウザ以外でWebAssembly(wasm)を実行する際、システムリソース(ファイル、ネットワーク、時刻など)にアクセスするためのインターフェース仕様 wasiはブラウザ以外でWebAssembly(wasm)を実行する際、システムリソース(ファイル、ネットワーク、時刻など)にアクセスするためのインターフェース仕様
行 5: 行 6:
 ブラウザ以外でのwasm実行環境をwasiと呼ぶこともある ブラウザ以外でのwasm実行環境をwasiと呼ぶこともある
  
-===== コマンドライン実行環境 =====+## 実行環境 
 + 
 +### CLI
    
-  * [[https://wasmtime.dev/|Wasmtime]] +  * [Wasmtime](https://wasmtime.dev/) 
-  * [[https://wasmer.io/|Wasmer - The Universal WebAssembly Runtime]]+  * [Wasmer - The Universal WebAssembly Runtime](https://wasmer.io/
 +  * [WasmEdge](https://wasmedge.org/)
  
-macOSいずれもbrewでインストール可能+wasmtime、wasmerはbrewでインストール可能。wasmedgeはdockerイメージが配布されている
  
-===== サーバ実行環境 =====+### HTTPサーバ
    
-  * [[https://workers.wasmlabs.dev/|Wasm Workers Server]]+  * [Wasm Workers Server](https://workers.wasmlabs.dev/
 + 
 + 
 +## rustでwasmをビルドしてwasiで実行 
 + 
 +[wasmtim](https://wasmtime.dev/) をインストール 
 + 
 +``` 
 +brew install wasmtime 
 +``` 
 + 
 +wasm32-wasip1をビルドターゲットを追加 
 + 
 +``` 
 +rustup target add wasm32-wasip1 
 +``` 
 + 
 +プロジェクトの作成 
 + 
 +``` 
 +cargo init 
 +``` 
 + 
 +Cargo.tomlに以下を追加 
 + 
 +``` 
 +[[bin]
 +name = "hoge" 
 +path = "src/main.rs" 
 +``` 
 + 
 +コードを書く 
 + 
 +```rust 
 +fn main() { 
 +    println!("Hello, world!"); 
 +
 +``` 
 + 
 + 
 +ビルド 
 + 
 +``` 
 +cargo build --target wasm32-wasip1 
 +``` 
 + 
 +実行 
 + 
 +``` 
 +wasmtime target/wasm32-wasi/debug/hoge.wasm 
 +``` 
 + 
 +</markdown>
wasi.1678620913.txt.gz · 最終更新: 2023/03/12 11:35 by nullpon