-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·95 lines (87 loc) · 2.45 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
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh
#
# build.sh [clean | conf | build]
#
# This script configures and/or builds OpenZone for all supported platforms in the `build`
# directory. The following commands may be given (`build` is assumed if none):
#
# - `clean`: Delete all builds.
# - `conf`: Delete all builds and configure (but not build) them anew.
# - `build`: Configure (if necessary) and build all builds.
# - `pnacl`: Run `pnacl-translate` to convert client `.pexe` to platform-dependent `.nexe`s.
#
buildType=Debug
platforms=(
Linux-x86_64
Linux-x86_64-Clang
Linux-i686
Linux-i686-Clang
Windows-i686
NaCl-x86_64
# NaCl-x86_64-glibc
NaCl-i686
# NaCl-i686-glibc
PNaCl
Android14-i686
Android14-ARM
Android14-ARMv7a
Android14-MIPS
)
# Extract path to NaCl SDK from CMake toolchain files.
naclPrefix=`sed -r '/ PLATFORM_PREFIX / !d; s|.*\"(.*)\".*|\1|' cmake/NaCl-x86_64.Toolchain.cmake`
naclGNUPrefix=`sed -r '/ PLATFORM_PREFIX / !d; s|.*\"(.*)\".*|\1|' cmake/NaCl-x86_64-glibc.Toolchain.cmake`
pnaclPrefix=`sed -r '/ PLATFORM_PREFIX / !d; s|.*\"(.*)\".*|\1|' cmake/PNaCl.Toolchain.cmake`
function clean()
{
for platform in ${platforms[@]}; do
rm -rf build/$platform
done
rm -rf build/{OpenZone-*,NaCl-test,Android}
}
function build()
{
for platform in ${platforms[@]}; do
echo ================================================================
echo
echo $platform
echo
echo ----------------------------------------------------------------
(( $1 )) && rm -rf build/$platform
if [[ ! -d build/$platform ]]; then
mkdir -p build/$platform
( cd build/$platform && cmake -Wdev --warn-uninitialized \
-D CMAKE_BUILD_TYPE=$buildType \
-D CMAKE_TOOLCHAIN_FILE=../../cmake/$platform.Toolchain.cmake \
../.. )
fi
(( $1 )) || ( cd build/$platform && time make -j4 )
echo ----------------------------------------------------------------
echo
echo $platform
echo
echo ================================================================
echo
done
}
function pnacl()
{
for arch in x86_64 i686 arm; do
echo "Building openzone.$arch.nexe"
"$pnaclPrefix/bin64/pnacl-translate" -arch $arch -o build/PNaCl/src/tools/openzone.$arch.nexe \
build/PNaCl/src/tools/openzone.pexe
done
}
case $1 in
clean)
clean
;;
conf)
build 1
;;
pnacl)
pnacl
;;
build|*)
build 0
;;
esac