| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
Command-line interface for mruby/edge - a lightweight, WebAssembly-focused mruby VM implementation.
mruby/edge is an mruby-compatible virtual machine implementation written in Rust, specifically designed for WebAssembly environments. It aims to provide:
Install mrubyedge-cli using cargo:
cargo install mrubyedge-cliOr build from source:
git clone https://github.com/mrubyedge/mrubyedge.git
cd mrubyedge
cargo build --release -p mrubyedge-cliThe binary will be available as mrbedge.
Create a simple Ruby script hello.rb:
puts "Hello from mruby/edge!"
puts RUBY_ENGINERun it with mrbedge:
mrbedge hello.rb
# or explicitly
mrbedge run hello.rbThe run subcommand executes Ruby source files (.rb) or compiled mruby bytecode (.mrb).
Usage:
mrbedge run <file>
# or simply
mrbedge <file>Examples:
# Run Ruby source
mrbedge run script.rb
# Run compiled bytecode
mrbedge run script.mrbCompiles Ruby source code into mruby bytecode format for faster loading and distribution.
Usage:
mrbedge compile-mrb <input.rb> -o <output.mrb>Examples:
# Compile a single file
mrbedge compile-mrb app.rb -o app.mrb
# Run the compiled bytecode
mrbedge run app.mrbBenefits:
Compiles Ruby code directly into a standalone WebAssembly module that can run in browsers or any WebAssembly runtime.
Usage:
mrbedge wasm <input.rb> -o <output.wasm>Examples:
# Generate WebAssembly module
mrbedge wasm app.rb -o app.wasm
# Use in browser or Node.js
# The generated WASM can be loaded and executed in any WASM runtimeUse Cases:
The wasm command can generate both WASI-enabled and non-WASI WebAssembly binaries. By default, it produces WASI-enabled modules. To disable WASI support, use the --no-wasi flag.
You can specify WebAssembly function imports and exports using RBS (Ruby Signature) files. Place RBS files with specific naming conventions alongside your Ruby script:
For a Ruby script named foo.rb:
Example:
# app.rb
def calculate(x, y)
x + y
end# app.export.rbs
def calculate: (Integer, Integer) -> Integer# app.import.rbs
def external_log: (String) -> voidThe generated WebAssembly module will expose calculate and can call external_log from the host environment.
Note: Inline RBS annotations for imports and exports will be supported in future releases.
See the LICENSE file in the repository root.
| Back | FazBrowse Home | New Git URL |