Tuesday, July 22, 2008

Autobuilding (Erlang) using inotifywait

Quick hack of the day:

#!/bin/bash

ERLC="erlc -W +debug_info"
inotifywait -m -e close_write *.erl | while read f; do
file=$(echo "$f" | cut -d' ' -f1)
cmd="$ERLC $file"
clear
date
echo $cmd
$cmd && echo "Success."
done

Requires a fairly modern Linux kernel (2.6.13-ish). Run the script in a terminal, and it will automatically compile any Erlang sources as soon as you save them, and display the error messages in the terminal window. (Replace ERLC with compilation command of your choice.)

2 comments:

Ernan said...

Hi

I get an error:

Setting up watches.
Couldn't watch *.erl: No such file or directory

Unknown said...

That's because you don't have any *.erl files.