Skip to content

Commit 4554e77

Browse files
committed
Added boringssl to the project + Universal build script for static cmake dependencies + Bump native library version to 221
1 parent 92f3176 commit 4554e77

File tree

7 files changed

+72
-1
lines changed

7 files changed

+72
-1
lines changed

‎.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,6 @@
6868
[submodule "vkryl/android"]
6969
path = vkryl/android
7070
url = https://github.com/TGX-Android/X-Android.git
71+
[submodule "app/jni/third_party/boringssl"]
72+
path = app/jni/third_party/boringssl
73+
url = https://github.com/google/boringssl

‎app/jni/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ set(TDLIB_DIR "${CMAKE_HOME_DIRECTORY}/../../tdlib")
1313
set(EXO_FLAC_DIR "${CMAKE_HOME_DIRECTORY}/../../thirdparty/ExoPlayer/extensions/flac/src/main/jni")
1414
set(UTILS_DIR "${THIRDPARTY_DIR}/jni-utils")
1515

16+
set(SSL_DIR "${THIRDPARTY_DIR}/boringssl")
17+
set(SSL_LIB_PATH "${SSL_DIR}/build/${ANDROID_ABI}/ssl/libssl.a")
18+
set(CRYPTO_LIB_PATH "${SSL_DIR}/build/${ANDROID_ABI}/crypto/libcrypto.a")
19+
1620
set(YUV_DIR "${THIRDPARTY_DIR}/libyuv")
1721
set(LZ4_DIR "${THIRDPARTY_DIR}/lz4/lib")
1822
set(RLOTTIE_DIR "${THIRDPARTY_DIR}/rlottie")
@@ -103,6 +107,8 @@ set(EXCLUDE_LIBS
103107
libopusfile.a
104108
librlottie.a
105109
liblz4.a
110+
"${SSL_LIB_PATH}"
111+
"${CRYPTO_LIB_PATH}"
106112
)
107113
if (${USE_WEBP})
108114
list(APPEND EXCLUDE_LIBS
@@ -137,6 +143,17 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.11.0")
137143
)
138144
endif()
139145

146+
# crypto
147+
148+
add_library(crypto STATIC IMPORTED)
149+
set_target_properties(crypto PROPERTIES IMPORTED_LOCATION "${CRYPTO_LIB_PATH}")
150+
151+
# ssl
152+
153+
add_library(ssl STATIC IMPORTED)
154+
set_target_properties(ssl PROPERTIES IMPORTED_LOCATION "${SSL_LIB_PATH}")
155+
target_include_directories(ssl INTERFACE "${SSL_DIR}/include")
156+
140157
# flac
141158

142159
ReadVariables("${EXO_FLAC_DIR}/flac_sources.mk")
@@ -925,6 +942,8 @@ target_link_libraries(${NATIVE_LIB}
925942
opus
926943
rlottie
927944
lz4
945+
ssl
946+
crypto
928947
)
929948
if (${USE_WEBP})
930949
target_link_libraries(${NATIVE_LIB} webpdecoder_static)

‎app/jni/third_party/boringssl

Submodule boringssl added at 46a1c7e

‎scripts/build-boringssl.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
# shellcheck source=set-env.sh
4+
source "$(dirname "$0")"/set-env.sh
5+
6+
run-cmake-impl.sh "$THIRDPARTY_LIBRARIES/boringssl" || (echo "boringssl build failed" && exit 1)

‎scripts/private/run-cmake-impl.sh

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
set -e
3+
4+
NDK_CMAKE_DIR="$ANDROID_SDK_ROOT/cmake/3.18.1"
5+
NDK_CMAKE_BIN="$NDK_CMAKE_DIR/bin/cmake"
6+
NDK_NINJA_BIN="$NDK_CMAKE_DIR/bin/ninja"
7+
TARGET_DIR="$1"
8+
9+
validate_file "$NDK_CMAKE_BIN"
10+
validate_file "$NDK_NINJA_BIN"
11+
validate_dir "$TARGET_DIR"
12+
13+
function run_cmake {
14+
ARG_ABI="$1"
15+
ARG_API_LEVEL="$2"
16+
test -d "$ARG_ABI" || mkdir "$ARG_ABI"
17+
pushd "$ARG_ABI" > /dev/null
18+
19+
$NDK_CMAKE_BIN -DANDROID_ABI="${ARG_ABI}" \
20+
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
21+
-DANDROID_NATIVE_API_LEVEL="${ARG_API_LEVEL}" \
22+
-GNinja ../..
23+
$NDK_NINJA_BIN
24+
25+
popd > /dev/null
26+
}
27+
28+
pushd "$TARGET_DIR"
29+
30+
test -d build || mkdir build
31+
pushd build > /dev/null
32+
33+
run_cmake arm64-v8a 21
34+
run_cmake armeabi-v7a 16
35+
run_cmake x86_64 21
36+
run_cmake x86 16
37+
38+
popd > /dev/null
39+
popd

‎scripts/setup.sh

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ patch-opus-impl.sh
2323
# Patch ExoPlayer sources
2424
patch-exoplayer-impl.sh
2525

26+
# Build boringssl
27+
run-cmake-impl.sh "$THIRDPARTY_LIBRARIES/boringssl"
28+
2629
# Build and configure libvpx
2730
build-vpx-impl.sh
2831

‎version.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ version.major=0
44
# Anchor date point in app versioning
55
version.creation=873642600564
66
# Native bundle (/app/jni)
7-
version.jni=220
7+
version.jni=221
88
# TDLib (/tdlib)
99
version.tdlib=89
1010
# LevelDB (/vkryl/leveldb)

0 commit comments

Comments
 (0)