#!/bin/bash -v

svn_url=file:///home/ben88/svn/frogatto/trunk
#svn up svn
rev=`perl -e 'print (\`svn info $ARGV[0]\` =~ /Revision: (\\d+)/);' $svn_url`
bp="win_builds" #builds path
local=""
while getopts ":r:v:l" flag
do
	case $flag in
		r) rev=$OPTARG;;
		v) version=$OPTARG;;
		l) local=1;;
	esac
done
if [ -z $version ];
then
	version=r$rev
fi

cp -R -p 'win_template' "$bp/Frogatto $version"
if [ -z $local ]
then
	rsync -avzP ben@64.201.60.211:~/projects/frogatto/Windows/Frogatto.exe "$bp/Frogatto $version/"
else
	cp Frogatto.exe "$bp/Frogatto $version/"
fi

#cp -R -p svn/*.cfg svn/*.ttf "$bp/Frogatto $version/"
for dir in data locale images music sounds FreeMono.ttf DejaVuSans.ttf
do
	svn export $svn_url/$dir "$bp/Frogatto $version/$dir"
done;
cd "$bp"; zip -r "../../files/Frogatto_${version}_Win.zip" "Frogatto $version/"
rm -rf ../win_builds/*

