Skip to content
 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

146 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mruby-zig

mruby bindings for zig!

Mruby is the lightweight implementation of the Ruby language complying with part of the ISO standard.

Mruby documentation can be found here.

Embedding

To embed mruby into another zig project, you just need to recursively clone this repository and add a couple of lines to your build.zig.

  • Add the following lines to build.zig, with the paths changed to match the correct location

    const addMruby = @import("mruby-zig/build.zig").addMruby;
    
    pub fn build(b: *std.build.Builder) void {
        [...]
        const exe = b.addExecutable("example", "src/main.zig");
        addMruby(exe);
        [...]
    }
  • Import mruby and start a new interpreter

const std = @import("std");
const mruby = @import("mruby");

pub fn main() anyerror!void {
    // Opening a state
    var mrb = try mruby.open();
    defer mrb.close();

    // Loading a program from a string
    mrb.load_string("puts 'hello from ruby!'");
}

Example

See examples/main.zig

About

mruby bindings for zig

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages