Subversion Repositories eduke32

Rev

Rev 4130 | Rev 4154 | 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
 
1940 plagman 50
lastrevision=`ls -A1 $output/????????-???? | 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/* ./
97
}
98
 
99
function package_debug ()
100
{
101
    cp -R $top/$source/package/debug/${*}/* ./
102
}
103
 
104
function package_game_lunatic ()
105
{
106
    # Package some Lunatic test and demo files.
107
    mkdir -p lunatic/test
108
    cp $top/$source/source/lunatic/test.lua lunatic
109
    cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua lunatic/test
110
    cp $top/$source/source/lunatic/test/{delmusicsfx,helixspawner}.lua lunatic/test
111
}
112
 
113
function package_sdk ()
114
{
115
    cp -R $top/$source/package/sdk/* ./
116
}
117
 
118
function package_execute ()
119
{
4131 hendricks2 120
    echo 7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
121
    7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
4130 hendricks2 122
 
123
    cd $top/$source
124
 
125
    rm -rf $package
126
}
127
 
1512 plagman 128
if [ $dobuild ]
129
then
130
    echo "Launching a build..."
1714 plagman 131
 
1518 plagman 132
    cd $top/$source
1714 plagman 133
 
1822 terminx 134
    # throw the svn revision into a header.  this is ugly.
3116 hendricks2 135
    echo "s_buildRev = \"r$head\";" > source/rev.h
1940 plagman 136
 
4130 hendricks2 137
    # get the date in the YYYYMMDD format (ex: 20091001)
138
    date=`date +%Y%m%d`
4098 hendricks2 139
 
4130 hendricks2 140
 
4098 hendricks2 141
    # 32-bit debug
142
 
143
    # clean the tree and build
1714 plagman 144
    echo "${make[@]}" RELEASE=0 $clean all
145
    "${make[@]}" RELEASE=0 $clean all
146
 
147
    # make sure all the targets were produced
4098 hendricks2 148
    verifytargets
1714 plagman 149
 
4130 hendricks2 150
    # package game
151
    package_start
152
    package_debug win32
4131 hendricks2 153
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
4130 hendricks2 154
    package_execute ${basename}_win32_debug
155
 
156
    # package sdk
157
    package_start
158
    package_debug win32
159
    package_sdk
4131 hendricks2 160
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
4130 hendricks2 161
    package_execute ${basename}-sdk_win32_debug
1714 plagman 162
 
4098 hendricks2 163
 
164
    # 64-bit debug
165
 
166
    # clean the tree and build
167
    echo "${make64[@]}" RELEASE=0 $clean all
168
    "${make64[@]}" RELEASE=0 $clean all
169
 
170
    # make sure all the targets were produced
171
    verifytargets
172
 
4130 hendricks2 173
    # package game
174
    package_start
175
    package_debug win64
4131 hendricks2 176
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
4130 hendricks2 177
    package_execute ${basename}_win64_debug
4098 hendricks2 178
 
4130 hendricks2 179
    # package sdk
180
    package_start
181
    package_debug win64
182
    package_sdk
4131 hendricks2 183
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
4130 hendricks2 184
    package_execute ${basename}-sdk_win64_debug
4098 hendricks2 185
 
4130 hendricks2 186
 
4098 hendricks2 187
    # 32-bit Lunatic (pre-)release
188
 
4022 helixhorne 189
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
190
 
191
    if [ -n "$BUILD_LUNATIC" ]; then
4098 hendricks2 192
        # clean the tree and build
4002 helixhorne 193
        echo "${make[@]}" LUNATIC=1 $clean all
194
        "${make[@]}" LUNATIC=1 $clean all
3978 helixhorne 195
 
196
        # make sure all the targets were produced
4098 hendricks2 197
        verifytargets
3978 helixhorne 198
 
4130 hendricks2 199
        # package game
200
        package_start
201
        package_game_lunatic
4131 hendricks2 202
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
4130 hendricks2 203
        package_execute l${basename}-lunatic-PREVIEW_win32
3978 helixhorne 204
    fi
205
 
4098 hendricks2 206
 
207
    # 32-bit release
208
 
209
    # clean the tree and build
1651 terminx 210
    echo "${make[@]}" $clean all
211
    "${make[@]}" $clean all
1714 plagman 212
 
1512 plagman 213
    # make sure all the targets were produced
4098 hendricks2 214
    verifytargets
1714 plagman 215
 
4130 hendricks2 216
    # package game
217
    package_start
4131 hendricks2 218
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
4130 hendricks2 219
    package_execute ${basename}_win32
220
 
221
    # package sdk
222
    package_start
223
    package_sdk
4131 hendricks2 224
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
4130 hendricks2 225
    package_execute ${basename}-sdk_win32
2062 hendricks2 226
 
4098 hendricks2 227
 
228
    # 64-bit release
229
 
230
    # clean the tree and build
231
    echo "${make64[@]}" $clean all
232
    "${make64[@]}" $clean all
233
 
234
    # make sure all the targets were produced
235
    verifytargets
236
 
4130 hendricks2 237
    # package game
238
    package_start
4131 hendricks2 239
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
4130 hendricks2 240
    package_execute ${basename}_win64
4098 hendricks2 241
 
4130 hendricks2 242
    # package sdk
243
    package_start
244
    package_sdk
4131 hendricks2 245
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
4130 hendricks2 246
    package_execute ${basename}-sdk_win64
4098 hendricks2 247
 
248
 
4130 hendricks2 249
    # clean up
4022 helixhorne 250
 
1512 plagman 251
    # hack to restore [e]obj/keep.me
252
    echo svn update -r $head
253
    svn update -r $head
4130 hendricks2 254
 
1512 plagman 255
    # export the source tree into the output directory
1654 terminx 256
    svn export . $output/$date-$head/${basename}_$date-$head
257
    echo svn export . $output/$date-$head/${basename}_$date-$head
4130 hendricks2 258
 
1512 plagman 259
    # package the source
260
    cd $output/$date-$head
4130 hendricks2 261
 
1518 plagman 262
    # first remove the unnecessary files
263
    for i in "${not_src_packaged[@]}"; do
1654 terminx 264
        echo rm -r ${basename}_$date-$head/$i
265
        rm -r ${basename}_$date-$head/$i
1518 plagman 266
    done
4130 hendricks2 267
 
4129 hendricks2 268
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
269
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
1654 terminx 270
    rm -r ${basename}_$date-$head
3235 hendricks2 271
 
272
    # clean up the revision header
273
    cd $top/$source
274
    echo svn revert "source/rev.h"
275
    svn revert "source/rev.h"
4130 hendricks2 276
 
1515 plagman 277
    # output the changelog since last snapshot in the output directory
3235 hendricks2 278
    if [ $lastrevision ]
1515 plagman 279
    then
2402 hendricks2 280
        # add one so that we only include what is new to this update
281
        let lastrevision+=1
1516 plagman 282
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
1515 plagman 283
    fi
4130 hendricks2 284
 
1651 terminx 285
    # hack for our served directory structure... really belongs elsewhere,
286
    # like in whatever script executes this one
1517 plagman 287
    chmod -R g+w $output/$date-$head
1535 terminx 288
    chown -R :$group $output/$date-$head
1651 terminx 289
 
4130 hendricks2 290
    # link eduke32_latest.zip to the new archive
291
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
1940 plagman 292
 
3999 helixhorne 293
    rm -f $lockfile
1512 plagman 294
else
295
    echo "Nothing to do."
3999 helixhorne 296
    rm -f $lockfile
1535 terminx 297
fi