Gradual Epiphany

10Jan/103

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:

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

Filed under: General Leave a comment
Comments (3) Trackbacks (0)
  1. It’s great to see this out in the open now! Good work.

  2. Great work Dave. I haven’t used it a great deal so far, but it’s certainly going to be in my tool chain! As I mentioned on Twitter, I’m happy to help out with documentation and any coding-related stuff that I find the time to work on.

    I’ve built a few small templates for creating gen_server, gen_fsm and plain ol’ modules as well. When generating modules it also generates the test code include stuff so that it’s all ready for eunit testing.

    Not sure if this is the kind of stuff you want to see included in your built-in templates, but I’m happy to share them if you want to consider them as an option. I’ve also added create-srv, create-fsm and create-mod functions to make it easier to use the templates, just as you did with create-app.

    One question: does rebar need a proper OTP application in place for it to be able to run the unit tests? Also, how difficult would it be to modify the templating system to allow file modifications? In particular, what would be nice would be to be able to update the .app file to add the names of new modules to the modules list to remove the need to do it manually?

    Thoughts?

    Cheers mate, keep up the great work.
    OJ

  3. Since I didn’t find a command description or listing, I took a peak into the code. Here are the commands I found (there are some more and some are duplicate)

    Command list:
    -clean / compile
    - escriptize
    - analyse / build_plt / ??_plt
    - test / int_test / perf_test
    - eunit / clean
    - install
    - preprocess ?
    - create / create-app / create-node

    Thank you for this tool :)


Leave a comment


No trackbacks yet.