-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild2.sh
executable file
·496 lines (408 loc) · 12.6 KB
/
build2.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
#!/bin/bash
#
# Script to produce an autobuild
stage=""
echo "#########################################################################"
echo
echo "Build starting"
echo
echo "#########################################################################"
function check_result
{
ret=$?
if [ $ret != 0 ]; then
echo "*************************************************************************"
echo
echo
echo "Build failed, stage= " $stage
echo
echo "*************************************************************************"
exit 1
fi
}
function onexit
{
result=$?
cd $cwd/kits
if [ $result == 0 ]; then
if [ -f z88dk-$date-$revision.tgz ]; then
ln -s z88dk-$date-$revision.tgz z88dk-latest.tgz
fi
if [ -f z88dk-win32-$date-$revision.zip ]; then
ln -s z88dk-win32-$date-$revision.zip z88dk-win32-latest.zip
fi
if [ -f z88dk-osx-$date-$revision.zip ]; then
ln -s z88dk-osx-$date-$revision.zip z88dk-osx-latest.zip
fi
if [ -f z88dk-atari-mint-$date-$revision.zip ]; then
ln -s z88dk-atari-mint-$date-$revision.zip z88dk-atari-mint-latest.zip
fi
fi
echo "#########################################################################"
echo
echo "Deploying kits to nightly area"
echo
echo "#########################################################################"
ls -l
rsync -rl z88dk* $PUBLIC_DIRECTORY/
}
cwd=`pwd`
date=`date +%Y%m%d`
PERL5LIB=/home/build/perl5/lib/perl5
export PERL5LIB
PATH=/home/build/perl5/bin:$PATH
export PATH
trap "onexit" EXIT
mkdir -p kits
rm -fr kits/*
# Create a cvs tarball
echo "#########################################################################"
echo
echo "Updating from guest git"
echo
echo "#########################################################################"
stage="Git update"
cd z88dk
git fetch
check_result
git pull
check_result
git submodule update --init --recursive
check_result
stage="Encoding version"
rm -f src/config.h
make src/config.h
check_result
hash=`git rev-parse --short HEAD`
check_result
count=`git rev-list --count HEAD`
check_result
revision="$hash-$count"
echo "#########################################################################"
echo
echo "Creating src tarball"
echo
echo "#########################################################################"
stage="Tarball creation"
cd $cwd
tar czf kits/z88dk-src-$date-$revision.tgz --exclude-vcs z88dk
check_result
echo "#########################################################################"
echo
echo "Starting native build"
echo
echo "#########################################################################"
stage="Native build"
# Create a build of libraries
rm -fr build
mkdir -p build
tar xzf kits/z88dk-src-$date-$revision.tgz -C build
check_result
cd build/z88dk
check_result
export CFLAGS="-g -O2"
export CXX_FLAGS=""
export CXXFLAGS=""
export LDFLAGS=$CFLAGS
export CC=gcc
export ZCCCFG=`pwd`/lib/config/
export Z80_OZFILES=`pwd`/lib/
export PATH=`pwd`/bin:$PATH
./build.sh
check_result
make -C libsrc/_DEVELOPMENT install-clean
check_result
# Back to where we where
cd $cwd
echo "#########################################################################"
echo
echo "Creating tarball with libraries"
echo
echo "#########################################################################"
stage="Tarball with libraries"
rm -fr build_with_libs
mkdir -p build_with_libs
tar xzf kits/z88dk-src-$date-$revision.tgz -C build_with_libs
stage="Copying libraries into tarball with libraries"
cd build_with_libs/z88dk
rsync -a ../../build/z88dk/lib/clibs/ lib/clibs
check_result
cp ../../build/z88dk/src/z80asm/z88dk-z80asm.lib lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sccz80 libsrc/_DEVELOPMENT/lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sdcc* libsrc/_DEVELOPMENT/lib/
check_result
rsync -a ../../build/z88dk/include/ include/
check_result
rsync -a ../../build/z88dk/libsrc/_DEVELOPMENT/target/ libsrc/_DEVELOPMENT/target/
check_result
stage="Creating tarball with libraries"
cd $cwd
cd build_with_libs
tar czf ../kits/z88dk-$date-$revision.tgz z88dk
check_result
cd $cwd
echo "#########################################################################"
echo
echo "Starting atari-mint build"
echo
echo "#########################################################################"
rm -fr mint
mkdir -p mint
stage="Atari Mint build"
# Extract the fresh tarball
tar xzf kits/z88dk-src-$date-$revision.tgz -C mint
check_result
# Build some mint binaries
stage="Build Mint binaries"
# Set some required variables
export CFLAGS="-O2 -fomit-frame-pointer -m68020-60"
export CXX_FLAGS="-O2 -fomit-frame-pointer -m68020-60"
export CXXFLAGS=$CXX_FLAGS
export LDFLAGS="-g -O2"
export CC="m68k-atari-mint-gcc"
export CXX="m68k-atari-mint-g++"
export PREFIX="/usr/local/"
export EXESUFFIX=""
export CROSS=1
export PKG_CONFIG_PATH=/usr/m68k-atari-mint/sys-root/usr/lib/pkgconfig/
cp build/z88dk/lib/z88dk-z80asm.lib mint/z88dk/src/z80asm/dev/z80asm_lib/
check_result
# And build
cd mint/z88dk
check_result
make
check_result
# Remove intermediates
stage="Cleaning intermediate files"
make bins-clean
check_result
stage="Copying sdcc into mint kit"
cp bin/mint/* mint/z88dk/bin/
#check_result
# Copy dependencies
# Copy libs
stage="Copying libraries into mint kit"
cp ../../build/z88dk/lib/clibs/*.lib lib/clibs
check_result
cp ../../build/z88dk/src/z80asm/z88dk-z80asm.lib lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sccz80 libsrc/_DEVELOPMENT/lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sdcc* libsrc/_DEVELOPMENT/lib/
check_result
rsync -a ../../build/z88dk/include/ include/
check_result
rsync -a ../../build/z88dk/libsrc/_DEVELOPMENT/target/ libsrc/_DEVELOPMENT/target/
check_result
cd ..
check_result
echo "#########################################################################"
echo
echo "Building mint kit"
echo
echo "#########################################################################"
stage="mint zip"
zip -qr9 ../kits/z88dk-atari-mint-$date-$revision.zip z88dk
# Back to where we where
cd $cwd
# Now create a mingw build
echo "#########################################################################"
echo
echo "Starting win32 build"
echo
echo "#########################################################################"
rm -fr win32
mkdir -p win32
stage="Win32 build"
# Extract the fresh tarball
tar xzf kits/z88dk-src-$date-$revision.tgz -C win32
check_result
# Copying sdcc
stage="Copying sdcc + libs into win32 kit"
cp bin/win32/* win32/z88dk/bin/
check_result
# Build some mingw binaries
stage="Build windows binaries"
# Set some required variables
export CFLAGS="-g -O2"
export CC="x86_64-w64-mingw32-gcc"
export CXX="x86_64-w64-mingw32-g++"
export CXX_FLAGS=""
export CXXFLAGS=""
export LDFLAGS="-static"
export PREFIX="c:/z88dk/"
export CROSS=1
export EXESUFFIX=".exe"
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig/
export XML2CONFIG=/usr/x86_64-w64-mingw32/bin/xml2-config
echo "#undef PREFIX" >> win32/z88dk/src/config.h
echo "#define PREFIX \"$PREFIX\"" >> win32/z88dk/src/config.h
cp build/z88dk/src/z80asm/z88dk-z80asm.lib win32/z88dk/src/z80asm/dev/z80asm_lib
check_result
# And build
cd win32/z88dk
check_result
touch bin/zsdcc.exe
make
check_result
sed -i "s/COPYCMD.*/COPYCMD\t\tcopy/g" lib/config/*.cfg
sed -i s,/,\\\\,g lib/config/*.cfg
check_result
# Remove intermediates
stage="Cleaning intermediate files"
make bins-clean
check_result
stage="Build i686 windows binaries"
cp ../../build/z88dk/src/z80asm/z88dk-z80asm.lib src/z80asm/dev/z80asm_lib
check_result
# Now, build the i686 versions
mv bin bin.x86-64
mkdir bin
export CFLAGS="-g -O2"
export CC="i686-w64-mingw32-gcc"
export CXX="i686-w64-mingw32-g++"
export CXX_FLAGS=""
export CXXFLAGS=""
export LDFLAGS="-static"
export PREFIX="c:/z88dk/"
export CROSS=1
export EXESUFFIX=".exe"
export PKG_CONFIG_PATH=/usr/i686-w64-mingw32/lib/pkgconfig/
export XML2CONFIG=/usr/i686-w64-mingw32/bin/xml2-config
make
check_result
stage="Cleaning intermediate files"
make bins-clean
check_result
stage="Copying i686 sdcc + libs into win32 kit"
cp ../../bin/win32.i686/* bin/
check_result
# And now rearrange the binary folds
mv bin bin.x86
mv bin.x86-64 bin
# Copy libs
stage="Copying libraries into win32 kit"
rsync -a ../../build/z88dk/lib/clibs/ lib/clibs
check_result
cp ../../build/z88dk/src/z80asm/z88dk-z80asm.lib lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sccz80 libsrc/_DEVELOPMENT/lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sdcc* libsrc/_DEVELOPMENT/lib/
check_result
rsync -a ../../build/z88dk/include/ include/
check_result
rsync -a ../../build/z88dk/libsrc/_DEVELOPMENT/target/ libsrc/_DEVELOPMENT/target/
check_result
cd ..
check_result
echo "#########################################################################"
echo
echo "Building win32 kit"
echo
echo "#########################################################################"
stage="win32 zip"
zip -qr9 ../kits/z88dk-win32-$date-$revision.zip z88dk
check_result
# Back to where we where
cd $cwd
# Now create a OS-X build
echo "#########################################################################"
echo
echo "Starting OS-X build"
echo
echo "#########################################################################"
rm -fr osx
mkdir -p osx
stage="OSX build"
# Extract the fresh tarball
tar xzf kits/z88dk-src-$date-$revision.tgz -C osx
check_result
stage="Copying sdcc into osx kit"
cp bin/osx/* osx/z88dk/bin/
check_result
# Build some mac binaries
stage="Build MacOS binaries"
# Set some required variables
export CFLAGS="-g -O2 -arch x86_64 -arch arm64 -mmacosx-version-min=11.0 -I/opt/osxcross/macports/pkgs/opt/local/include"
export CXX_FLAGS="-g -O2 -arch x86_64 -arch arm64 -mmacosx-version-min=11.0 -I/opt/osxcross/macports/pkgs/opt/local/libexec/boost/1.76/include"
export CXXFLAGS=$CXX_FLAGS
export LDFLAGS="-g -O2 -arch x86_64 -arch arm64 -L/opt/osxcross/macports/pkgs/opt/local/libexec/boost/1.76/lib -L/opt/osxcross/macports/pkgs/opt/local/lib"
export CC="x86_64-apple-darwin20.2-cc"
export CXX="x86_64-apple-darwin20.2-c++"
export PREFIX="/usr/local/"
export EXESUFFIX=""
export CROSS=1
export PATH=/opt/osxcross/bin:$PATH
# The libxml-2.0.pc file was manually added to this location
export PKG_CONFIG_PATH=/opt/osxcross/SDK/MacOSX11.1.sdk/usr/lib/pkgconfig
export XML2CONFIG=/opt/osxcross/SDK/MacOSX11.1.sdk/usr/bin/xml2-config
export USE_BOOST_FILESYSTEM=1
cp build/z88dk/lib/z88dk-z80asm.lib osx/z88dk/src/z80asm/dev/z80asm_lib/
check_result
# And build
cd osx/z88dk
check_result
make
check_result
# Remove intermediates
stage="Cleaning intermediate files"
make bins-clean
check_result
stage="Copying dependencies into osx kit"
#cp /opt/gtk-macosx/lib/libglib-2.0.dylib bin/libglib-2.0.0.dylib
#check_result
#cp /opt/gtk-macosx/lib/libintl.8.dylib bin/
#check_result
stage="Copying sdcc into osx kit"
cp ../../bin/osx/* bin/
check_result
# Remove z80asm or codesigning is a bit weird
rm -f bin/z80asm
stage="Code signing for MacOS"
for file in `file bin/* | grep Mach-O | awk '{print $1}' | sed s,:,,`; do
echo "Code signing $file"
rcodesign sign --p12-file $HOME/certs/domdev.p12 --p12-password-file $HOME/certs/password --code-signature-flags runtime $file
check_result
done
# Copy dependencies
# Copy libs
stage="Copying libraries into osx kit"
cp ../../build/z88dk/lib/clibs/*.lib lib/clibs
check_result
cp ../../build/z88dk/src/z80asm/z88dk-z80asm.lib lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sccz80 libsrc/_DEVELOPMENT/lib/
check_result
cp -r ../../build/z88dk/libsrc/_DEVELOPMENT/lib/sdcc* libsrc/_DEVELOPMENT/lib/
check_result
rsync -a ../../build/z88dk/include/ include/
check_result
rsync -a ../../build/z88dk/libsrc/_DEVELOPMENT/target/ libsrc/_DEVELOPMENT/target/
check_result
cd ..
check_result
echo "#########################################################################"
echo
echo "Building osx kit"
echo
echo "#########################################################################"
stage="osx zip"
zip -qr9 ../kits/z88dk-osx-$date-$revision.zip z88dk
echo "#########################################################################"
echo
echo "Notarising osx kit"
echo
echo "#########################################################################"
stage="notarise"
rcodesign notary-submit --api-key-path ~/certs/appstore.json --wait ../kits/z88dk-osx-$date-$revision.zip
cd $cwd/kits
rm z88dk-src-$date-$revision.tgz
echo "#########################################################################"
echo
echo "Everything built OK"
echo
echo "#########################################################################"
exit 0