I'm repurposing this neglected blog to act as a record of my journey into game development.

Wednesday, September 26, 2007

Building Erlang with Rake

I've recently started using Erlang on a project. This is my first foray into Erlang and I'm using Joe Armstong's new book Programming Erlang as introductory material. It is a great introduction to the language, although I wish it covered more of the OTP. I suppose there is the OTP Design Principles guide but sometimes a good paper book written in conversational style is better when you are learning.

In the book Joe describes building an Erlang project using make and most of the downloadable bits of Erlang code use make too; this makes sense, make is virtually ubiquitous. However the other components of this project are Ruby on Rails applications and make heavy use of Rake, so I figure why subject myself to Make when I can use the beautiful Rake.

This gives you rake compile which builds all the .erl files in the src subdirectory into the .beam files in the ebin directory. Files will only be built if they have changes since the last build. You also get rake clean which deletes all the .beam files from the ebin directory.

I much prefer this over the equivalent Makefile and it is much easier to extend since you have the full power of Ruby at your disposal.

I have also used Rake with erlang.Here is what I came up with when I need to rebuild eunit.========================require 'rake/clean'CLOBBER.include 'ebin'SRC_TO_BIN = [/src(\/.*\.)erl/,'ebin\1beam']BIN_TO_SRC = [/ebin(\/.*\.)beam/,'src\1erl']