-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·83 lines (76 loc) · 1.99 KB
/
build.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
#!/bin/sh
#
# build.sh [clean | conf] [<platform>]
#
# This script configures and/or builds OpenZone in the `build` directory for a specified platform or
# all supported platforms uncommented in the beginning of this script if `<platform>` parameter is
# omitted. `ANDROID_NDK` and `NACL_SDK_ROOT` environment variables must be set for Android and NaCl
# builds respectively.
#
# The following commands may be given:
#
# - `clean`: Delete build(s).
# - `conf`: Delete build(s) and configure (but not build) them anew.
# - (none): Configure (if necessary) and build.
buildType=Debug
platforms=(
# Android14-i686
# Android14-ARMv7a
# Emscripten
# Linux-i686
# Linux-i686-Clang
Linux-x86_64
Linux-x86_64-Clang
# PNaCl
# Windows-i686
# Windows-x86_64
)
. etc/common.sh
function clean()
{
for platform in ${platforms[@]}; do
rm -rf build/$platform
done
rm -rf build/{OpenZone-*,NaCl-test,Windows-test,Android,bundle}
}
function build()
{
for platform in ${platforms[@]}; do
if [[ $platform != Emscripten && ! -f cmake/$platform.Toolchain.cmake ]]; then
echo Unknown platform: $platform
continue
fi
header_msg $platform-$buildType
(( $1 )) && rm -rf build/$platform-$buildType
if [[ ! -d build/$platform-$buildType ]]; then
mkdir -p build/$platform-$buildType
if [[ $platform == Emscripten ]]; then
( cd build/$platform-$buildType && emcmake cmake -Wdev --warn-uninitialized \
-G Ninja \
-D CMAKE_BUILD_TYPE=$buildType \
../.. )
else
( cd build/$platform-$buildType && cmake -Wdev --warn-uninitialized \
-G Ninja \
-D CMAKE_TOOLCHAIN_FILE=../../cmake/$platform.Toolchain.cmake \
-D CMAKE_BUILD_TYPE=$buildType \
../.. )
fi
fi
(( $1 )) || ( cd build/$platform-$buildType && time ninja )
done
}
case $1 in
clean)
if [[ -n $2 ]]; then platforms=( $2 ); fi
clean
;;
conf)
if [[ -n $2 ]]; then platforms=( $2 ); fi
build 1
;;
*)
if [[ -n $1 ]]; then platforms=( $1 ); fi
build 0
;;
esac