-
Notifications
You must be signed in to change notification settings - Fork 200
/
Copy pathbuild_player.sh
271 lines (220 loc) · 8.28 KB
/
build_player.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
#!/usr/bin/env bash
BUILD_TOOLS_DIR=$(cd $(dirname ${BASH_SOURCE[0]}); pwd)
PATH=$PATH:${BUILD_TOOLS_DIR}
function check_brew() {
if [[ ! `which brew` ]]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" \
|| exit 1
fi
}
function check_tool() {
if [[ -z "$1" ]];then
echo "error no tool to check"
else
if [[ ! `which $1` ]]
then
brew install $1 || exit 1
fi
fi
}
function check_cmake(){
if [[ ! `which cmake` ]]
then
echo 'cmake not found'
echo 'Trying to install cmake...'
brew install cmake || exit 1
else
local major=`cmake -version | head -1 | cut -d ' ' -f3 | cut -d '-' -f1 | cut -d '.' -f1`
local minor=`cmake -version | head -1 | cut -d ' ' -f3 | cut -d '-' -f1 | cut -d '.' -f2`
if [[ ${major} -ge 3 && ${minor} -ge 14 ]];then
echo cmake version is ok ${major}.${minor}
else
brew upgrade cmake
fi
fi
}
#function Android_build_Asan(){
# if [ -n "$MTL" ];then
# export ANDROID_NDK_HOME=/home/admin/software/android-ndk-r18b
# echo "ANDROID_NDK_HOME is ${ANDROID_NDK_HOME}"
# fi
# cd motuAsan/
# sh gradlew build --refresh-dependencies --stacktrace -DALIYUN_APP_VERSION=$SAASPLAYERSDK_VERSION $JAVA_HOME_OPT
# mkdir -p $TOP_DIR/output
# cp app/build/outputs/apk/debug/CicadaDemo_debug.apk $TOP_DIR/output/
# cp -r premierlibrary/build/intermediates/cmake/corePlayer/release/obj/armeabi-v7a $TOP_DIR/output
#}
function build_Android(){
git submodule init
git submodule update
JAVA_HOME_OPT=
if [ -n "$JAVA_HOME" ]
then
JAVA_HOME_OPT=-Dorg.gradle.java.home=${JAVA_HOME}
fi
cd ${TOP_DIR}/external
./build_external.sh Android
export EXTERN_INSTALL_DIR_ANDROID=$PWD/install/
export FFMPEG_INSTALL_DIR_ANDROID=$PWD/install/ffmpeg/Android/
if [ $? -ne 0 ]; then
echo "build_external break"
return 1
fi
cd ${TOP_DIR}/platform/Android
# if [ -n "$BUILD_ASAN" ];then
# Android_build_Asan
# return 0
# fi
cd source/
sh gradlew clean
# sh gradlew build --refresh-dependencies --stacktrace -DALIYUN_APP_VERSION=$SAASPLAYERSDK_VERSION $JAVA_HOME_OPT
# #run twice for copy aar
export ANDROID_FULL_PACKAGE='true'
sh gradlew assembleRelease --refresh-dependencies --stacktrace $JAVA_HOME_OPT
cd ${TOP_DIR}/platform/Android
./package.sh
# ./apsaraPlayer_Android/build_demo.sh
cd $TOP_DIR
mkdir output
cp `find platform/Android -name "*.apk"` output
cp `find platform/Android/source/releaseLibs/ -name "*.aar"` output
cp `find platform/Android/release -name "*.zip"` output
mkdir -p output/armeabi-v7a/
mkdir -p output/arm64-v8a/
cp platform/Android/source/premierlibrary/build/intermediates/cmake/corePlayerRelease/obj/armeabi-v7a/*.so output/armeabi-v7a/
cp platform/Android/source/premierlibrary/build/intermediates/cmake/corePlayerRelease/obj/arm64-v8a/*.so output/arm64-v8a/
cp external/install/ffmpeg/Android/armeabi-v7a/libalivcffmpeg.so output/armeabi-v7a/
cp external/install/ffmpeg/Android/arm64-v8a/libalivcffmpeg.so output/arm64-v8a/
cd output
tree
}
function packet_iOS(){
rm -rf ${TOP_DIR}/output
mkdir -p ${TOP_DIR}/output/
mkdir -p ${TOP_DIR}/output/CicadaPlayerSDK/
mkdir -p ${TOP_DIR}/output/CicadaPlayerSDK/CicadaDemo
CicadaSDK_PATH=${TOP_DIR}/output/CicadaPlayerSDK/SDK/
CicadaSDK_ALL=${CicadaSDK_PATH}/ARM_SIMULATOR
CicadaSDK_ARM=${TOP_DIR}/output/CicadaPlayerSDK/SDK/ARM
mkdir -p ${CicadaSDK_ALL}
mkdir -p ${CicadaSDK_ARM}
#cp clear CicadaDemo at first
cp -rf CicadaDemo/ ${TOP_DIR}/output/CicadaPlayerSDK/CicadaDemo
cd ${DEMO_SOURCE_DIR_IOS}/SDK/
ALL_FRAMEWORK_PATH=${DEMO_SOURCE_DIR_IOS}/SDK/ARM_SIMULATOR
mkdir -p ${ALL_FRAMEWORK_PATH}
#build iphoneos
xcodebuild -scheme ALL_BUILD ONLY_ACTIVE_ARCH=NO -configuration MinSizeRel -sdk iphoneos VALID_ARCHS="armv7 arm64"
cp -rf ./MinSizeRel/*.framework ${ALL_FRAMEWORK_PATH}
cp -rf ./MinSizeRel/*.dSYM ${CicadaSDK_ALL}/
cp -rf ./MinSizeRel/*.framework ${CicadaSDK_ARM}/
#build simulator
xcodebuild -scheme ALL_BUILD ONLY_ACTIVE_ARCH=NO -configuration Release -sdk iphonesimulator VALID_ARCHS="x86_64 i386"
if [ $? -ne 0 ]; then
echo "simulator build failed"
else
lipo -create "${ALL_FRAMEWORK_PATH}/CicadaPlayerSDK.framework/CicadaPlayerSDK" "./Release/CicadaPlayerSDK.framework/CicadaPlayerSDK" -output "${ALL_FRAMEWORK_PATH}/CicadaPlayerSDK.framework/CicadaPlayerSDK"
lipo -create "${ALL_FRAMEWORK_PATH}/alivcffmpeg.framework/alivcffmpeg" "./Release/alivcffmpeg.framework/alivcffmpeg" -output "${ALL_FRAMEWORK_PATH}/alivcffmpeg.framework/alivcffmpeg"
fi
# copy to SDK folder
cp -rf ${ALL_FRAMEWORK_PATH}/*.framework ${CicadaSDK_ALL}/
nobit_path=${CicadaSDK_PATH}/ARM_NO_BITCODE
mkdir -p ${nobit_path}
cp -rf ${CicadaSDK_ARM}/*.framework ${nobit_path}
xcrun bitcode_strip ${nobit_path}/CicadaPlayerSDK.framework/CicadaPlayerSDK -r -o ${nobit_path}/CicadaPlayerSDK.framework/CicadaPlayerSDK
xcrun bitcode_strip ${nobit_path}/alivcffmpeg.framework/alivcffmpeg -r -o ${nobit_path}/alivcffmpeg.framework/alivcffmpeg
#build app without SDK
# mv CicadaPlayerSDK.xcodeproj CicadaPlayerSDKBak.xcodeproj
# cd ${DEMO_SOURCE_DIR_IOS}/CicadaDemo
# sh packetIPA.sh
# cp ./build/Release-iphoneos/CicadaDemo.ipa ${TOP_DIR}/output
# cd ./build/Release-iphoneos/CicadaDemo.xcarchive/dSYMs
# tar -cjvf ${TOP_DIR}/output/CicadaDemo.app.dSYM.bz2 ./CicadaDemo.app.dSYM
# cd ${DEMO_SOURCE_DIR_IOS}/SDK/
# mv CicadaPlayerSDKBak.xcodeproj CicadaPlayerSDK.xcodeproj
cd ${TOP_DIR}/output/
tar -cjvf ${TOP_DIR}/output/CicadaPlayerSDK_${MUPP_BUILD_ID}.bz2 CicadaPlayerSDK/
}
function build_iOS_new(){
DEMO_SOURCE_DIR_IOS=${TOP_DIR}/platform/Apple/demo/iOS
cd ${DEMO_SOURCE_DIR_IOS}
./genxcodeproj.sh
packet_iOS
}
function build_iOS(){
check_brew
if [[ -n "$MTL" ]];then
check_cmake
else
check_tool "cmake"
fi
check_tool "yasm"
check_tool "automake"
if [[ $? -ne 0 ]]; then
return 1
fi
cd ${TOP_DIR}/external
./build_external.sh iOS
if [[ $? -ne 0 ]]; then
echo "build_external break"
return 1
fi
build_iOS_new
if [[ ! -f "${TOP_DIR}/output/CicadaPlayerSDK/SDK/ARM_SIMULATOR/CicadaPlayerSDK.framework/CicadaPlayerSDK" ]]; then
echo "CicadaPlayerSDK.framework build failed"
return 1
fi
}
function packet_mac(){
mkdir ${TOP_DIR}/output
OUT_PUT_IDR=${TOP_DIR}/output
cd ${DEMO_SOURCE_DIR_MAC}/SDK
xcodebuild -scheme install ONLY_ACTIVE_ARCH=NO -configuration MinSizeRel
#build app without SDK
mv CicadaPlayerSDK.xcodeproj CicadaPlayerSDKBak.xcodeproj
cd ${DEMO_SOURCE_DIR_MAC}/
mkdir CicadaDemo_release
cp -rf CicadaDemo CicadaDemo_release/
mkdir -p CicadaDemo_release/SDK/
cd ${DEMO_SOURCE_DIR_MAC}/CicadaDemo
xcodebuild -workspace CicadaDemo.xcworkspace -scheme CicadaDemo ONLY_ACTIVE_ARCH=NO -configuration Release
cd ${DEMO_SOURCE_DIR_MAC}/Release
tar -cjvf ${OUT_PUT_IDR}/CicadaDemo.app.bz2 CicadaDemo.app
tar -cjvf ${OUT_PUT_IDR}/CicadaDemo.app.dSYM.bz2 CicadaDemo.app.dSYM
cd ${DEMO_SOURCE_DIR_MAC}
mv ./SDK/CicadaPlayerSDKBak.xcodeproj ./SDK/CicadaPlayerSDK.xcodeproj
mv SDK/*.framework CicadaDemo_release/SDK/
mv SDK/MinSizeRel/*.dSYM CicadaDemo_release/SDK/
tar -cjvf ${OUT_PUT_IDR}/CicadaDemo_release.bz2 CicadaDemo_release
}
function build_mac(){
if [[ -n "$MTL" ]];then
export HOMEBREW_NO_AUTO_UPDATE=true
fi
check_brew
if [[ -n "$MTL" ]];then
check_cmake
else
check_tool "cmake"
fi
check_tool "yasm"
check_tool "automake"
if [[ $? -ne 0 ]]; then
return 1
fi
cd ${TOP_DIR}/external
./build_external.sh macOS
if [[ $? -ne 0 ]]; then
echo "build_external break"
return 1
fi
DEMO_SOURCE_DIR_MAC=${TOP_DIR}/platform/Apple/demo/macOS
cd ${DEMO_SOURCE_DIR_MAC}
./Genxcodeproj.sh
if [[ -n "$MTL" ]];then
packet_mac
fi
cd ${TOP_DIR}
}