Subversion Repositories eduke32

Rev

Rev 4115 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1999 plagman 1
#!/bin/bash
1512 plagman 2
 
4003 helixhorne 3
# The extension for executables.
4
exe=.exe
5
 
1512 plagman 6
# some paths
1651 terminx 7
top=/var/www/synthesis/eduke32
8
lockfile=$top/synthesis_building
9
source=eduke32
1518 plagman 10
output=/var/www/dukeworld.duke4.net/eduke32/synthesis
4115 Plagman 11
make=( make SYNTHESIS=1 PLATFORM=WINDOWS CROSS='i686-w64-mingw32-' CC='i686-w64-mingw32-gcc-4.8.0' AS='nasm' PRETTY_OUTPUT=0 )
12
make64=( make SYNTHESIS=1 PLATFORM=WINDOWS CROSS='x86_64-w64-mingw32-' CC='x86_64-w64-mingw32-gcc-4.8.0' AS='nasm' PRETTY_OUTPUT=0 )
1512 plagman 13
clean=veryclean
1535 terminx 14
 
1512 plagman 15
# the following file paths are relative to $source
4003 helixhorne 16
targets=( eduke32$exe mapster32$exe )
3235 hendricks2 17
package=package
4024 helixhorne 18
not_src_packaged=( $package/ebacktrace1.dll $package/ebacktrace1-64.dll )
1512 plagman 19
 
1535 terminx 20
# group that owns the resulting packages
21
group=dukeworld
1512 plagman 22
 
23
# some variables
24
dobuild=
25
 
1651 terminx 26
# controls resulting package filenames... will support linux later
27
basename=eduke32
28
platform=win32
29
 
1512 plagman 30
# if the output dir doesn't exist, create it
31
if [ ! -e $output ]
32
then
33
    mkdir -p $output
34
fi
35
 
1651 terminx 36
if [ -f $lockfile ]
37
then
3999 helixhorne 38
    echo "Build already in progress!"
39
    exit
1651 terminx 40
else
41
    touch $lockfile
42
fi
43
 
44
cd $top
45
 
1512 plagman 46
# update the code repository and get the last revision number from SVN
47
head=`svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
48
echo "HEAD is revision $head."
4002 helixhorne 49
headlog=`svn log -r $head`
1512 plagman 50
 
1940 plagman 51
lastrevision=`ls -A1 $output/????????-???? | tail -n1 | cut -d- -f2 | cut -d. -f1`
1512 plagman 52
 
3978 helixhorne 53
# If the log of HEAD contains DONT_BUILD, obey.
4002 helixhorne 54
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
3978 helixhorne 55
    echo "HEAD requested to not build. Bailing out..."
3999 helixhorne 56
    rm -f $lockfile
3978 helixhorne 57
    exit
58
fi
59
 
1512 plagman 60
# if the output dir is empty, we build no matter what
61
if [ ! $lastrevision ]
62
then
63
    echo "No builds yet."
64
    dobuild=1
65
else
66
    echo "Last built revision is $lastrevision."
1651 terminx 67
 
1512 plagman 68
    # if the last built revision is less than HEAD, we also build
69
    if [ $lastrevision -lt $head ]
70
    then
71
        echo "Need a new build."
72
        dobuild=1
73
    fi
74
fi
75
 
4098 hendricks2 76
function verifytargets ()
77
{
78
    for i in "${targets[@]}"; do
79
        if [ ! -e $i ]
80
        then
81
            echo "Build failed! Bailing out..."
82
            rm -f $lockfile
83
            exit
84
        fi
85
    done
86
}
87
 
1512 plagman 88
if [ $dobuild ]
89
then
90
    echo "Launching a build..."
1714 plagman 91
 
1518 plagman 92
    cd $top/$source
1714 plagman 93
 
1822 terminx 94
    # throw the svn revision into a header.  this is ugly.
3116 hendricks2 95
    echo "s_buildRev = \"r$head\";" > source/rev.h
1940 plagman 96
 
4098 hendricks2 97
 
98
    # 32-bit debug
99
 
100
    # clean the tree and build
1714 plagman 101
    echo "${make[@]}" RELEASE=0 $clean all
102
    "${make[@]}" RELEASE=0 $clean all
103
 
104
    # make sure all the targets were produced
4098 hendricks2 105
    verifytargets
1714 plagman 106
 
3235 hendricks2 107
    # move the targets to $package
4003 helixhorne 108
    echo mv -f eduke32$exe "$package/eduke32.debug$exe"
109
    mv -f eduke32$exe "$package/eduke32.debug$exe"
110
    echo mv -f mapster32$exe "$package/mapster32.debug$exe"
111
    mv -f mapster32$exe "$package/mapster32.debug$exe"
1714 plagman 112
 
4098 hendricks2 113
 
114
    # 64-bit debug
115
 
116
    # clean the tree and build
117
    echo "${make64[@]}" RELEASE=0 $clean all
118
    "${make64[@]}" RELEASE=0 $clean all
119
 
120
    # make sure all the targets were produced
121
    verifytargets
122
 
123
    # move the targets to $package
124
    echo mv -f eduke32$exe "$package/eduke64.debug$exe"
125
    mv -f eduke32$exe "$package/eduke64.debug$exe"
126
    echo mv -f mapster32$exe "$package/mapster64.debug$exe"
127
    mv -f mapster32$exe "$package/mapster64.debug$exe"
128
 
129
 
130
    # 32-bit Lunatic (pre-)release
131
 
4022 helixhorne 132
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
133
 
134
    if [ -n "$BUILD_LUNATIC" ]; then
4098 hendricks2 135
        # clean the tree and build
4002 helixhorne 136
        echo "${make[@]}" LUNATIC=1 $clean all
137
        "${make[@]}" LUNATIC=1 $clean all
3978 helixhorne 138
 
139
        # make sure all the targets were produced
4098 hendricks2 140
        verifytargets
3978 helixhorne 141
 
142
        # move the targets to $package
4003 helixhorne 143
        echo mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
144
        mv -f eduke32$exe "$package/leduke32_PREVIEW$exe"
3978 helixhorne 145
    fi
146
 
4098 hendricks2 147
 
148
    # 32-bit release
149
 
150
    # clean the tree and build
1651 terminx 151
    echo "${make[@]}" $clean all
152
    "${make[@]}" $clean all
1714 plagman 153
 
1512 plagman 154
    # make sure all the targets were produced
4098 hendricks2 155
    verifytargets
1714 plagman 156
 
3235 hendricks2 157
    # move the targets to $package
4003 helixhorne 158
    echo mv -f eduke32$exe "$package/eduke32$exe"
159
    mv -f eduke32$exe "$package/eduke32$exe"
160
    echo mv -f mapster32$exe "$package/mapster32$exe"
161
    mv -f mapster32$exe "$package/mapster32$exe"
2062 hendricks2 162
 
4098 hendricks2 163
 
164
    # 64-bit release
165
 
166
    # clean the tree and build
167
    echo "${make64[@]}" $clean all
168
    "${make64[@]}" $clean all
169
 
170
    # make sure all the targets were produced
171
    verifytargets
172
 
173
    # move the targets to $package
174
    echo mv -f eduke32$exe "$package/eduke64$exe"
175
    mv -f eduke32$exe "$package/eduke64$exe"
176
    echo mv -f mapster32$exe "$package/mapster64$exe"
177
    mv -f mapster32$exe "$package/mapster64$exe"
178
 
179
 
180
 
1512 plagman 181
    # get the date in the YYYYMMDD format (ex: 20091001)
182
    date=`date +%Y%m%d`
1651 terminx 183
 
1512 plagman 184
    # create the output directory
185
    mkdir $output/$date-$head
4022 helixhorne 186
 
1512 plagman 187
    # package the binary snapshot
3235 hendricks2 188
    cd $package
4022 helixhorne 189
 
190
    # Package some Lunatic test and demo files.
191
    if [ -n "$BUILD_LUNATIC" ]; then
192
        mkdir -p lunatic/test
193
        cp $top/$source/source/lunatic/test.lua lunatic
194
        cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua lunatic/test
195
        cp $top/$source/source/lunatic/test/{delmusicsfx,helixspawner}.lua lunatic/test
196
    fi
197
 
4129 hendricks2 198
    echo 7z a -mx9 -t7z $output/$date-$head/${basename}_${platform}_$date-$head.7z *
199
    7z a -mx9 -t7z $output/$date-$head/${basename}_${platform}_$date-$head.7z *
4022 helixhorne 200
 
201
    # Remove the packaged Lunatic test/demo files.
202
    if [ -n "$BUILD_LUNATIC" ]; then
203
        rm lunatic/test/*.lua lunatic/test.lua
204
        rmdir lunatic/test
205
        rmdir lunatic
206
    fi
207
 
3235 hendricks2 208
    cd $top/$source
1940 plagman 209
 
1512 plagman 210
    # hack to restore [e]obj/keep.me
211
    echo svn update -r $head
212
    svn update -r $head
1651 terminx 213
 
1512 plagman 214
    # export the source tree into the output directory
1654 terminx 215
    svn export . $output/$date-$head/${basename}_$date-$head
216
    echo svn export . $output/$date-$head/${basename}_$date-$head
1651 terminx 217
 
1512 plagman 218
    # package the source
219
    cd $output/$date-$head
1651 terminx 220
 
1518 plagman 221
    # first remove the unnecessary files
222
    for i in "${not_src_packaged[@]}"; do
1654 terminx 223
        echo rm -r ${basename}_$date-$head/$i
224
        rm -r ${basename}_$date-$head/$i
1518 plagman 225
    done
1651 terminx 226
 
4129 hendricks2 227
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
228
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
1654 terminx 229
    rm -r ${basename}_$date-$head
3235 hendricks2 230
 
231
    # clean up the revision header
232
    cd $top/$source
233
    echo svn revert "source/rev.h"
234
    svn revert "source/rev.h"
1651 terminx 235
 
1515 plagman 236
    # output the changelog since last snapshot in the output directory
3235 hendricks2 237
    if [ $lastrevision ]
1515 plagman 238
    then
2402 hendricks2 239
        # add one so that we only include what is new to this update
240
        let lastrevision+=1
1516 plagman 241
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 242
    fi
1651 terminx 243
 
244
    # hack for our served directory structure... really belongs elsewhere,
245
    # like in whatever script executes this one
1517 plagman 246
    chmod -R g+w $output/$date-$head
1535 terminx 247
    chown -R :$group $output/$date-$head
1651 terminx 248
 
1940 plagman 249
   # link eduke32_latest.zip to the new archive
4129 hendricks2 250
    ln -sf $output/$date-$head/${basename}_${platform}_$date-$head.7z $output/eduke32_latest.7z
1940 plagman 251
 
3999 helixhorne 252
    rm -f $lockfile
1512 plagman 253
else
254
    echo "Nothing to do."
3999 helixhorne 255
    rm -f $lockfile
1535 terminx 256
fi