Subversion Repositories eduke32

Rev

Rev 4323 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4323 Rev 4330
1
#!/bin/bash
1
#!/bin/bash
2
2
3
# The extension for executables.
3
# The extension for executables.
4
exe=.exe
4
exe=.exe
5
5
6
# some paths
6
# some paths
7
top=/var/www/synthesis/eduke32
7
top=/var/www/synthesis/eduke32
8
lockfile=$top/synthesis_building
8
lockfile=$top/synthesis_building
9
source=eduke32
9
source=eduke32
10
output=/var/www/dukeworld.duke4.net/eduke32/synthesis
10
output=/var/www/dukeworld.duke4.net/eduke32/synthesis
11
make=( make SYNTHESIS=1 PLATFORM=WINDOWS CROSS='i686-w64-mingw32-' CC='i686-w64-mingw32-gcc-4.8.0' AS='nasm' PRETTY_OUTPUT=0 )
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 )
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 )
13
clean=veryclean
13
clean=veryclean
14
14
15
# the following file paths are relative to $source
15
# the following file paths are relative to $source
16
targets=( eduke32$exe mapster32$exe )
16
targets=( eduke32$exe mapster32$exe )
17
package=$top/$source/package/package
17
package=$top/$source/package/package
18
not_src_packaged=( package/debug/win32/ebacktrace1.dll package/debug/win64/ebacktrace1-64.dll )
18
not_src_packaged=( package/debug/win32/ebacktrace1.dll package/debug/win64/ebacktrace1-64.dll )
19
19
20
# group that owns the resulting packages
20
# group that owns the resulting packages
21
group=dukeworld
21
group=dukeworld
22
22
23
# some variables
23
# some variables
24
dobuild=
24
dobuild=
25
25
26
# controls resulting package filenames... will support linux later
26
# controls resulting package filenames... will support linux later
27
basename=eduke32
27
basename=eduke32
28
28
29
# if the output dir doesn't exist, create it
29
# if the output dir doesn't exist, create it
30
if [ ! -e $output ]
30
if [ ! -e $output ]
31
then
31
then
32
    mkdir -p $output
32
    mkdir -p $output
33
fi
33
fi
34
34
35
if [ -f $lockfile ]
35
if [ -f $lockfile ]
36
then
36
then
37
    echo "Build already in progress!"
37
    echo "Build already in progress!"
38
    exit
38
    exit
39
else
39
else
40
    touch $lockfile
40
    touch $lockfile
41
fi
41
fi
42
42
43
cd $top
43
cd $top
44
44
45
# update the code repository and get the last revision number from SVN
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`
46
head=`svn update | tail -n1 | awk '{ print $NF }' | cut -d. -f1`
47
echo "HEAD is revision $head."
47
echo "HEAD is revision $head."
48
headlog=`svn log -r $head`
48
headlog=`svn log -r $head`
49
49
50
lastrevision=`ls -A1 $output/????????-???? | grep ${basename}_ - | tail -n1 | cut -d- -f2 | cut -d. -f1`
50
lastrevision=`ls -A1 $output/????????-???? | grep ${basename}_ - | tail -n1 | cut -d- -f2 | cut -d. -f1`
51
51
52
# If the log of HEAD contains DONT_BUILD, obey.
52
# If the log of HEAD contains DONT_BUILD, obey.
53
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
53
if [ -n "`echo $headlog | grep DONT_BUILD`" ]; then
54
    echo "HEAD requested to not build. Bailing out..."
54
    echo "HEAD requested to not build. Bailing out..."
55
    rm -f $lockfile
55
    rm -f $lockfile
56
    exit
56
    exit
57
fi
57
fi
58
58
59
# if the output dir is empty, we build no matter what
59
# if the output dir is empty, we build no matter what
60
if [ ! $lastrevision ]
60
if [ ! $lastrevision ]
61
then
61
then
62
    echo "No builds yet."
62
    echo "No builds yet."
63
    dobuild=1
63
    dobuild=1
64
else
64
else
65
    echo "Last built revision is $lastrevision."
65
    echo "Last built revision is $lastrevision."
66
66
67
    # if the last built revision is less than HEAD, we also build
67
    # if the last built revision is less than HEAD, we also build
68
    if [ $lastrevision -lt $head ]
68
    if [ $lastrevision -lt $head ]
69
    then
69
    then
70
        echo "Need a new build."
70
        echo "Need a new build."
71
        dobuild=1
71
        dobuild=1
72
    fi
72
    fi
73
fi
73
fi
74
74
75
function verifytargets ()
75
function verifytargets ()
76
{
76
{
77
    for i in "${targets[@]}"; do
77
    for i in "${targets[@]}"; do
78
        if [ ! -e $i ]
78
        if [ ! -e $i ]
79
        then
79
        then
80
            echo "Build failed! Bailing out..."
80
            echo "Build failed! Bailing out..."
81
            rm -f $lockfile
81
            rm -f $lockfile
82
            exit
82
            exit
83
        fi
83
        fi
84
    done
84
    done
85
85
86
    # create the output directory
86
    # create the output directory
87
    mkdir -p $output/$date-$head
87
    mkdir -p $output/$date-$head
88
}
88
}
89
89
90
function package_start ()
90
function package_start ()
91
{
91
{
92
    mkdir -p $package
92
    mkdir -p $package
93
93
94
    cd $package
94
    cd $package
95
95
96
    cp -R $top/$source/package/common/* ./
96
    cp -R $top/$source/package/common/* ./
97
}
97
}
98
98
99
function package_debug ()
99
function package_debug ()
100
{
100
{
101
    cp -R $top/$source/package/debug/${*}/* ./
101
    cp -R $top/$source/package/debug/${*}/* ./
102
}
102
}
103
103
104
function package_game_lunatic ()
104
function package_game_lunatic ()
105
{
105
{
106
    # Package some Lunatic test and demo files.
106
    # Package some Lunatic test and demo files.
107
    mkdir -p ./lunatic/test
107
    mkdir -p ./lunatic/test
108
    cp $top/$source/source/lunatic/test.lua ./lunatic/
108
    cp $top/$source/source/lunatic/test.lua ./lunatic/
109
    cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua ./lunatic/test/
109
    cp $top/$source/source/lunatic/test/test_{bitar,geom,rotspr}.lua ./lunatic/test/
110
    cp $top/$source/source/lunatic/test/{damagehplane,delmusicsfx,helixspawner,shadexfog}.lua ./lunatic/test/
110
    cp $top/$source/source/lunatic/test/{damagehplane,delmusicsfx,helixspawner,shadexfog}.lua ./lunatic/test/
111
}
111
}
112
112
113
function package_sdk ()
113
function package_sdk ()
114
{
114
{
115
    cp -R $top/$source/package/sdk/* ./
115
    cp -R $top/$source/package/sdk/* ./
116
}
116
}
117
117
118
function package_execute ()
118
function package_execute ()
119
{
119
{
120
    echo 7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
120
    echo 7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
121
    7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
121
    7zr a -mx9 -t7z $output/$date-$head/${*}_$date-$head.7z *
122
122
123
    cd $top/$source
123
    cd $top/$source
124
124
125
    rm -rf $package
125
    rm -rf $package
126
}
126
}
127
127
128
if [ $dobuild ]
128
if [ $dobuild ]
129
then
129
then
130
    echo "Launching a build..."
130
    echo "Launching a build..."
131
131
132
    cd $top/$source
132
    cd $top/$source
133
133
134
    # throw the svn revision into a header.  this is ugly.
134
    # throw the svn revision into a header.  this is ugly.
135
    echo "s_buildRev = \"r$head\";" > source/rev.h
135
    echo "s_buildRev = \"r$head\";" > source/rev.h
136
136
137
    # get the date in the YYYYMMDD format (ex: 20091001)
137
    # get the date in the YYYYMMDD format (ex: 20091001)
138
    date=`date +%Y%m%d`
138
    date=`date +%Y%m%d`
139
139
140
140
141
    # 32-bit debug
141
    # 32-bit debug
142
142
143
    # clean the tree and build
143
    # clean the tree and build
144
    echo "${make[@]}" RELEASE=0 $clean all
144
    echo "${make[@]}" RELEASE=0 $clean all
145
    "${make[@]}" RELEASE=0 $clean all
145
    "${make[@]}" RELEASE=0 $clean all
146
146
147
    # make sure all the targets were produced
147
    # make sure all the targets were produced
148
    verifytargets
148
    verifytargets
149
149
150
    # package game
150
    # package game
151
    package_start
151
    package_start
152
    package_debug win32
152
    package_debug win32
153
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
153
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
154
    package_execute ${basename}_win32_debug
154
    package_execute ${basename}_win32_debug
155
155
156
    # package sdk
156
    # package sdk
157
    package_start
157
    package_start
158
    package_debug win32
158
    package_debug win32
159
    package_sdk
159
    package_sdk
160
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
160
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
161
    package_execute ${basename}-sdk_win32_debug
161
    package_execute ${basename}-sdk_win32_debug
162
162
163
163
164
    # 64-bit debug
164
    # 64-bit debug
165
165
166
    # clean the tree and build
166
    # clean the tree and build
167
    echo "${make64[@]}" RELEASE=0 $clean all
167
    echo "${make64[@]}" RELEASE=0 $clean all
168
    "${make64[@]}" RELEASE=0 $clean all
168
    "${make64[@]}" RELEASE=0 $clean all
169
169
170
    # make sure all the targets were produced
170
    # make sure all the targets were produced
171
    verifytargets
171
    verifytargets
172
172
173
    # package game
173
    # package game
174
    package_start
174
    package_start
175
    package_debug win64
175
    package_debug win64
176
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
176
    mv -f $top/$source/eduke32$exe "$package/eduke32.debug$exe"
177
    package_execute ${basename}_win64_debug
177
    package_execute ${basename}_win64_debug
178
178
179
    # package sdk
179
    # package sdk
180
    package_start
180
    package_start
181
    package_debug win64
181
    package_debug win64
182
    package_sdk
182
    package_sdk
183
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
183
    mv -f $top/$source/mapster32$exe "$package/mapster32.debug$exe"
184
    package_execute ${basename}-sdk_win64_debug
184
    package_execute ${basename}-sdk_win64_debug
185
185
186
186
187
    # 32-bit Lunatic (pre-)release
187
    # 32-bit Lunatic (pre-)release
188
188
189
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
189
    BUILD_LUNATIC="`echo $headlog | grep BUILD_LUNATIC`"
190
190
191
    if [ -n "$BUILD_LUNATIC" ]; then
191
    if [ -n "$BUILD_LUNATIC" ]; then
192
        # clean the tree and build
192
        # clean the tree and build
193
        echo "${make[@]}" LUNATIC=1 $clean all
193
        echo "${make[@]}" LUNATIC=1 $clean all
194
        "${make[@]}" LUNATIC=1 $clean all
194
        "${make[@]}" LUNATIC=1 $clean all
195
195
196
        # make sure all the targets were produced
196
        # make sure all the targets were produced
197
        verifytargets
197
        verifytargets
198
198
199
        # package game
199
        # package game
200
        package_start
200
        package_start
201
        package_game_lunatic
201
        package_game_lunatic
202
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
202
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
-
 
203
        mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
203
        package_execute l${basename}_lunatic_PREVIEW_win32
204
        package_execute l${basename}_lunatic_PREVIEW_win32
204
    fi
205
    fi
205
206
206
207
207
    # 64-bit Lunatic (pre-)release
208
    # 64-bit Lunatic (pre-)release
208
209
209
    if [ -n "$BUILD_LUNATIC" ]; then
210
    if [ -n "$BUILD_LUNATIC" ]; then
210
        # clean the tree and build
211
        # clean the tree and build
211
        echo "${make64[@]}" LUNATIC=1 $clean all
212
        echo "${make64[@]}" LUNATIC=1 $clean all
212
        "${make64[@]}" LUNATIC=1 $clean all
213
        "${make64[@]}" LUNATIC=1 $clean all
213
214
214
        # make sure all the targets were produced
215
        # make sure all the targets were produced
215
        verifytargets
216
        verifytargets
216
217
217
        # package game
218
        # package game
218
        package_start
219
        package_start
219
        package_game_lunatic
220
        package_game_lunatic
220
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
221
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
-
 
222
        mv -f $top/$source/mapster32$exe "$package/lmapster32_PREVIEW$exe"
221
        package_execute l${basename}_lunatic_PREVIEW_win64
223
        package_execute l${basename}_lunatic_PREVIEW_win64
222
    fi
224
    fi
223
225
224
226
225
    # 32-bit release
227
    # 32-bit release
226
228
227
    # clean the tree and build
229
    # clean the tree and build
228
    echo "${make[@]}" $clean all
230
    echo "${make[@]}" $clean all
229
    "${make[@]}" $clean all
231
    "${make[@]}" $clean all
230
232
231
    # make sure all the targets were produced
233
    # make sure all the targets were produced
232
    verifytargets
234
    verifytargets
233
235
234
    # package game
236
    # package game
235
    package_start
237
    package_start
236
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
238
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
237
    package_execute ${basename}_win32
239
    package_execute ${basename}_win32
238
240
239
    # package sdk
241
    # package sdk
240
    package_start
242
    package_start
241
    package_sdk
243
    package_sdk
242
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
244
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
243
    package_execute ${basename}-sdk_win32
245
    package_execute ${basename}-sdk_win32
244
246
245
247
246
    # 64-bit release
248
    # 64-bit release
247
249
248
    # clean the tree and build
250
    # clean the tree and build
249
    echo "${make64[@]}" $clean all
251
    echo "${make64[@]}" $clean all
250
    "${make64[@]}" $clean all
252
    "${make64[@]}" $clean all
251
253
252
    # make sure all the targets were produced
254
    # make sure all the targets were produced
253
    verifytargets
255
    verifytargets
254
256
255
    # package game
257
    # package game
256
    package_start
258
    package_start
257
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
259
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
258
    package_execute ${basename}_win64
260
    package_execute ${basename}_win64
259
261
260
    # package sdk
262
    # package sdk
261
    package_start
263
    package_start
262
    package_sdk
264
    package_sdk
263
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
265
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
264
    package_execute ${basename}-sdk_win64
266
    package_execute ${basename}-sdk_win64
265
267
266
268
267
    # clean up
269
    # clean up
268
270
269
    # hack to restore [e]obj/keep.me
271
    # hack to restore [e]obj/keep.me
270
    echo svn update -r $head
272
    echo svn update -r $head
271
    svn update -r $head
273
    svn update -r $head
272
274
273
    # export the source tree into the output directory
275
    # export the source tree into the output directory
274
    svn export . $output/$date-$head/${basename}_$date-$head
276
    svn export . $output/$date-$head/${basename}_$date-$head
275
    echo svn export . $output/$date-$head/${basename}_$date-$head
277
    echo svn export . $output/$date-$head/${basename}_$date-$head
276
278
277
    # package the source
279
    # package the source
278
    cd $output/$date-$head
280
    cd $output/$date-$head
279
281
280
    # first remove the unnecessary files
282
    # first remove the unnecessary files
281
    for i in "${not_src_packaged[@]}"; do
283
    for i in "${not_src_packaged[@]}"; do
282
        echo rm -r ${basename}_$date-$head/$i
284
        echo rm -r ${basename}_$date-$head/$i
283
        rm -r ${basename}_$date-$head/$i
285
        rm -r ${basename}_$date-$head/$i
284
    done
286
    done
285
287
286
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
288
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
287
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
289
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
288
    rm -r ${basename}_$date-$head
290
    rm -r ${basename}_$date-$head
289
291
290
    # clean up the revision header
292
    # clean up the revision header
291
    cd $top/$source
293
    cd $top/$source
292
    echo svn revert "source/rev.h"
294
    echo svn revert "source/rev.h"
293
    svn revert "source/rev.h"
295
    svn revert "source/rev.h"
294
296
295
    # output the changelog since last snapshot in the output directory
297
    # output the changelog since last snapshot in the output directory
296
    if [ $lastrevision ]
298
    if [ $lastrevision ]
297
    then
299
    then
298
        # add one so that we only include what is new to this update
300
        # add one so that we only include what is new to this update
299
        let lastrevision+=1
301
        let lastrevision+=1
300
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
302
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
301
303
302
        echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
304
        echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
303
    fi
305
    fi
304
306
305
    # hack for our served directory structure... really belongs elsewhere,
307
    # hack for our served directory structure... really belongs elsewhere,
306
    # like in whatever script executes this one
308
    # like in whatever script executes this one
307
    chmod -R g+w $output/$date-$head
309
    chmod -R g+w $output/$date-$head
308
    chown -R :$group $output/$date-$head
310
    chown -R :$group $output/$date-$head
309
311
310
    # link eduke32_latest.zip to the new archive
312
    # link eduke32_latest.zip to the new archive
311
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
313
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
312
314
313
    rm -f $lockfile
315
    rm -f $lockfile
314
else
316
else
315
    echo "Nothing to do."
317
    echo "Nothing to do."
316
    rm -f $lockfile
318
    rm -f $lockfile
317
fi
319
fi
318
 
320