jbreeden / mruby-apr

A portable runtime library for mruby
14 stars 1 forks source link

mruby-apr

Join the chat at https://gitter.im/jbreeden/mruby-apr

A cross-platform MRuby port of the core system libraries from CRuby:

Specs

See the ruby/spec results

Building

Mac and Linux

1. Setup the dependencies

_Note: APR uses the off64_t type. If you're running 32-bit Linux and get errors like "Unknown type name off64_t" you'll need to define the preprocessor macro _LARGEFILE64_SOURCE._

Windows

1. Setup the dependencies

2. CMake & Rake

APR comes with cmake scripts. You can use cmake to generate different kinds of project files for building APR. To name a few, Visual Studio, MinGW, and NMake are supported. Just use the same compiler you're using for MRuby.

Once APR is built

cd /path/to/mruby
rake

Platform Support

Primary development and testing done on Windows, Mac, Ubuntu, and Raspbian. However, it should work anywhere you can compile Apache APR.

Implementation Details

Apache APR provides a cross platform runtime library for C, allowing portable access to system resources (eg processes, files, sockets, etc.). mruby-apr provides bindings to this library to bring these capabilities to mruby, without having to code the cross-platform logic over again.

These bindings are provided at 2 distinct levels:

  1. Direct bindings to libapr are provided in the APR module.
    • These bindings provide a nearly identical api to libapr from mruby as is available in C.
    • The main point of difference is that out-parameters in the C API correspond to multiple return values in the mruby API.
  2. The direct bindings are used to implement portions of the CRuby standard library, purely in mruby.
    • This provides a familiar and idiomatic API to system resources for ruby programmers.
    • As with the Rubinius implementation, this should make it easier for Ruby programmers to hack on the stdlib.