-
Notifications
You must be signed in to change notification settings - Fork 135
/
openh264-build-target-archs
executable file
·108 lines (86 loc) · 3.08 KB
/
openh264-build-target-archs
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
#!/bin/bash -e
set -e
# Source variables from config.conf file
. config.conf
##############################################################################
############################ FUNCTIONS ##############################
##############################################################################
function initialSetup {
NDK_PATH="$DOWNLOAD_DIR/$NDK_DIR_NAME"
SDK_TOOLS_PATH="$DOWNLOAD_DIR/${SDK_DIR_NAME}"/tools
OPENH264_SRC_PATH="$DOWNLOAD_DIR/${OPENH264_DIR_NAME}"
OPENH264_TMP_DIR="/tmp/openh264"
}
function setupPathsAndExports {
LIB_PATH="${OPENH264_BUILD_OUT_PATH}/libs"
LOG_PATH="${OPENH264_BUILD_OUT_PATH}/logs"
export ANDROID_NDK_HOME=$NDK_PATH
export ANDROID_HOME=$DOWNLOAD_DIR/${SDK_DIR_NAME}
export PATH=${SDK_TOOLS_PATH}:$PATH
}
function clearBuildDirectory {
rm -rf "${OPENH264_BUILD_OUT_PATH}"
mkdir -p "${LIB_PATH}"
mkdir -p "${LOG_PATH}"
}
function clearTmpAndInitDirectory {
rm -rf "${OPENH264_TMP_DIR}"
mkdir -p "${OPENH264_TMP_DIR}"
cd ${OPENH264_SRC_PATH}
cp -r * ${OPENH264_TMP_DIR}
cd ${OPENH264_TMP_DIR}
mkdir -p "$BUILD_DIR"
mkdir -p "${LIB_PATH}/${arch}"
mkdir -p "${LOG_PATH}"
}
function finalizeArgs {
arch=$1
if [ "$arch" == "armeabi" ]
then
ARGS="${ARGS}arm APP_ABI=armeabi"
elif [ "$arch" == "armeabi-v7a" ]
then
ARGS="${ARGS}arm"
elif [ "$arch" == "x86" ]
then
ARGS="${ARGS}x86 ENABLEPIC=Yes"
elif [ "$arch" == "x86_64" ]
then
ARGS="${ARGS}x86_64"
elif [ "$arch" == "arm64-v8a" ]
then
ARGS="${ARGS}arm64"
else
echo "Unsupported target ABI: $arch"
exit 1
fi
}
##############################################################################
############################ INIT ############################
##############################################################################
# Initial variables setup
initialSetup
# Set final paths and exports
setupPathsAndExports
# Clear and recreate the build output directory
clearBuildDirectory
##############################################################################
############################ MAIN ############################
##############################################################################
for arch in "${TARGET_ARCHS[@]}"
do
echo "Building OpenH264 for target arch $arch ..."
# Clear the tmp source directory
clearTmpAndInitDirectory
#change default output DIR for make install
sed -i "s*PREFIX=/usr/local*PREFIX=${LIB_PATH}/${arch}*g" Makefile
ARGS="APP_PLATFORM=android-${TARGET_ANDROID_API} OS=android NDKROOT=${NDK_PATH} NDK_TOOLCHAIN_VERSION=clang NDKLEVEL=${OPENH264_TARGET_NDK_LEVEL} "
ARGS="${ARGS}TARGET=android-${TARGET_ANDROID_API} ARCH="
# Add final architecture dependent info
finalizeArgs $arch
make ${ARGS} >> "${LOG_PATH}/${arch}.log" 2>&1
mkdir -p ${LIB_PATH}/${arch}
make ${ARGS} install >> "${LOG_PATH}/${arch}.log" 2>&1
done
echo "Finished building OpenH264! Check output folder: ${OPENH264_BUILD_OUT_PATH}"
set +e