Gradual Epiphany

Rebar

Over the past two months, I’ve been busy taking the lessons learned from erlbox and designing a pure Erlang build tool called rebar. While erlbox is a very complete toolkit of rake functions for building Erlang code, it has a couple of significant problems. First off, the external dependency on rake is often a significant problem for developers who are not conversant in Ruby. While anyone can learn Ruby, if you’re an Erlang developer you likely have other tasks to attend to than learning a language solely for the purpose of maintaining your build system. The other significant problem with erlbox is that it spends a lot of time going in/out of Erlang to do “Erlangy” sorts of checks — like parsing/validating the .app file, running eunit, etc. This leads to erlbox being a relatively slow build system, not to mention a little awkward to maintain since it was an odd mix of Ruby and invocations of Erlang.

Thus, rebar was born. As a strictly Erlang implementation, it’s possible for Erlang developers to dig into it and improve/modify with minimal effort. It’s also wickedly fast, since it starts the VM up only once and has direct access to all the tools one needs to build and validate Erlang code. It has the added advantage of being able to take advantage of Erlang’s inherent parallelism, so where possible, it runs commands concurrently. Finally, it’s designed to be a self-contained escript, so using rebar doesn’t introduce any build dependencies other than a stock Erlang install. You simply drop the rebar script into your code tree and go!

You can see a demonstration of converting an existing app to rebar here.

Create and compile a simple OTP application by doing the following steps on a terminal:

1
2
3
4
5
6
 
$ mkdir myapp; cd myapp
$ wget http://bitbucket.org/basho/rebar/downloads/rebar; chmod u+x rebar
$ ./rebar create-app appid=myapp
$ ./rebar compile
 

Documentation is still scarce — that’s something I’m going to be working on over the next few weeks. The core pieces of rebar are mostly at a point that I’m happy with; now it’s time to polish. :)

If you have questions about rebar, or especially feedback after using it IRL, please ping me on Freenode IRC — I’m typically in the #riak room.