Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dantecatalfamo/mruby-zig
mruby bindings for zig
https://github.com/dantecatalfamo/mruby-zig
bindings mruby ruby zig zig-library
Last synced: about 2 months ago
JSON representation
mruby bindings for zig
- Host: GitHub
- URL: https://github.com/dantecatalfamo/mruby-zig
- Owner: dantecatalfamo
- License: mit
- Created: 2022-02-22T22:30:35.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-06-20T23:13:07.000Z (over 1 year ago)
- Last Synced: 2024-11-15T11:36:25.148Z (about 2 months ago)
- Topics: bindings, mruby, ruby, zig, zig-library
- Language: Zig
- Homepage:
- Size: 74.2 KB
- Stars: 33
- Watchers: 5
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - mruby-zig🗒️mruby bindings for zig
README
# mruby-zig
[mruby](https://mruby.org/) bindings for [zig](https://ziglang.org/)!
Mruby is the lightweight implementation of the Ruby language complying with part of the ISO standard.
Mruby documentation can be found [here](https://mruby.org/docs/api/).
## 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
```zig
const addMruby = @import("mruby-zig/build.zig").addMruby;pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});const exe = b.addExecutable(.{
.name = "example",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
addMruby(b, exe);// ...
}
```- Import `mruby` and start a new interpreter
```zig
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`