Subversion Repositories eduke32

Rev

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

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