-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
150 lines (136 loc) · 3.31 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
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
#!/bin/bash
# Copyright (c) 2020 Kosaki Mezumona
# This script distributed under the MIT License.
# See the root LICENSE file or https://opensource.org/licenses/MIT
# @(#)Build the libopus with opus_custom options.
# @(#)Usage:
# @(#) [OPUSBUILD_CONF=CONF] \\
# @(#) [OPUSBUILD_BUILD_DIR=BUILD_DIR]
# @(#) bash build.sh TARGET TYPE OUTDIR
# @(#)Parameters:
# @(#) TARGET: A target platform.
# @(#) android_armv7
# @(#) android_arm64
# @(#) android_x86
# @(#) android_x64
# @(#) ios
# @(#) macos
# @(#) TYPE: The library type.
# @(#) static
# @(#) shared
# @(#) OUTDIR: A directory path that is used to place built binaries.
# @(#) CONF: The library configuration. (optional)
# @(#) Debug
# @(#) Release
# @(#) MinSizeRel (default)
# @(#) RelWithDebInfo
# @(#) BUILD_DIR: A directory path that is used to place intermediate files.
SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
__main__()
{
set -e
if [[ $# -eq 0 ]]; then
what "$0"
return 1
fi
if [[ ! $# -eq 3 ]]; then
echo "Invalid parameter count expected 3, but $#." >&2
return 1
fi
local TARGET="$1"
local TYPE="$2"
local OUTDIR="$PWD/$3"
shift 3
local CONF="${OPUSBUILD_CONF:-MinSizeRel}"
local BUILD_DIR="${OPUSBUILD_BUILD_DIR:-}"
if [[ -z "$BUILD_DIR" ]]; then
BUILD_DIR="$PWD/build"
fi
local TOOLCHAIN="$(cmake_toolchain "$TARGET")"
if [[ ! -f "$TOOLCHAIN" ]]; then
echo "Unknown target platform: $TARGET" >&2
return 1
fi
eval "local GENERATOR_PARAMS=($(cmake_generator_params "$TARGET"))"
local BUILD_SHARED_LIBS="$(cmake_build_type "$TYPE")"
if [[ $BUILD_SHARED_LIBS -lt 0 ]]; then
echo "Unknown library type: $TYPE"
return 1
fi
mkdir -p "$BUILD_DIR"
if [[ "$TARGET" == "ios" ]]; then
export XCODE_XCCONFIG_FILE="$SCRIPT_DIR/polly/scripts/NoCodeSign.xcconfig"
fi
pushd "$BUILD_DIR" >/dev/null
cmake "$SCRIPT_DIR/libopus" \
-DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" \
-DCMAKE_INSTALL_PREFIX="$OUTDIR" \
-DCMAKE_BUILD_TYPE="$CONF" \
-DBUILD_SHARED_LIBS="$BUILD_SHARED_LIBS" \
-DOPUS_CUSTOM_MODES=ON \
-DOPUS_FLOAT_APPROX=ON \
-DOPUS_INSTALL_PKG_CONFIG_MODULE=OFF \
-DOPUS_INSTALL_CMAKE_CONFIG_MODULE=OFF \
"${GENERATOR_PARAMS[@]}"
cmake --build . --target install --config Release
popd >/dev/null
}
cmake_toolchain()
{
case "$1" in
"android_armv7")
echo "$SCRIPT_DIR/polly/android-ndk-r16b-api-21-armeabi-v7a-neon-clang-libcxx.cmake"
;;
"android_arm64")
echo "$SCRIPT_DIR/polly/android-ndk-r16b-api-21-arm64-v8a-neon-clang-libcxx.cmake"
;;
"android_x86")
echo "$SCRIPT_DIR/polly/android-ndk-r16b-api-21-x86-clang-libcxx.cmake"
;;
"android_x64")
echo "$SCRIPT_DIR/polly/android-ndk-r16b-api-21-x86-64-clang-libcxx.cmake"
;;
"ios")
echo "$SCRIPT_DIR/polly/ios-nocodesign.cmake"
;;
"macos")
echo "$SCRIPT_DIR/polly/xcode.cmake"
;;
"win64")
echo "$SCRIPT_DIR/polly/vs-15-2017-win64.cmake"
;;
*)
echo "SCRIPT_DIR/polly/$1"
;;
esac
}
cmake_generator_params()
{
case "$1" in
"ios")
echo '-G Xcode -DIOS_DEPLOYMENT_SDK_VERSION=10.0'
;;
"macos")
echo '-G Xcode'
;;
"win64")
echo '-G "Visual Studio 15 2017 Win64"'
;;
esac
}
cmake_build_type()
{
case "$1" in
"static")
echo 0
;;
"shared")
echo 1
;;
*)
echo -1
;;
esac
}
__main__ "$@"
exit $?