Skip to content
mruby WebAssembly using WebIDL
HTML Ruby C++ JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
mruby @ 0701cc4
src
template
.gitignore
.gitmodules
.travis.yml
README.md
Rakefile
mruby.idl
mruby_wasm_config.rb
wasm.gembox

README.md

mruby.wasm

Binding mruby to WebAssembly use WebIDL

Requirements

  • Emscripten SDK
  • Ruby
  • Rake
  • Python

Compile

To compile project, please make sure your emsdk is already configured with $EMSDK environment and emcc command.

Please make sure you are use LLVM version instead Fastcomp version. The LLVM version can install by use emsdk install latest-upstream.

libmruby

Compile mruby and generate libmruby.bc

rake libmruby

WebIDL Glue

Generate glue.cpp and glue.js for WebIDL

rake mruby.idl

WebAssemtly

Generate mruby's WebAssembly file

rake wasm
rake js
rake html

The rake html is default task, you can specify which output you wants

If you want to minify for production, please add MINIFY environment

MINIFY=1 rake html

Usage

Local PlayGround

Prepare WebAssembly

# Create mruby.html
rake html

# Serve mruby.wasm
ruby -run -e httpd .

Goto http://localhost:8080/mruby.html and open the console to execute ruby code.

var ruby = new Ruby()
ruby.Execute('puts "Hello World"')

Production

Prepare WebAssembly

rake js

Copy mruby.js and mruby.wasm to your project and load WebAssembly by yourself.

Currently this project is for prototype to test use mruby on browser, it is not stable!

References

You can’t perform that action at this time.