forked from bilibili/ijkplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile-ijk.sh
executable file
·123 lines (113 loc) · 3.11 KB
/
compile-ijk.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
#! /usr/bin/env bash
#
# Copyright (C) 2013-2014 Zhang Rui <[email protected]>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
if [ -z "$ANDROID_NDK" -o -z "$ANDROID_NDK" ]; then
echo "You must define ANDROID_NDK, ANDROID_SDK before starting."
echo "They must point to your NDK and SDK directories.\n"
exit 1
fi
REQUEST_TARGET=$1
REQUEST_SUB_CMD=$2
ACT_ABI_32="armv5 armv7a x86"
ACT_ABI_64="armv5 armv7a arm64 x86 x86_64"
ACT_ABI_ALL=$ACT_ABI_64
UNAME_S=$(uname -s)
FF_MAKEFLAGS=
if which nproc >/dev/null
then
FF_MAKEFLAGS=-j`nproc`
elif [ "$UNAME_S" = "Darwin" ] && which sysctl >/dev/null
then
FF_MAKEFLAGS=-j`sysctl -n machdep.cpu.thread_count`
fi
do_sub_cmd () {
SUB_CMD=$1
if [ -L "./android-ndk-prof" ]; then
rm android-ndk-prof
fi
if [ "$PARAM_SUB_CMD" = 'prof' ]; then
echo 'profiler build: YES';
ln -s ../../../../../../ijkprof/android-ndk-profiler/jni android-ndk-prof
else
echo 'profiler build: NO';
ln -s ../../../../../../ijkprof/android-ndk-profiler-dummy/jni android-ndk-prof
fi
case $SUB_CMD in
prof)
$ANDROID_NDK/ndk-build $FF_MAKEFLAGS
;;
clean)
$ANDROID_NDK/ndk-build clean
;;
rebuild)
$ANDROID_NDK/ndk-build clean
$ANDROID_NDK/ndk-build $FF_MAKEFLAGS
;;
*)
$ANDROID_NDK/ndk-build $FF_MAKEFLAGS
;;
esac
}
do_ndk_build () {
PARAM_TARGET=$1
PARAM_SUB_CMD=$2
case "$PARAM_TARGET" in
armv5|armv7a)
cd "ijkplayer/ijkplayer-$PARAM_TARGET/src/main/jni"
do_sub_cmd $PARAM_SUB_CMD
cd -
;;
arm64|x86|x86_64)
cd "ijkplayer/ijkplayer-$PARAM_TARGET/src/main/jni"
if [ "$PARAM_SUB_CMD" = 'prof' ]; then PARAM_SUB_CMD=''; fi
do_sub_cmd $PARAM_SUB_CMD
cd -
;;
esac
}
case "$REQUEST_TARGET" in
"")
do_ndk_build armv7a;
;;
armv5|armv7a|arm64|x86|x86_64)
do_ndk_build $REQUEST_TARGET $REQUEST_SUB_CMD;
;;
all32)
for ABI in $ACT_ABI_32
do
do_ndk_build "$ABI" $REQUEST_SUB_CMD;
done
;;
all|all64)
for ABI in $ACT_ABI_64
do
do_ndk_build "$ABI" $REQUEST_SUB_CMD;
done
;;
clean)
for ABI in $ACT_ABI_ALL
do
do_ndk_build "$ABI" clean;
done
;;
*)
echo "Usage:"
echo " compile-ijk.sh armv5|armv7a|arm64|x86|x86_64"
echo " compile-ijk.sh all|all32"
echo " compile-ijk.sh all64"
echo " compile-ijk.sh clean"
;;
esac