forked from etlegacy/etlegacy-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
easybuild.sh
executable file
·776 lines (700 loc) · 18.9 KB
/
easybuild.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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
#!/usr/bin/env bash
# encoding: utf-8
# Made by the ET Legacy team!
# script checks for needed applications
# and builds ET Legacy
# Mandatory variables
_SRC=`pwd`
#BUILDDIR="${_SRC}/build"
BUILDDIR="${BUILD_DIR:-${_SRC}/build}"
SOURCEDIR="${_SRC}/src"
PROJECTDIR="${_SRC}/project"
LEGACYETMAIN="${HOME}/.etlegacy/etmain"
LEGACY_MIRROR="https://mirror.etlegacy.com/etmain/"
LEGACY_VERSION=`git describe 2>/dev/null`
# Set this to false to disable colors
color=true
# Do 32bit build
x86_build=true
# Command that can be run
# first array has the cmd names which can be given
# second array holds the functions which match the cmd names
easy_keys=(clean build package install download crust release project help)
easy_cmd=(run_clean run_build run_package run_install run_download run_uncrustify run_release run_project print_help)
easy_count=`expr ${#easy_keys[*]} - 1`
check_exit() {
EXIT_CODE=$?
if [ "$#" -ne 0 ]; then
eval "$1"
EXIT_CODE=$?
fi
if [ $EXIT_CODE != 0 ]; then
echo Exiting!
exit $EXIT_CODE
fi
}
if $color; then
# For color codes, see e.g. http://www.cplusplus.com/forum/unices/36461/
boldgreen='\033[1;32m'
boldlightblue='\033[1;36m'
boldwhite='\033[1;37m'
boldyellow='\033[1;33m'
boldred='\033[1;31m'
darkgreen='\033[0;32m'
reset='\033[0m'
else
boldgreen=
boldlightblue=
boldwhite=
boldyellow=
boldred=
darkgreen=
reset=
fi
einfo() {
echo -e "\n$boldgreen~~>$reset $boldwhite${1}$reset"
}
ehead() {
echo -e "$boldlightblue * $boldwhite${1}$reset"
}
app_exists() {
local __resultvar=$1
local app_result=0
BINPATH=`which $2 2>/dev/null`
if [ $? == 0 ]; then
local app_result=1
fi
eval $__resultvar="'$app_result'"
}
checkapp() {
if [ ${2} ]; then
ISPROBLEM=${2}
else
ISPROBLEM=1
fi
app_exists APP_FOUND $1
if [ $APP_FOUND == 1 ]; then
printf " %-8s $boldgreen%s$reset: %s\n" "${1}" "found" "${BINPATH}"
else
if [ ${ISPROBLEM} == 0 ]; then
printf " %-8s $boldyellow%s$reset\n" "${1}" "not found but no problem"
else
printf " %-8s $boldred%s$reset\n" "${1}" "not found"
fi
fi
}
_detectlinuxdistro() {
# check for most popular distro files
_DISTROFILES="
/etc/gentoo-release /etc/slackware-release
/etc/debian_version /etc/debian_release /etc/ubuntu-release
/etc/redhat-release /etc/centos-release /etc/fedora-release
/etc/SuSE-release /etc/novell-release /etc/sles-release"
for distro in ${_DISTROFILES}; do
[ -e "${distro}" ] && echo $(<${distro}) && exit
done
# archlinux has empty file...
[ -e "/etc/arch-release" ] && echo "Arch Linux" && exit
# Alpine Linux only has a version number
[ -e "/etc/alpine-release" ] && echo "Alpine Linux $(</etc/alpine-release)" && exit
# oh, maybe we have /etc/lsb-release?
if [ -e "/etc/lsb-release" ]; then
. "/etc/lsb-release"
[ ! ${DISTRIB_DESCRIPTION} ] && DISTRIB_DESCRIPTION="${DISTRIB_ID} ${DISTRIB_RELEASE}"
echo "${DISTRIB_DESCRIPTION}"
exit
fi
echo "Unknown Linux"
}
detectos() {
PLATFORMSYS=`uname -s`
PLATFORMARCH=`uname -m`
if [[ ${PLATFORMSYS} == "Linux" ]]; then
DISTRO=`_detectlinuxdistro`
elif [[ ${PLATFORMSYS} == "Darwin" ]]; then
PLATFORMSYS=`sw_vers -productName`
DISTRO=`sw_vers -productVersion`
else
DISTRO="Unknown"
fi
echo -e " running on: $boldgreen${PLATFORMSYS}$reset $darkgreen${PLATFORMARCH}$reset - $boldlightblue${DISTRO}$reset"
}
# This is in reference to https://cmake.org/pipermail/cmake/2016-April/063312.html
# Long story short, setting the cross compile state in cmake does not work on all platforms
# so lets set the -m32 flag before we run cmake
set_compiler() {
if [ ${3} == true ]; then
export CC="${1} -m32"
export CXX="${2} -m32"
else
export CC=${1}
export CXX=${2}
fi
}
check_compiler() {
if [ -z "$CC" ] && [ -z "$CXX" ]; then
app_exists GCCFOUND "gcc"
app_exists GPLUSFOUND "g++"
app_exists CLANGFOUND "clang"
app_exists CLANGPLUSFOUND "clang++"
if [ $GCCFOUND == 1 ] && [ $GPLUSFOUND == 1 ]; then
set_compiler gcc g++ $x86_build
elif [ $CLANGFOUND == 1 ] && [ $CLANGPLUSFOUND == 1 ]; then
set_compiler clang clang++ $x86_build
else
einfo "Missing compiler. Exiting."
exit 1
fi
fi
}
print_startup() {
echo
ehead "ET Legacy Easy Builder"
ehead "==============================="
ehead "This script will check for binaries needed to compile ET Legacy"
ehead "Then it will build ET Legacy into ${BUILDDIR}/ directory"
echo
einfo "Checking for needed apps to compile..."
echo
detectos
echo
checkapp autoconf
checkapp cmake
checkapp gcc
checkapp g++
checkapp clang 0
checkapp clang++ 0
checkapp git
checkapp zip
checkapp nasm
echo
check_compiler
einfo "Using compilers:"
echo
echo " CC = ${CC}"
echo " CXX = ${CXX}"
}
parse_commandline() {
for var in "$@"
do
if [ "$var" = "-64" ]; then
einfo "Will disable crosscompile"
CROSS_COMPILE32=0
x86_build=false
elif [ "$var" = "-clang" ]; then
einfo "Will use clang"
set_compiler clang clang++ $x86_build
elif [ "$var" = "-gcc" ]; then
einfo "Will use gcc"
set_compiler gcc g++ $x86_build
elif [ "$var" = "-debug" ]; then
einfo "Will enable debug build"
RELEASE_TYPE="Debug"
elif [ "$var" = "-nodb" ]; then
einfo "Will disable database"
FEATURE_DBMS=0
BUNDLED_SQLITE3=0
elif [ "$var" = "-nor2" ]; then
einfo "Will disable renderer2"
FEATURE_RENDERER2=0
elif [ "$var" = "-nodynamic" ]; then
einfo "Will disable dynamic renderer build"
RENDERER_DYNAMIC=0
elif [ "$var" = "-jpeg-turbo" ]; then
einfo "Will enable system jpeg turbo"
BUNDLED_JPEG=0
elif [ "$var" = "-systemlib" ]; then
einfo "Will disable bundled libraries"
BUNDLED_LIBS=0
BUNDLED_SDL=0
BUNDLED_ZLIB=0
BUNDLED_MINIZIP=0
BUNDLED_CURL=0
BUNDLED_JPEG=0
BUNDLED_LUA=0
BUNDLED_OGG_VORBIS=0
BUNDLED_THEORA=0
BUNDLED_OPENAL=0
BUNDLED_GLEW=0
BUNDLED_FREETYPE=0
BUNDLED_JANSSON=0
BUNDLED_SQLITE3=0
elif [ "$var" = "-noextra" ]; then
einfo "Will disable installation of Omni-bot, GeoIP and WolfAdmin"
INSTALL_EXTRA=0
INSTALL_OMNIBOT=0
INSTALL_GEOIP=0
INSTALL_WOLFADMIN=0
elif [ "$var" = "-noupdate" ]; then
einfo "Will disable autoupdate"
FEATURE_AUTOUPDATE=0
elif [ "$var" = "-RPI" ]; then
einfo "Will enable Raspberry PI build ..."
ARM=1
CROSS_COMPILE32=0
x86_build=false
FEATURE_RENDERER_GLES=0
RENDERER_DYNAMIC=0
FEATURE_RENDERER2=0
FEATURE_JANSSON=0
BUNDLED_JANSSON=0
# FIXME: ogg doesn't compile
BUNDLED_OGG_VORBIS=0
FEATURE_OGG_VORBIS=0
# FIXME
FEATURE_THEORA=0
BUNDLED_THEORA=0
# not required
BUNDLED_GLEW=0
# FIXME: needs -PIC
FEATURE_FREETYPE=0
BUNDLED_FREETYPE=0
#FEATURE_DBMS=0
#BUNDLED_SQLITE3=0
FEATURE_LUASQL=1
FEATURE_OMNIBOT=1
INSTALL_OMNIBOT=0
elif [ "$var" = "-mod" ]; then
einfo "Will only build the mod"
BUILD_CLIENT=0
BUILD_SERVER=0
FEATURE_RENDERER2=0
FEATURE_RENDERER_GLES=0
RENDERER_DYNAMIC=0
FEATURE_CURL=0
FEATURE_OGG_VORBIS=0
FEATURE_THEORA=0
FEATURE_OPENAL=0
FEATURE_FREETYPE=0
FEATURE_JANSSON=0
BUNDLED_SDL=0
# FIXME: this needs to be fixed in cmake, we do not want zlib or minizip if we are not building the client or server
BUNDLED_ZLIB=1
BUNDLED_MINIZIP=1
BUNDLED_JPEG=0
BUNDLED_OGG_VORBIS=0
BUNDLED_THEORA=0
BUNDLED_GLEW=0
BUNDLED_FREETYPE=0
BUNDLED_JANSSON=0
BUNDLED_CURL=0
BUNDLED_OPENAL=0
elif [ "$var" = "-server" ]; then
einfo "Will only build server requirements"
BUILD_CLIENT=0
BUILD_SERVER=1
FEATURE_RENDERER2=0
FEATURE_RENDERER_GLES=0
RENDERER_DYNAMIC=0
FEATURE_CURL=0
FEATURE_OGG_VORBIS=0
FEATURE_THEORA=0
FEATURE_OPENAL=0
FEATURE_FREETYPE=0
FEATURE_JANSSON=0
BUNDLED_SDL=0
BUNDLED_ZLIB=1
BUNDLED_MINIZIP=1
BUNDLED_JPEG=0
BUNDLED_OGG_VORBIS=0
BUNDLED_THEORA=0
BUNDLED_GLEW=0
BUNDLED_FREETYPE=0
BUNDLED_JANSSON=0
BUNDLED_CURL=0
BUNDLED_OPENAL=0
else
# drop the script commands from the result
for index in ${!easy_keys[*]}
do
#printf "%4d: %s\n" $index ${easy_keys[$index]}
if [ "$easy_count" = "$index" ] && [ ! "$var" = "${easy_keys[$index]}" ]; then
if [ -z "$PARSE_CMD" ]; then
PARSE_CMD=$var
else
PARSE_CMD="$PARSE_CMD $var"
fi
elif [[ "$var" = "${easy_keys[$index]}" ]]; then
break
fi
done
fi
done
}
generate_configuration() {
#cmake variables
RELEASE_TYPE=${RELEASE_TYPE:-Release}
CROSS_COMPILE32=${CROSS_COMPILE32:-1}
BUILD_SERVER=${BUILD_SERVER:-1}
BUILD_CLIENT=${BUILD_CLIENT:-1}
BUILD_MOD=${BUILD_MOD:-1}
BUILD_MOD_PK3=${BUILD_MOD_PK3:-1}
BUILD_PAK_PK3=${BUILD_PAK_PK3:-1}
BUNDLED_LIBS=${BUNDLED_LIBS:-1}
BUNDLED_SDL=${BUNDLED_SDL:-1}
BUNDLED_ZLIB=${BUNDLED_ZLIB:-1}
BUNDLED_MINIZIP=${BUNDLED_MINIZIP:-1}
BUNDLED_JPEG=${BUNDLED_JPEG:-1}
BUNDLED_LUA=${BUNDLED_LUA:-1}
BUNDLED_OGG_VORBIS=${BUNDLED_OGG_VORBIS:-1}
BUNDLED_THEORA=${BUNDLED_THEORA:-1}
BUNDLED_GLEW=${BUNDLED_GLEW:-1}
BUNDLED_FREETYPE=${BUNDLED_FREETYPE:-1}
BUNDLED_JANSSON=${BUNDLED_JANSSON:-0}
BUNDLED_SQLITE3=${BUNDLED_SQLITE3:-1}
if [ "${PLATFORMSYS}" == "Mac OS X" ]; then
BUNDLED_CURL=${BUNDLED_CURL:-0}
BUNDLED_OPENSSL=${BUNDLED_OPENSSL:-0}
BUNDLED_OPENAL=${BUNDLED_OPENAL:-0}
else
BUNDLED_CURL=${BUNDLED_CURL:-1}
BUNDLED_OPENSSL=${BUNDLED_OPENSSL:-0}
BUNDLED_OPENAL=${BUNDLED_OPENAL:-1}
fi
FEATURE_RENDERER2=${FEATURE_RENDERER2:-1}
FEATURE_RENDERER_GLES=${FEATURE_RENDERER_GLES:-0}
RENDERER_DYNAMIC=${RENDERER_DYNAMIC:-1}
FEATURE_CURL=${FEATURE_CURL:-1}
FEATURE_OPENSSL=${FEATURE_OPENSSL:-0}
FEATURE_OGG_VORBIS=${FEATURE_OGG_VORBIS:-1}
FEATURE_THEORA=${FEATURE_THEORA:-1}
FEATURE_OPENAL=${FEATURE_OPENAL:-1}
FEATURE_FREETYPE=${FEATURE_FREETYPE:-1}
FEATURE_GETTEXT=${FEATURE_GETTEXT:-1}
FEATURE_JANSSON=${FEATURE_JANSSON:-0}
FEATURE_DBMS=${FEATURE_DBMS:-1}
FEATURE_LUA=${FEATURE_LUA:-1}
FEATURE_MULTIVIEW=${FEATURE_MULTIVIEW:-1}
FEATURE_EDV=${FEATURE_EDV:-1}
FEATURE_ANTICHEAT=${FEATURE_ANTICHEAT:-1}
FEATURE_RATING=${FEATURE_RATING:-1}
FEATURE_AUTOUPDATE=${FEATURE_AUTOUPDATE:-0}
FEATURE_LUASQL=${FEATURE_LUASQL:-1}
FEATURE_OMNIBOT=${FEATURE_OMNIBOT:-1}
INSTALL_EXTRA=${INSTALL_EXTRA:-1}
INSTALL_OMNIBOT=${INSTALL_OMNIBOT:-1}
INSTALL_GEOIP=${INSTALL_GEOIP:-1}
INSTALL_WOLFADMIN=${INSTALL_WOLFADMIN:-1}
einfo "Configuring ET Legacy..."
_CFGSTRING="
-DCMAKE_BUILD_TYPE=${RELEASE_TYPE}
-DCROSS_COMPILE32=${CROSS_COMPILE32}
-DBUILD_SERVER=${BUILD_SERVER}
-DBUILD_CLIENT=${BUILD_CLIENT}
-DBUILD_MOD=${BUILD_MOD}
-DBUILD_MOD_PK3=${BUILD_MOD_PK3}
-DBUILD_PAK3_PK3=${BUILD_PAK_PK3}
-DBUNDLED_LIBS=${BUNDLED_LIBS}
-DBUNDLED_SDL=${BUNDLED_SDL}
-DBUNDLED_ZLIB=${BUNDLED_ZLIB}
-DBUNDLED_MINIZIP=${BUNDLED_MINIZIP}
-DBUNDLED_JPEG=${BUNDLED_JPEG}
-DBUNDLED_CURL=${BUNDLED_CURL}
-DBUNDLED_OPENSSL=${BUNDLED_OPENSSL}
-DBUNDLED_LUA=${BUNDLED_LUA}
-DBUNDLED_OGG_VORBIS=${BUNDLED_OGG_VORBIS}
-DBUNDLED_THEORA=${BUNDLED_THEORA}
-DBUNDLED_OPENAL=${BUNDLED_OPENAL}
-DBUNDLED_GLEW=${BUNDLED_GLEW}
-DBUNDLED_FREETYPE=${BUNDLED_FREETYPE}
-DBUNDLED_JANSSON=${BUNDLED_JANSSON}
-DBUNDLED_SQLITE3=${BUNDLED_SQLITE3}
-DFEATURE_CURL=${FEATURE_CURL}
-DFEATURE_OPENSSL=${FEATURE_OPENSSL}
-DFEATURE_OGG_VORBIS=${FEATURE_OGG_VORBIS}
-DFEATURE_THEORA=${FEATURE_THEORA}
-DFEATURE_OPENAL=${FEATURE_OPENAL}
-DFEATURE_FREETYPE=${FEATURE_FREETYPE}
-DFEATURE_LUA=${FEATURE_LUA}
-DFEATURE_MULTIVIEW=${FEATURE_MULTIVIEW}
-DFEATURE_EDV=${FEATURE_EDV}
-DFEATURE_ANTICHEAT=${FEATURE_ANTICHEAT}
-DFEATURE_GETTEXT=${FEATURE_GETTEXT}
-DFEATURE_JANSSON=${FEATURE_JANSSON}
-DFEATURE_DBMS=${FEATURE_DBMS}
-DFEATURE_RATING=${FEATURE_RATING}
-DFEATURE_AUTOUPDATE=${FEATURE_AUTOUPDATE}
-DFEATURE_RENDERER2=${FEATURE_RENDERER2}
-DFEATURE_RENDERER_GLES=${FEATURE_RENDERER_GLES}
-DRENDERER_DYNAMIC=${RENDERER_DYNAMIC}
-DFEATURE_LUASQL=${FEATURE_LUASQL}
-DFEATURE_OMNIBOT=${FEATURE_OMNIBOT}
-DINSTALL_EXTRA=${INSTALL_EXTRA}
-DINSTALL_OMNIBOT=${INSTALL_OMNIBOT}
-DINSTALL_GEOIP=${INSTALL_GEOIP}
-DINSTALL_WOLFADMIN=${INSTALL_WOLFADMIN}
"
if [ "${DEV}" != 1 ]; then
if [ "${PLATFORMSYS}" == "Mac OS X" ]; then
PREFIX=${HOME}/etlegacy
_CFGSTRING="${_CFGSTRING}
-DCMAKE_INSTALL_PREFIX=${PREFIX}
-DINSTALL_DEFAULT_MODDIR=./
-DINSTALL_DEFAULT_BINDIR=./
-DINSTALL_DEFAULT_BASEDIR=./
"
else
PREFIX=${HOME}/etlegacy
_CFGSTRING="${_CFGSTRING}
-DCMAKE_INSTALL_PREFIX=${PREFIX}
-DINSTALL_DEFAULT_MODDIR=.
-DINSTALL_DEFAULT_BINDIR=.
-DINSTALL_DEFAULT_BASEDIR=.
"
fi
fi
echo -e "$boldyellowusing: $boldwhite${_CFGSTRING}$reset"
}
# Check if the bundled libs repo has been loaded
handle_bundled_libs() {
if [[ ! -e "${_SRC}/libs/CMakeLists.txt" ]]; then
einfo "Getting bundled libs..."
git submodule init
git submodule update
fi
}
run_clean() {
einfo "Clean..."
if [ -d ${BUILDDIR} ]; then
rm -rf ${BUILDDIR}
fi
CLEANLIBS=1
if [[ -e "${_SRC}/libs/CMakeLists.txt" && ${CLEANLIBS} ]]; then
# this doesn't work?
if [ "${BUNDLED_SDL}" == 1 ]; then
einfo "Cleaning SDL..."
cd ${_SRC}/libs/sdl2; make clean
fi
if [ "${BUNDLED_ZLIB}" == 1 ]; then
einfo "Cleaning ZLib..."
cd ${_SRC}/libs/zlib; make distclean
fi
if [ "${BUNDLED_MINIZIP}" == 1 ]; then
einfo "Cleaning MiniZip..."
cd ${_SRC}/libs/minizip; make clean
fi
if [ "${BUNDLED_JPEG}" == 1 ]; then
einfo "Cleaning libjpeg-turbo..."
cd ${_SRC}/libs/jpegturbo; make clean
fi
if [ "${BUNDLED_CURL}" == 1 ]; then
einfo "Cleaning libcurl..."
cd ${_SRC}/libs/curl/src; make clean
fi
if [ "${BUNDLED_LUA}" == 1 ]; then
einfo "Cleaning Lua..."
cd ${_SRC}/libs/lua/src; make clean
fi
if [ "${BUNDLED_OGG_VORBIS}" == 1 ]; then
einfo "Cleaning libogg..."
cd ${_SRC}/libs/ogg; make clean
einfo "Cleaning libvorbis..."
cd ${_SRC}/libs/vorbis; make clean
# einfo "Cleaning libtheora..."
# cd ${_SRC}/libs/theora; make clean
fi
if [ "${BUNDLED_OPENAL}" == 1 ]; then
einfo "Cleaning openAL..."
cd ${_SRC}/libs/openal; make clean
fi
cd ${_SRC}/libs
git clean -d -f
fi
}
run_build() {
einfo "Build..."
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
cmake ${_CFGSTRING} ..
check_exit
make ${CMD_ARGS}
check_exit
}
create_osx_dmg() {
# Generate DMG
app_exists APP_FOUND "gm"
if [ $APP_FOUND == 0 ]; then
echo "Missing GraphicsMagick skipping OSX installer creation"
return
fi
app_exists APP_FOUND "node"
if [ $APP_FOUND == 0 ]; then
echo "Missing nodejs skipping OSX installer creation"
return
fi
app_exists APP_FOUND "appdmg"
if [ $APP_FOUND == 0 ]; then
echo "Missing appdmg skipping OSX installer creation"
return
fi
app_exists APP_FOUND "rsvg-convert"
if [ $APP_FOUND == 0 ]; then
echo "Missing rsvg-convert cannot create installer"
exit 1
fi
echo "Generating OSX installer"
SHORT_VERSION=`git describe --abbrev=0 --tags 2>/dev/null`
# Generate the icon for the folder
# using rsvg-convert
# brew install librsvg
rsvg-convert -h 256 ../misc/etl.svg > icon.png
# Generate the DMG background
# using the Graphics Magick
# brew install graphicsmagick
gm convert ../misc/osx-dmg-background.jpg -resize 640x360 -font ../misc/din1451alt.ttf -pointsize 20 -fill 'rgb(85,85,85)' -draw "text 75,352 '${SHORT_VERSION}'" osx-dmg-background.jpg
# Needs to be the osx:s default python install!
python << END
import Cocoa
import sys
import os
import glob
import shutil
iconfile = "icon.png"
foldername = "ET Legacy"
if os.path.isdir(foldername):
shutil.rmtree(foldername)
files = [f for f in glob.glob('./_CPack_Packages/Darwin/TGZ/etlegacy*') if os.path.isdir(f)]
if len(files) == 1 :
packfolder = files[0]
shutil.copytree(packfolder, foldername)
print 'Copied the legacy install folder'
Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(Cocoa.NSImage.alloc().initWithContentsOfFile_(iconfile), foldername, 0) or sys.exit("Unable to set file icon")
print 'The icon succesfully set'
END
# Create the DMG json
cat << END > legacy-dmg.json
{
"title": "ET Legacy $SHORT_VERSION",
"icon": "../misc/etl.icns",
"background": "osx-dmg-background.jpg",
"window": {
"size": {
"width": 640,
"height": 390
}
},
"contents": [
{ "x": 456, "y": 250, "type": "link", "path": "/Applications" },
{ "x": 192, "y": 250, "type": "file", "path": "ET Legacy" }
]
}
END
# using appdmg nodejs application to generate the actual DMG installer
# https://github.com/LinusU/node-appdmg
# npm install -g appdmg
appdmg legacy-dmg.json "ETLegacy-${LEGACY_VERSION}.dmg"
}
run_package() {
einfo "Package..."
cd ${BUILDDIR}
# check_exit "make package"
# calling cpack directly we are not checking the build output anymore
check_exit "cpack"
# TODO: detect if osx and generate a package and a dmg installer
if [ "${PLATFORMSYS}" == "Mac OS X" ]; then
create_osx_dmg
fi
}
run_install() {
einfo "Install..."
cd ${BUILDDIR}
check_exit "make install"
}
handle_download() {
if [ ! -f $1 ]; then
if [ -f /usr/bin/curl ]; then
curl -O "${LEGACY_MIRROR}$1"
else
wget "${LEGACY_MIRROR}$1"
fi
fi
}
run_download() {
einfo "Downloading packages..."
mkdir -p ${LEGACYETMAIN}
cd ${LEGACYETMAIN}
handle_download "pak0.pk3"
handle_download "pak1.pk3"
handle_download "pak2.pk3"
}
run_uncrustify() {
einfo "Uncrustify..."
cd ${SOURCEDIR}
for FILE in $(find . -type f -not -name "unzip.c" -name "*.c" -or -name "*.cpp" -or -name "*.glsl" -not -name "g_etbot_interface.cpp" -or -name "*.h" -or \( -name "sha*" -prune \) -or \( -name "Omnibot" -prune \));
do
uncrustify -c ${_SRC}/uncrustify.cfg --no-backup ${FILE}
done
}
run_project() {
einfo "Project..."
if [ -d ${PROJECTDIR} ]; then
rm -rf ${PROJECTDIR}
fi
mkdir -p ${PROJECTDIR}
cd ${PROJECTDIR}
if [ "${PLATFORMSYS}" == "Mac OS X" ]; then
cmake -G 'Xcode' ${_CFGSTRING} ..
else
cmake ${_CFGSTRING} ..
fi
}
run_release() {
einfo "Doing a release build process..."
run_clean
run_build
run_package
}
run_default() {
einfo "Default build..."
run_clean
run_build
run_package
run_install
}
print_help() {
ehead "ET Legacy Easy Builder Help"
ehead "==============================="
ehead "clean - clean up the build"
ehead "build - run the build process"
ehead "package - run the package process"
ehead "install - install the game into the system"
ehead "download - download assets"
ehead "crust - run the uncrustify to the source"
ehead "project - generate the project files for your platform"
ehead "release - run the entire release process"
ehead "help - print this help"
echo
einfo "Properties"
ehead "-64, -debug, -clang, -nodb -nor2, -nodynamic, -systemlib, -noextra, -noupdate, -mod, -server"
echo
}
start_script() {
parse_commandline $@
#CMD_ARGS="${@:2}"
#CMD_ARGS=$@
CMD_ARGS=$PARSE_CMD
print_startup
handle_bundled_libs
generate_configuration
ARG_FOUND=0
# Everything looks ok, try to run this shit!
# Find and run the processes the user requested
for var in "$@"
do
for index in ${!easy_keys[*]}
do
if [ "$var" = "${easy_keys[$index]}" ]; then
eval "${easy_cmd[$index]}"
ARG_FOUND=1
fi
done
done
if [ $ARG_FOUND -eq 1 ]; then
return
fi
# No process was set run the default
run_default
}
start_script $@
# Return to the original path
cd ${_SRC}