Subversion Repositories eduke32

Rev

Rev 4343 | Go to most recent revision | 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 )
4130 hendricks2 17
package=$top/$source/package/package
18
not_src_packaged=( package/debug/win32/ebacktrace1.dll package/debug/win64/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
 
1512 plagman 29
# if the output dir doesn't exist, create it
30
if [ ! -e $output ]
31
then
32
    mkdir -p $output
33
fi
34
 
1651 terminx 35
if [ -f $lockfile ]
36
then
3999 helixhorne 37
    echo "Build already in progress!"
38
    exit
1651 terminx 39
else
40
    touch $lockfile
41
fi
42
 
43
cd $top
44
 
1512 plagman 45
# update the code repository and get the last revision number from SVN
46
head=`svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
47
echo "HEAD is revision $head."
4002 helixhorne 48
headlog=`svn log -r $head`
1512 plagman 49
 
4158 hendricks2 50
lastrevision=`ls -A1 $output/????????-???? | grep ${basename}_ - | tail -n1 | cut -d- -f2 | cut -d. -f1`
1512 plagman 51
 
3978 helixhorne 52
# If the log of HEAD contains DONT_BUILD, obey.
4002 helixhorne 53
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
3978 helixhorne 54
    echo "HEAD requested to not build. Bailing out..."
3999 helixhorne 55
    rm -f $lockfile
3978 helixhorne 56
    exit
57
fi
58
 
1512 plagman 59
# if the output dir is empty, we build no matter what
60
if [ ! $lastrevision ]
61
then
62
    echo "No builds yet."
63
    dobuild=1
64
else
65
    echo "Last built revision is $lastrevision."
4130 hendricks2 66
 
1512 plagman 67
    # if the last built revision is less than HEAD, we also build
68
    if [ $lastrevision -lt $head ]
69
    then
70
        echo "Need a new build."
71
        dobuild=1
72
    fi
73
fi
74
 
4098 hendricks2 75
function verifytargets ()
76
{
77
    for i in "${targets[@]}"; do
78
        if [ ! -e $i ]
79
        then
80
            echo "Build failed! Bailing out..."
81
            rm -f $lockfile
82
            exit
83
        fi
84
    done
4130 hendricks2 85
 
86
    # create the output directory
87
    mkdir -p $output/$date-$head
4098 hendricks2 88
}
89
 
4130 hendricks2 90
function package_start ()
91
{
92
    mkdir -p $package
93
 
94
    cd $package
95
 
96
    cp -R $top/$source/package/common/* ./
4342 hendricks2 97
    cp -R $top/$source/package/sdk/* ./
4130 hendricks2 98
}
99
 
100
function package_debug ()
101
{
102
    cp -R $top/$source/package/debug/${*}/* ./
103
}
104
 
105
function package_game_lunatic ()
106
{
107
    # Package some Lunatic test and demo files.
4154 hendricks2 108
    mkdir -p ./lunatic/test
109
    cp $top/$source/source/lunatic/test.lua ./lunatic/
110
    cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua ./lunatic/test/
4240 helixhorne 111
    cp $top/$source/source/lunatic/test/{damagehplane,delmusicsfx,helixspawner,shadexfog}.lua ./lunatic/test/
4130 hendricks2 112
}
113
 
114
function package_execute ()
115
{
4131 hendricks2 116
    echo 7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
117
    7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
4130 hendricks2 118
 
119
    cd $top/$source
120
 
121
    rm -rf $package
122
}
123
 
1512 plagman 124
if [ $dobuild ]
125
then
126
    echo "Launching a build..."
1714 plagman 127
 
1518 plagman 128
    cd $top/$source
1714 plagman 129
 
4130 hendricks2 130
    # get the date in the YYYYMMDD format (ex: 20091001)
131
    date=`date +%Y%m%d`
4098 hendricks2 132
 
4130 hendricks2 133
 
4098 hendricks2 134
    # 32-bit debug
135
 
136
    # clean the tree and build
1714 plagman 137
    echo "${make[@]}" RELEASE=0 $clean all
138
    "${make[@]}" RELEASE=0 $clean all
139
 
140
    # make sure all the targets were produced
4098 hendricks2 141
    verifytargets
1714 plagman 142
 
4342 hendricks2 143
    # package
4130 hendricks2 144
    package_start
145
    package_debug win32
4131 hendricks2 146
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
4342 hendricks2 147
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
4130 hendricks2 148
    package_execute ${basename}_win32_debug
149
 
1714 plagman 150
 
4098 hendricks2 151
    # 64-bit debug
152
 
153
    # clean the tree and build
154
    echo "${make64[@]}" RELEASE=0 $clean all
155
    "${make64[@]}" RELEASE=0 $clean all
156
 
157
    # make sure all the targets were produced
158
    verifytargets
159
 
4342 hendricks2 160
    # package
4130 hendricks2 161
    package_start
162
    package_debug win64
4131 hendricks2 163
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
4342 hendricks2 164
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
4130 hendricks2 165
    package_execute ${basename}_win64_debug
4098 hendricks2 166
 
167
 
168
    # 32-bit Lunatic (pre-)release
169
 
4022 helixhorne 170
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
171
 
172
    if [ -n "$BUILD_LUNATIC" ]; then
4098 hendricks2 173
        # clean the tree and build
4002 helixhorne 174
        echo "${make[@]}" LUNATIC=1 $clean all
175
        "${make[@]}" LUNATIC=1 $clean all
3978 helixhorne 176
 
177
        # make sure all the targets were produced
4098 hendricks2 178
        verifytargets
3978 helixhorne 179
 
4342 hendricks2 180
        # package
4130 hendricks2 181
        package_start
182
        package_game_lunatic
4131 hendricks2 183
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
4330 helixhorne 184
        mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
4157 hendricks2 185
        package_execute l${basename}_lunatic_PREVIEW_win32
3978 helixhorne 186
    fi
187
 
4098 hendricks2 188
 
4323 hendricks2 189
    # 64-bit Lunatic (pre-)release
190
 
191
    if [ -n "$BUILD_LUNATIC" ]; then
192
        # clean the tree and build
5029 helixhorne 193
        echo "${make64[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
194
        "${make64[@]}" LUNATIC=1 CPLUSPLUS=0 $clean all
4323 hendricks2 195
 
196
        # make sure all the targets were produced
197
        verifytargets
198
 
4342 hendricks2 199
        # package
4323 hendricks2 200
        package_start
201
        package_game_lunatic
202
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
4330 helixhorne 203
        mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
4323 hendricks2 204
        package_execute l${basename}_lunatic_PREVIEW_win64
205
    fi
206
 
207
 
4098 hendricks2 208
    # 32-bit release
209
 
210
    # clean the tree and build
1651 terminx 211
    echo "${make[@]}" $clean all
212
    "${make[@]}" $clean all
1714 plagman 213
 
1512 plagman 214
    # make sure all the targets were produced
4098 hendricks2 215
    verifytargets
1714 plagman 216
 
4342 hendricks2 217
    # package
4130 hendricks2 218
    package_start
4131 hendricks2 219
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
4342 hendricks2 220
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
4130 hendricks2 221
    package_execute ${basename}_win32
222
 
2062 hendricks2 223
 
4098 hendricks2 224
    # 64-bit release
225
 
226
    # clean the tree and build
227
    echo "${make64[@]}" $clean all
228
    "${make64[@]}" $clean all
229
 
230
    # make sure all the targets were produced
231
    verifytargets
232
 
4342 hendricks2 233
    # package
4130 hendricks2 234
    package_start
4131 hendricks2 235
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
4342 hendricks2 236
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
4130 hendricks2 237
    package_execute ${basename}_win64
4098 hendricks2 238
 
239
 
4130 hendricks2 240
    # clean up
4022 helixhorne 241
 
1512 plagman 242
    # hack to restore [e]obj/keep.me
243
    echo svn update -r $head
244
    svn update -r $head
4130 hendricks2 245
 
4343 hendricks2 246
    # throw the svn revision into a header.
247
    echo "s_buildRev = \"r$head\";" > source/rev.h
248
 
1512 plagman 249
    # export the source tree into the output directory
1654 terminx 250
    svn export . $output/$date-$head/${basename}_$date-$head
251
    echo svn export . $output/$date-$head/${basename}_$date-$head
4130 hendricks2 252
 
1512 plagman 253
    # package the source
254
    cd $output/$date-$head
4130 hendricks2 255
 
1518 plagman 256
    # first remove the unnecessary files
257
    for i in "${not_src_packaged[@]}"; do
1654 terminx 258
        echo rm -r ${basename}_$date-$head/$i
259
        rm -r ${basename}_$date-$head/$i
1518 plagman 260
    done
4130 hendricks2 261
 
4129 hendricks2 262
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
263
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
1654 terminx 264
    rm -r ${basename}_$date-$head
3235 hendricks2 265
 
266
    # clean up the revision header
267
    cd $top/$source
268
    echo svn revert "source/rev.h"
269
    svn revert "source/rev.h"
4130 hendricks2 270
 
1515 plagman 271
    # output the changelog since last snapshot in the output directory
3235 hendricks2 272
    if [ $lastrevision ]
1515 plagman 273
    then
2402 hendricks2 274
        # add one so that we only include what is new to this update
275
        let lastrevision+=1
1516 plagman 276
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
4159 hendricks2 277
 
278
        echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
1515 plagman 279
    fi
4130 hendricks2 280
 
1651 terminx 281
    # hack for our served directory structure... really belongs elsewhere,
282
    # like in whatever script executes this one
1517 plagman 283
    chmod -R g+w $output/$date-$head
1535 terminx 284
    chown -R :$group $output/$date-$head
1651 terminx 285
 
4130 hendricks2 286
    # link eduke32_latest.zip to the new archive
287
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
1940 plagman 288
 
3999 helixhorne 289
    rm -f $lockfile
1512 plagman 290
else
291
    echo "Nothing to do."
3999 helixhorne 292
    rm -f $lockfile
1535 terminx 293
fi