2011-09-01 20:11:22 +00:00
#!/bin/bash
2009-10-01 04:36:05 +00:00
2013-08-11 15:28:47 +00:00
# The extension for executables.
exe = .exe
2009-10-01 04:36:05 +00:00
# some paths
2010-05-25 10:47:52 +00:00
top = /var/www/synthesis/eduke32
lockfile = $top /synthesis_building
source = eduke32
2009-10-01 06:31:22 +00:00
output = /var/www/dukeworld.duke4.net/eduke32/synthesis
2013-10-13 03:13:53 +00:00
make = ( make SYNTHESIS = 1 PLATFORM = WINDOWS CC = 'i686-w64-mingw32-gcc' CXX = 'i686-w64-mingw32-g++' AS = 'nasm' RC = 'i686-w64-mingw32-windres' STRIP = 'i686-w64-mingw32-strip' AR = 'i686-w64-mingw32-ar' RANLIB = 'i686-w64-mingw32-ranlib' PRETTY_OUTPUT = 0 NEDMALLOC = 0 )
2009-10-01 04:36:05 +00:00
clean = veryclean
2009-10-18 02:59:31 +00:00
2009-10-01 04:36:05 +00:00
# the following file paths are relative to $source
2013-08-11 15:28:47 +00:00
targets = ( eduke32$exe mapster32$exe )
2012-11-26 08:23:20 +00:00
package = package
2013-08-18 21:54:48 +00:00
not_src_packaged = ( $package /ebacktrace1.dll $package /ebacktrace1-64.dll )
2009-10-01 04:36:05 +00:00
2009-10-18 02:59:31 +00:00
# group that owns the resulting packages
group = dukeworld
2009-10-01 04:36:05 +00:00
# some variables
dobuild =
2010-05-25 10:47:52 +00:00
# controls resulting package filenames... will support linux later
basename = eduke32
platform = win32
2009-10-01 04:36:05 +00:00
# if the output dir doesn't exist, create it
if [ ! -e $output ]
then
mkdir -p $output
fi
2010-05-25 10:47:52 +00:00
if [ -f $lockfile ]
then
2013-08-11 15:28:40 +00:00
echo "Build already in progress!"
exit
2010-05-25 10:47:52 +00:00
else
touch $lockfile
fi
2009-10-01 04:36:05 +00:00
cd $top
2010-05-25 10:47:52 +00:00
# update the code repository and get the last revision number from SVN
2009-10-01 04:36:05 +00:00
head = ` svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
echo " HEAD is revision $head . "
2013-08-11 15:28:46 +00:00
headlog = ` svn log -r $head `
2009-10-01 04:36:05 +00:00
2011-07-21 23:45:12 +00:00
lastrevision = ` ls -A1 $output /????????-???? | tail -n1 | cut -d- -f2 | cut -d. -f1`
2009-10-01 04:36:05 +00:00
2013-08-04 20:37:50 +00:00
# If the log of HEAD contains DONT_BUILD, obey.
2013-08-11 15:28:46 +00:00
if [ -n " `echo $headlog | grep DONT_BUILD` " ] ; then
2013-08-04 20:37:50 +00:00
echo "HEAD requested to not build. Bailing out..."
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2013-08-04 20:37:50 +00:00
exit
fi
2009-10-01 04:36:05 +00:00
# if the output dir is empty, we build no matter what
if [ ! $lastrevision ]
then
echo "No builds yet."
dobuild = 1
else
echo " Last built revision is $lastrevision . "
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# if the last built revision is less than HEAD, we also build
if [ $lastrevision -lt $head ]
then
echo "Need a new build."
dobuild = 1
fi
fi
if [ $dobuild ]
then
echo "Launching a build..."
2010-10-19 04:39:54 +00:00
2009-10-01 06:31:22 +00:00
cd $top /$source
2010-10-19 04:39:54 +00:00
2011-03-04 09:29:54 +00:00
# throw the svn revision into a header. this is ugly.
2012-11-05 02:49:08 +00:00
echo " s_buildRev = \"r $head \"; " > source/rev.h
2011-07-21 23:45:12 +00:00
2010-10-19 04:39:54 +00:00
# clean the tree and build debug first
echo " ${ make [@] } " RELEASE = 0 $clean all
" ${ make [@] } " RELEASE = 0 $clean all
# make sure all the targets were produced
for i in " ${ targets [@] } " ; do
if [ ! -e $i ]
then
echo "Build failed! Bailing out..."
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2010-10-19 04:39:54 +00:00
exit
fi
done
2012-11-26 08:23:20 +00:00
# move the targets to $package
2013-08-11 15:28:47 +00:00
echo mv -f eduke32$exe " $package /eduke32.debug $exe "
mv -f eduke32$exe " $package /eduke32.debug $exe "
echo mv -f mapster32$exe " $package /mapster32.debug $exe "
mv -f mapster32$exe " $package /mapster32.debug $exe "
2010-10-19 04:39:54 +00:00
2013-08-18 19:24:27 +00:00
BUILD_LUNATIC = " `echo $headlog | grep BUILD_LUNATIC` "
if [ -n " $BUILD_LUNATIC " ] ; then
2013-08-04 20:37:50 +00:00
# clean the tree and build Lunatic (pre-)release next
2013-08-11 15:28:46 +00:00
echo " ${ make [@] } " LUNATIC = 1 $clean all
" ${ make [@] } " LUNATIC = 1 $clean all
2013-08-04 20:37:50 +00:00
# make sure all the targets were produced
for i in " ${ targets [@] } " ; do
if [ ! -e $i ]
then
echo "Build failed! Bailing out..."
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2013-08-04 20:37:50 +00:00
exit
fi
done
# move the targets to $package
2013-08-11 15:28:47 +00:00
echo mv -f eduke32$exe " $package /leduke32_PREVIEW $exe "
mv -f eduke32$exe " $package /leduke32_PREVIEW $exe "
2013-08-04 20:37:50 +00:00
fi
2010-10-19 04:39:54 +00:00
# clean the tree and build release
2010-05-25 10:47:52 +00:00
echo " ${ make [@] } " $clean all
" ${ make [@] } " $clean all
2010-10-19 04:39:54 +00:00
2009-10-01 04:36:05 +00:00
# make sure all the targets were produced
for i in " ${ targets [@] } " ; do
if [ ! -e $i ]
then
2010-05-25 10:47:52 +00:00
echo "Build failed! Bailing out..."
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2010-05-25 10:47:52 +00:00
exit
2009-10-01 04:36:05 +00:00
fi
done
2010-10-19 04:39:54 +00:00
2012-11-26 08:23:20 +00:00
# move the targets to $package
2013-08-11 15:28:47 +00:00
echo mv -f eduke32$exe " $package /eduke32 $exe "
mv -f eduke32$exe " $package /eduke32 $exe "
echo mv -f mapster32$exe " $package /mapster32 $exe "
mv -f mapster32$exe " $package /mapster32 $exe "
2011-10-02 07:47:18 +00:00
2009-10-01 04:36:05 +00:00
# get the date in the YYYYMMDD format (ex: 20091001)
date = ` date +%Y%m%d`
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# create the output directory
mkdir $output /$date -$head
2013-08-18 19:24:27 +00:00
2009-10-01 04:36:05 +00:00
# package the binary snapshot
2012-11-26 08:23:20 +00:00
cd $package
2013-08-18 19:24:27 +00:00
# Package some Lunatic test and demo files.
if [ -n " $BUILD_LUNATIC " ] ; then
mkdir -p lunatic/test
cp $top /$source /source/lunatic/test.lua lunatic
cp $top /$source /source/lunatic/test/test_{ bitar,geom,rotspr} .lua lunatic/test
cp $top /$source /source/lunatic/test/{ delmusicsfx,helixspawner} .lua lunatic/test
fi
2012-11-26 08:23:20 +00:00
echo zip -r -y -9 $output /$date -$head /${ basename } _${ platform } _$date -$head .zip * -x "*.svn*"
zip -r -y -9 $output /$date -$head /${ basename } _${ platform } _$date -$head .zip * -x "*.svn*"
2013-08-18 19:24:27 +00:00
# Remove the packaged Lunatic test/demo files.
if [ -n " $BUILD_LUNATIC " ] ; then
rm lunatic/test/*.lua lunatic/test.lua
rmdir lunatic/test
rmdir lunatic
fi
2012-11-26 08:23:20 +00:00
cd $top /$source
2011-07-21 23:45:12 +00:00
2009-10-01 04:36:05 +00:00
# hack to restore [e]obj/keep.me
echo svn update -r $head
svn update -r $head
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# export the source tree into the output directory
2010-05-25 11:26:09 +00:00
svn export . $output /$date -$head /${ basename } _$date -$head
echo svn export . $output /$date -$head /${ basename } _$date -$head
2010-05-25 10:47:52 +00:00
2009-10-01 04:36:05 +00:00
# package the source
cd $output /$date -$head
2010-05-25 10:47:52 +00:00
2009-10-01 06:31:22 +00:00
# first remove the unnecessary files
for i in " ${ not_src_packaged [@] } " ; do
2010-05-25 11:26:09 +00:00
echo rm -r ${ basename } _$date -$head /$i
rm -r ${ basename } _$date -$head /$i
2009-10-01 06:31:22 +00:00
done
2010-05-25 10:47:52 +00:00
2010-05-25 11:26:09 +00:00
echo tar cjf ${ basename } _src_$date -$head .tar.bz2 ${ basename } _$date -$head
tar cjf ${ basename } _src_$date -$head .tar.bz2 ${ basename } _$date -$head
rm -r ${ basename } _$date -$head
2012-11-26 08:23:20 +00:00
# clean up the revision header
cd $top /$source
echo svn revert "source/rev.h"
svn revert "source/rev.h"
2010-05-25 10:47:52 +00:00
2009-10-01 05:25:34 +00:00
# output the changelog since last snapshot in the output directory
2012-11-26 08:23:20 +00:00
if [ $lastrevision ]
2009-10-01 05:25:34 +00:00
then
2012-03-04 09:33:23 +00:00
# add one so that we only include what is new to this update
let lastrevision += 1
2009-10-01 05:33:49 +00:00
svn log -r $head :$lastrevision > $output /$date -$head /ChangeLog.txt
2009-10-01 05:25:34 +00:00
fi
2010-05-25 10:47:52 +00:00
# hack for our served directory structure... really belongs elsewhere,
# like in whatever script executes this one
2009-10-01 05:51:17 +00:00
chmod -R g+w $output /$date -$head
2009-10-18 02:59:31 +00:00
chown -R :$group $output /$date -$head
2010-05-25 10:47:52 +00:00
2011-07-21 23:45:12 +00:00
# link eduke32_latest.zip to the new archive
ln -sf $output /$date -$head /${ basename } _${ platform } _$date -$head .zip $output /eduke32_latest.zip
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2009-10-01 04:36:05 +00:00
else
echo "Nothing to do."
2013-08-11 15:28:40 +00:00
rm -f $lockfile
2009-10-18 02:59:31 +00:00
fi