Tuesday, July 22, 2008

Autobuilding (Erlang) using inotifywait

Quick hack of the day:


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

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