This is a header-only wrapper over mruby. You still need to pull mruby into your project. That is not covered in this README.
You can see the Coverage report at https://labs.astrobunny.io/mruby-cpp
Contributors please change your upstream to
git remote set-url upstream https://gitlab.astrobunny.net/astrobunny/mruby-cpp
Likewise if you checked this code out from github before, please change the repo you pull from using this command:
git remote set-url origin https://gitlab.astrobunny.net/astrobunny/mruby-cpp
Add the repository directory to your compiler include directory list
CPPFLAGS="$CPPFLAGS -Imruby-cpp"
Include mruby.hpp
#include <mruby.hpp>
Its that simple!
mruby::VM vm;
vm.run("puts 'hello world!'");
# hello world!
int myfunction(int a, int b)
{
return a+b;
}
vm.bind_method("myfunction", myfunction);
vm.run("p myfunction 5,6")
# 11
You can test by running
make test
This will download mruby and compile it to test the headers.
Simply add a cpp file to the tests folder, and make will pick it up automatically when running make test
. If your test fails simply return a non-zero value.
Have fun with mruby!