Skip to content

Instantly share code, notes, and snippets.

@volpe28v
Created June 14, 2012 07:20
Show Gist options
  • Save volpe28v/2928675 to your computer and use it in GitHub Desktop.
Save volpe28v/2928675 to your computer and use it in GitHub Desktop.
コンパイル自動化スクリプト
#!/bin/bash
##########################################################################
# 以下のコマンドで inotify-tools をインストールしてください
# $ sudo apt-get install inotify-tools
# or
# yum install inotify-tools
#
# Growl へ通知する場合は以下をインストールしてください
# $ sudo apt-get install rubygems1.8
# $ sudo gem install ruby-growl
# growl へのパスを通す。例)/var/lib/gems/1.8/bin/
##########################################################################
make_command = 'make'
ip_addr = 'XX'
growl_title = 'title'
growl_password = 'xxx'
target_files_or_dir="./"
if [ $# -ne 0 ]; then
target_files_or_dir=$@
fi
while inotifywait -e MODIFY --exclude '\.swp' $target_files_or_dir || true; do
$make_command &> /tmp/mm_log
build_result=$?
grep warning /tmp/mm_log > /tmp/w_log; w_cnt=`wc -l /tmp/w_log | cut -d' ' -f1 `
grep error /tmp/mm_log > /tmp/e_log; e_cnt=`wc -l /tmp/e_log | cut -d' ' -f1 `
echo " ----- building... -----"
cat /tmp/w_log
cat /tmp/e_log
echo " ----- done ------------"
# for growl
[ $build_result = 0 ] && result_msg="OK" || result_msg="!!!!! NG NG NG !!!!!"
growl -H $ip_addr -t $growl_title -m "Build - $result_msg warning($w_cnt) error($e_cnt)" -P $growl_password
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment