forked from intermedia-net/pjproject-android-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·157 lines (127 loc) · 5.8 KB
/
build
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
#!/bin/bash -e
# @author Aleksandar Gotev ([email protected])
# @author Vincenzo Esposito ([email protected])
. config.conf
PJSIP_TMP_PATH="/tmp/pjsip"
CONFIG_SITE_PATH="${PJSIP_BASE_PATH}/pjlib/include/pj/config_site.h"
PJSUA_BASE_DIR="${PJSIP_TMP_PATH}/pjsip-apps/src/swig"
PJSUA_GENERATED_SRC_DIR="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/java/"
PJSUA_GENERATED_SO_PATH="${PJSUA_BASE_DIR}/java/android/$PJSIP_GENERATED_ROOT_DIR_NAME/src/main/jniLibs"
FINAL_BUILD_DIR=$PJSIP_BUILD_OUT_PATH
FINAL_BUILD_LIB="${FINAL_BUILD_DIR}/lib"
FINAL_BUILD_LOGS="${FINAL_BUILD_DIR}/logs"
FINAL_BUILD_INCLUDES="${FINAL_BUILD_DIR}/includes"
export ANDROID_NDK_ROOT="${DOWNLOAD_DIR}/${NDK_DIR_NAME}"
export PATH="$ANDROID_NDK_ROOT:$PATH"
##############################################################################
############################ FUNCTIONS ##############################
##############################################################################
function clearBuildDirectory {
echo "Make build folders ..."
mkdir -p "${FINAL_BUILD_LIB}"
mkdir -p "${FINAL_BUILD_LOGS}"
mkdir -p "${FINAL_BUILD_INCLUDES}"
}
function setConfigSite {
echo "Creating config site file for Android ..."
echo "#define PJ_CONFIG_ANDROID 1" > "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_G7221_CODEC 1" >> "$CONFIG_SITE_PATH"
echo "#include <pj/config_site_sample.h>" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_VIDEO 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_VIDEO_DEV_HAS_ANDROID 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_AUDIO_DEV_HAS_ANDROID_JNI 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_AUDIO_DEV_HAS_OPENSL 1" >> "$CONFIG_SITE_PATH"
echo "#define PJSIP_AUTH_AUTO_SEND_NEXT 0" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_OPUS_CODEC 1" >> "$CONFIG_SITE_PATH"
echo "#define PJSUA_DETECT_MERGED_REQUESTS 0" >> "$CONFIG_SITE_PATH"
echo "#define PJ_HAS_IPV6 1" >> "$CONFIG_SITE_PATH"
echo "#define PJMEDIA_HAS_BCG729 1" >> "$CONFIG_SITE_PATH"
echo "#define PJSIP_TRANSPORT_IDLE_TIME 1" >> "$CONFIG_SITE_PATH"
}
function buildPjSip {
arch=$1
echo "Compile PJSIP for arch $arch ..."
rm -rf "${PJSIP_TMP_PATH}"
mkdir -p "${PJSIP_TMP_PATH}"
cd "${PJSIP_BASE_PATH}"
cp -r * "${PJSIP_TMP_PATH}"
cd "${PJSIP_TMP_PATH}"
args=("--use-ndk-cflags"
"--enable-libwebrtc-aec3"
"--with-ssl=${OPENSSL_BUILD_OUT_PATH}/libs/${arch}"
"--with-opus=${OPUS_BUILD_OUT_PATH}/libs/${arch}"
"--with-bcg729=${BCG729_BUILD_OUT_PATH}/libs/${arch}")
APP_PLATFORM=android-${TARGET_ANDROID_API} TARGET_ABI=$arch ./configure-android "${args[@]}" >> "${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
make dep >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
make clean >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
make >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
echo "Compile PJSUA for arch $arch ..."
cd "${PJSUA_BASE_DIR}"
make >>"${FINAL_BUILD_LOGS}/${arch}.log" 2>&1
echo "Copying PJSUA .so library to final build directory ..."
mkdir -p "${FINAL_BUILD_LIB}/${arch}"
# Different versions of PJSIP put .so libs in different directory name
# using /*/* we assume there is only one directory (whatever its name is)
# and retrieve all its content (.so libs)
mv "${PJSUA_GENERATED_SO_PATH}"/*/* "${FINAL_BUILD_LIB}/${arch}"
# Copy headers
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjlib"
cp -r "${PJSIP_TMP_PATH}/pjlib/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjlib"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjlib-util"
cp -r "${PJSIP_TMP_PATH}/pjlib-util/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjlib-util"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjmedia"
cp -r "${PJSIP_TMP_PATH}/pjmedia/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjmedia"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjnath"
cp -r "${PJSIP_TMP_PATH}/pjnath/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjnath"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjnat64"
cp -r "${PJSIP_TMP_PATH}/pjnat64/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjnat64"
mkdir -p "${FINAL_BUILD_INCLUDES}/${arch}/pjsip"
cp -r "${PJSIP_TMP_PATH}/pjsip/include"/* "${FINAL_BUILD_INCLUDES}/${arch}/pjsip"
}
function copyPjSuaJava {
echo "Copying PJSUA2 java bindings to final build directory ..."
cp -r "${PJSUA_GENERATED_SRC_DIR}" "${FINAL_BUILD_DIR}"
rm -r "${PJSIP_TMP_PATH}"
}
function clearToolsDirectory {
if [ "$REMOVE_TOOLS" == "1" ]
then
echo ""
echo "Cleaning up tools ..."
cd $BASEDIR
rm -r tools
echo "Finished cleaning up tools"
fi
}
function setPermissions {
if [ "$SET_PERMISSIONS" == "1" ] && [ "$OWNER" != "" ]
then
echo ""
echo "Setting permissions on $BUILD_DIR for user $OWNER"
chown $OWNER -R $BUILD_DIR
echo "Finished Setting permissions"
elif [ "$SET_PERMISSIONS" == "1" ] || [ "$OWNER" != "" ]
then
echo "You must set both the toggle [SET_PERMISSIONS] to 1 and the name of the user [OWNER] that should own the files"
fi
}
##############################################################################
############################ MAIN ############################
##############################################################################
# Clearing the build output directory
clearBuildDirectory
# Create config_site file
setConfigSite
# Build PjSip for each ARCH specified in config.conf
for arch in "${TARGET_ARCHS[@]}"
do
buildPjSip $arch
done
# Copy PjSua Java Bindings into final build output directory
copyPjSuaJava
# Delete the tools directory
clearToolsDirectory
# Setting Permission on build output directory
setPermissions
echo "Finished! Check the generated output in ${FINAL_BUILD_DIR}"