A portable runtime library for mruby
C Ruby C++ Objective-C HTML
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
include Get rid of old headers (use system headers instead) Jan 31, 2016
lib/win Initial commit Jul 12, 2015
mrblib Use mruby-rake-tasks Aug 20, 2016
mruby-bindings.in
rakelib Almost fixes #4, though use of flags_after_libraries is undesirable Oct 18, 2016
sandbox Check for MRB_INT64 when building Feb 13, 2016
specs Docs Feb 16, 2016
src Add Errno classes & fix SystemCallError API Mar 13, 2016
.gitignore Almost fixes #4, though use of flags_after_libraries is undesirable Oct 18, 2016
Gemfile
README.md
Rakefile.rb
api.md api.md update Feb 16, 2016
apr_functions.txt Adding recvfrom test Oct 10, 2015
build_config.rb Use mruby-rake-tasks Aug 20, 2016
doc.erb Merge origin Dec 8, 2015
mrbgem.rake Almost fixes #4, though use of flags_after_libraries is undesirable Oct 18, 2016
refactor.rb
spec.md Adding recvfrom test Oct 10, 2015

README.md

mruby-apr

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

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

  • IO (read, write, pipe, popen)
  • File, FileTest, File::Stat
  • Dir
  • BasicSocket, UDPSocket, TCPSocket, TCPServer
  • ENV
  • Kernel ( `backticks`, system, spawn, & load)
  • Process (spawn & wait)
  • Process::Status (including the global $?)
  • Forwardable
  • Observer
  • OpenStruct
  • Pathname
  • Shellwords

Specs

See the ruby/spec results

Building

Mac and Linux

1. Setup the dependencies

  • Download libapr version 1.5.2 from Apache's website
  • Download mruby-apr here.
  • Add the following lines to your MRuby build_config.rb file.
spec.cc.flags << '-DMRB_INT64'
conf.gem 'path/to/mruby-apr'

2. Make & Rake

cd /path/to/apr
configure && make && sudo make install
cd /path/to/mruby
rake

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

  • Download libapr version 1.5.2 from Apache's website
  • Download mruby-apr here.
  • Add the following lines to your MRuby build_config.rb file.
spec.cc.flags << '-DMRB_INT64'
ENV['APR_HOME'] = "/path/to/your/libapr/build/dir"
conf.gem '/path/to/mruby-apr'

Notice that on windows, you must set APR_HOME to tell this gem where to find headers & lib files

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.
  1. 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.