Subversion Repositories eduke32

Rev

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

Rev 4240 Rev 4323
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
        package_execute l${basename}_lunatic_PREVIEW_win32
203
        package_execute l${basename}_lunatic_PREVIEW_win32
204
    fi
204
    fi
205
205
206
206
-
 
207
    # 64-bit Lunatic (pre-)release
-
 
208
-
 
209
    if [ -n "$BUILD_LUNATIC" ]; then
-
 
210
        # clean the tree and build
-
 
211
        echo "${make64[@]}" LUNATIC=1 $clean all
-
 
212
        "${make64[@]}" LUNATIC=1 $clean all
-
 
213
-
 
214
        # make sure all the targets were produced
-
 
215
        verifytargets
-
 
216
-
 
217
        # package game
-
 
218
        package_start
-
 
219
        package_game_lunatic
-
 
220
        mv -f $top/$source/eduke32$exe "$package/leduke32_PREVIEW$exe"
-
 
221
        package_execute l${basename}_lunatic_PREVIEW_win64
-
 
222
    fi
-
 
223
-
 
224
207
    # 32-bit release
225
    # 32-bit release
208
226
209
    # clean the tree and build
227
    # clean the tree and build
210
    echo "${make[@]}" $clean all
228
    echo "${make[@]}" $clean all
211
    "${make[@]}" $clean all
229
    "${make[@]}" $clean all
212
230
213
    # make sure all the targets were produced
231
    # make sure all the targets were produced
214
    verifytargets
232
    verifytargets
215
233
216
    # package game
234
    # package game
217
    package_start
235
    package_start
218
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
236
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
219
    package_execute ${basename}_win32
237
    package_execute ${basename}_win32
220
238
221
    # package sdk
239
    # package sdk
222
    package_start
240
    package_start
223
    package_sdk
241
    package_sdk
224
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
242
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
225
    package_execute ${basename}-sdk_win32
243
    package_execute ${basename}-sdk_win32
226
244
227
245
228
    # 64-bit release
246
    # 64-bit release
229
247
230
    # clean the tree and build
248
    # clean the tree and build
231
    echo "${make64[@]}" $clean all
249
    echo "${make64[@]}" $clean all
232
    "${make64[@]}" $clean all
250
    "${make64[@]}" $clean all
233
251
234
    # make sure all the targets were produced
252
    # make sure all the targets were produced
235
    verifytargets
253
    verifytargets
236
254
237
    # package game
255
    # package game
238
    package_start
256
    package_start
239
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
257
    mv -f $top/$source/eduke32$exe "$package/eduke32$exe"
240
    package_execute ${basename}_win64
258
    package_execute ${basename}_win64
241
259
242
    # package sdk
260
    # package sdk
243
    package_start
261
    package_start
244
    package_sdk
262
    package_sdk
245
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
263
    mv -f $top/$source/mapster32$exe "$package/mapster32$exe"
246
    package_execute ${basename}-sdk_win64
264
    package_execute ${basename}-sdk_win64
247
265
248
266
249
    # clean up
267
    # clean up
250
268
251
    # hack to restore [e]obj/keep.me
269
    # hack to restore [e]obj/keep.me
252
    echo svn update -r $head
270
    echo svn update -r $head
253
    svn update -r $head
271
    svn update -r $head
254
272
255
    # export the source tree into the output directory
273
    # export the source tree into the output directory
256
    svn export . $output/$date-$head/${basename}_$date-$head
274
    svn export . $output/$date-$head/${basename}_$date-$head
257
    echo svn export . $output/$date-$head/${basename}_$date-$head
275
    echo svn export . $output/$date-$head/${basename}_$date-$head
258
276
259
    # package the source
277
    # package the source
260
    cd $output/$date-$head
278
    cd $output/$date-$head
261
279
262
    # first remove the unnecessary files
280
    # first remove the unnecessary files
263
    for i in "${not_src_packaged[@]}"; do
281
    for i in "${not_src_packaged[@]}"; do
264
        echo rm -r ${basename}_$date-$head/$i
282
        echo rm -r ${basename}_$date-$head/$i
265
        rm -r ${basename}_$date-$head/$i
283
        rm -r ${basename}_$date-$head/$i
266
    done
284
    done
267
285
268
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
286
    echo tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
269
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
287
    tar cJf ${basename}_src_$date-$head.tar.xz ${basename}_$date-$head
270
    rm -r ${basename}_$date-$head
288
    rm -r ${basename}_$date-$head
271
289
272
    # clean up the revision header
290
    # clean up the revision header
273
    cd $top/$source
291
    cd $top/$source
274
    echo svn revert "source/rev.h"
292
    echo svn revert "source/rev.h"
275
    svn revert "source/rev.h"
293
    svn revert "source/rev.h"
276
294
277
    # output the changelog since last snapshot in the output directory
295
    # output the changelog since last snapshot in the output directory
278
    if [ $lastrevision ]
296
    if [ $lastrevision ]
279
    then
297
    then
280
        # add one so that we only include what is new to this update
298
        # add one so that we only include what is new to this update
281
        let lastrevision+=1
299
        let lastrevision+=1
282
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
300
        svn log -r $head:$lastrevision > $output/$date-$head/ChangeLog.txt
283
301
284
        echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
302
        echo "See http://svn.eduke32.com/listing.php?repname=eduke32 for more details." >> $output/$date-$head/ChangeLog.txt
285
    fi
303
    fi
286
304
287
    # hack for our served directory structure... really belongs elsewhere,
305
    # hack for our served directory structure... really belongs elsewhere,
288
    # like in whatever script executes this one
306
    # like in whatever script executes this one
289
    chmod -R g+w $output/$date-$head
307
    chmod -R g+w $output/$date-$head
290
    chown -R :$group $output/$date-$head
308
    chown -R :$group $output/$date-$head
291
309
292
    # link eduke32_latest.zip to the new archive
310
    # link eduke32_latest.zip to the new archive
293
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
311
    ln -sf $output/$date-$head/${basename}_win32_$date-$head.7z $output/eduke32_latest.7z
294
312
295
    rm -f $lockfile
313
    rm -f $lockfile
296
else
314
else
297
    echo "Nothing to do."
315
    echo "Nothing to do."
298
    rm -f $lockfile
316
    rm -f $lockfile
299
fi
317
fi
300
 
318