| 7 |
| set(CMAKE_CXX_FLAGS "-DANDROID -g") |
| 8 | set(CMAKE_C_FLAGS "-w -std=c11 -DANDROID -D_LARGEFILE_SOURCE=1 -g -Wno-error=implicit-function-declaration") |
| 9 | set(CMAKE_ASM_FLAGS "${CFLAGS} -x assembler-with-cpp") |
| 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -flto=full") |
| 11 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -flto=full") |
| 12 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -flto=full -Wl,--gc-sections -Wl,--icf=safe -Wl,-Bsymbolic") |
| 13 |
| 14 | if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a") |
| 15 | enable_language(ASM) |
| 16 | else() |
| 17 | enable_language(ASM_NASM) |
| 18 | endif() |
| 19 |
| 20 | set(CAN_COMPILE_SME FALSE CACHE INTERNAL "Disable libyuv SME" FORCE) |
| 21 | add_subdirectory( |
| 22 | third_party/libyuv |
| 23 | ${CMAKE_CURRENT_BINARY_DIR}/libyuv |
| 24 | EXCLUDE_FROM_ALL) |
| 25 |
| 26 | # Abseil |
| 27 | set(ABSL_PROPAGATE_CXX_STD ON) |
| 28 | set(ABSL_BUILD_TESTING OFF) |
| 29 | set(ABSL_ENABLE_INSTALL OFF) |
| 30 | add_subdirectory( |
| 31 | third_party/absl |
| 32 | ${CMAKE_CURRENT_BINARY_DIR}/absl |
| 33 | EXCLUDE_FROM_ALL) |
| 34 |
| 35 | add_library(webrtc_absl INTERFACE) |
| 36 | target_link_libraries(webrtc_absl INTERFACE |
| 37 | absl::base |
| 38 | absl::strings |
| 39 | absl::str_format |
| 40 | absl::cord |
| 41 | absl::synchronization |
| 42 | absl::time |
| 43 | absl::status |
| 44 | absl::statusor |
| 45 | absl::hash |
| 46 | absl::flat_hash_map |
| 47 | absl::flat_hash_set |
| 48 | absl::flags |
| 49 | absl::flags_parse |
| 50 | absl::random_random |
| 51 | absl::random_distributions |
| 52 | absl::crc32c |
| 53 | absl::log |
| 54 | absl::check |
| 55 | ) |
| 56 |
| 57 | add_library(avutil STATIC IMPORTED) |
| 58 | set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavutil.a) |
| 59 |
| 60 | add_library(avformat STATIC IMPORTED) |
| 61 | set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavformat.a) |
| 62 |
| 63 | add_library(avcodec STATIC IMPORTED) |
| 64 | set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libavcodec.a) |
| 65 |
| 66 | add_library(swresample STATIC IMPORTED) |
| 67 | set_target_properties(swresample PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libswresample.a) |
| 68 |
| 69 | add_library(swscale STATIC IMPORTED) |
| 70 | set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libswscale.a) |
| 71 |
| 72 | add_library(crypto STATIC IMPORTED) |
| 73 | set_target_properties(crypto PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libcrypto.a) |
| 74 |
| 75 | add_library(ssl STATIC IMPORTED) |
| 76 | set_target_properties(ssl PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libssl.a) |
| 77 |
| 78 |
| 79 | #aesige |
| 80 | #add_library(aesige STATIC openssl/aes_ige.c) |
| 81 | #target_compile_options(aesige PUBLIC -Wall -frtti -finline-functions -ffast-math -Oz) |
| 82 | #target_include_directories(aesige PUBLIC third_party/boringssl/include openssl/include) |
| 83 | #target_link_libraries(aesige crypto) |
| 84 |
| 85 |
| 86 | add_library(libvpx STATIC IMPORTED) |
| 87 | set_target_properties(libvpx PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libvpx.a) |
| 88 |
| 89 | add_library(libdav1d STATIC IMPORTED) |
| 90 | set_target_properties(libdav1d PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libdav1d.a) |
| 91 |
| 92 | add_library(libopus STATIC IMPORTED) |
| 93 | set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libopus.a) |
| 94 |
| 95 | add_library(tde2e STATIC IMPORTED) |
| 96 | set_target_properties(tde2e PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtde2e.a) |
| 97 |
| 98 | add_library(tdutils STATIC IMPORTED) |
| 99 | set_target_properties(tdutils PROPERTIES IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtdutils.a) |
| 100 |
| 101 | #tgnet |
| 102 | add_library(tgnet STATIC |
| 103 | openssl/aes_ige.c |
| 104 | tgnet/ApiScheme.cpp |
| 105 | tgnet/BuffersStorage.cpp |
| 106 | tgnet/ByteArray.cpp |
| 107 | tgnet/ByteStream.cpp |
| 108 | tgnet/Connection.cpp |
| 109 | tgnet/ConnectionSession.cpp |
| 110 | tgnet/ConnectionsManager.cpp |
| 111 | tgnet/TLSHello.cpp |
| 112 | tgnet/ConnectionSocket.cpp |
| 113 | tgnet/Datacenter.cpp |
| 114 | tgnet/EventObject.cpp |
| 115 | tgnet/FileLog.cpp |
| 116 | tgnet/MTProtoScheme.cpp |
| 117 | tgnet/NativeByteBuffer.cpp |
| 118 | tgnet/Request.cpp |
| 119 | tgnet/Timer.cpp |
| 120 | tgnet/TLObject.cpp |
| 121 | tgnet/ProxyCheckInfo.cpp |
| 122 | tgnet/Handshake.cpp |
| 123 | tgnet/Config.cpp) |
| 124 | target_compile_options(tgnet PUBLIC |
| 125 | -Wall -frtti -finline-functions -ffast-math -Oz) |
| 126 | set_target_properties(tgnet PROPERTIES |
| 127 | ANDROID_ARM_MODE arm) |
| 128 | target_compile_definitions(tgnet PUBLIC |
| 129 | HAVE_PTHREAD) |
| 130 | target_include_directories(tgnet PUBLIC |
| 131 | third_party/boringssl/include |
| 132 | openssl/include) |
| 133 | target_link_libraries(tgnet |
| 134 | crypto) |
| 135 |
| 136 | # tlottie (prebuilt Rust static library) |
| 137 | add_library(tlottie STATIC IMPORTED) |
| 138 | set_target_properties(tlottie PROPERTIES |
| 139 | IMPORTED_LOCATION ${CMAKE_HOME_DIRECTORY}/prebuild/lib/${ANDROID_ABI}/libtlottie.a) |
| 140 |
| 141 | #sqlite |
| 142 | add_library(sqlite STATIC |
| 143 | sqlite/sqlite3.c) |
| 144 | target_compile_options(sqlite PUBLIC |
| 145 | -fno-strict-aliasing -Oz) |
| 146 | set_target_properties(sqlite PROPERTIES |
| 147 | ANDROID_ARM_MODE arm) |
| 148 | target_compile_definitions(sqlite PUBLIC |
| 149 | NULL=0 SOCKLEN_T=socklen_t LOCALE_NOT_USED ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE HAVE_STRCHRNUL=0 ANDROID_ARMV6_IDCT) |
| 150 |
| 151 | #breakpad |
| 152 | add_library(breakpad STATIC |
| 153 | third_party/breakpad/src/client/linux/crash_generation/crash_generation_client.cc |
| 154 | third_party/breakpad/src/client/linux/handler/exception_handler.cc |
| 155 | third_party/breakpad/src/client/linux/handler/minidump_descriptor.cc |
| 156 | third_party/breakpad/src/client/linux/log/log.cc |
| 157 | third_party/breakpad/src/client/linux/dump_writer_common/thread_info.cc |
| 158 | third_party/breakpad/src/client/linux/dump_writer_common/seccomp_unwinder.cc |
| 159 | third_party/breakpad/src/client/linux/dump_writer_common/ucontext_reader.cc |
| 160 | third_party/breakpad/src/client/linux/microdump_writer/microdump_writer.cc |
| 161 | third_party/breakpad/src/client/linux/minidump_writer/linux_dumper.cc |
| 162 | third_party/breakpad/src/client/linux/minidump_writer/linux_ptrace_dumper.cc |
| 163 | third_party/breakpad/src/client/linux/minidump_writer/minidump_writer.cc |
| 164 | third_party/breakpad/src/client/minidump_file_writer.cc |
| 165 | third_party/breakpad/src/common/android/breakpad_getcontext.S |
| 166 | third_party/breakpad/src/common/convert_UTF.c |
| 167 | third_party/breakpad/src/common/md5.cc |
| 168 | third_party/breakpad/src/common/string_conversion.cc |
| 169 | third_party/breakpad/src/common/linux/elfutils.cc |
| 170 | third_party/breakpad/src/common/linux/file_id.cc |
| 171 | third_party/breakpad/src/common/linux/guid_creator.cc |
| 172 | third_party/breakpad/src/common/linux/linux_libc_support.cc |
| 173 | third_party/breakpad/src/common/linux/memory_mapped_file.cc |
| 174 | third_party/breakpad/src/common/linux/safe_readlink.cc) |
| 175 | set_target_properties(breakpad PROPERTIES ANDROID_ARM_MODE arm) |
| 176 | set_property(SOURCE third_party/breakpad/src/common/android/breakpad_getcontext.S PROPERTY LANGUAGE C) |
| 177 | target_include_directories(breakpad PUBLIC |
| 178 | third_party/breakpad/src/common/android/include |
| 179 | third_party/breakpad/src) |
| 180 |
| 181 |
| 182 | #voip |
| 183 | include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt) |
| 184 |
| 185 | set(NATIVE_LIB "tmessages.49") |
| 186 |
| 187 | #tmessages |
| 188 | add_library(${NATIVE_LIB} SHARED |
| 189 | jni.c |
| 190 | audio.c |
| 191 | webm_encoder.c |
| 192 | image.cpp |
| 193 | intro/IntroRenderer.c |
| 194 | SqliteWrapper.cpp |
| 195 | utilities.cpp |
| 196 | gifvideo.cpp |
| 197 | lottie.cpp |
| 198 | TgNetWrapper.cpp |
| 199 | ffmpeg_jni.cc |
| 200 | fast-edge.cpp |
| 201 | genann.c |
| 202 | secureid_ocr.cpp |
| 203 | tde2e/bridge.cpp |
| 204 | tests.cpp |
| 205 | ) |
| 206 |
| 207 | target_compile_options(${NATIVE_LIB} PUBLIC |
| 208 | -ffast-math -Oz -funroll-loops -ffast-math -fno-strict-aliasing -fno-math-errno) |
| 209 |
| 210 | target_compile_definitions(${NATIVE_LIB} PUBLIC |
| 211 | BSD=1 NULL=0 SOCKLEN_T=socklen_t ANDROID_NDK DISABLE_IMPORTGL AVOID_TABLES ANDROID_TILE_BASED_DECODE __STDC_CONSTANT_MACROS ANDROID_ARMV6_IDCT OPUS_BUILD FIXED_POINT USE_ALLOCA restrict= __EMX__ LOCALE_NOT_USED HAVE_LRINT HAVE_LRINTF) |
| 212 |
| 213 | target_sources(${NATIVE_LIB} PRIVATE |
| 214 |
| 215 | third_party/xiph/opusfile/src/info.c |
| 216 | third_party/xiph/opusfile/src/internal.c |
| 217 | third_party/xiph/opusfile/src/opusfile.c |
| 218 | third_party/xiph/opusfile/src/stream.c |
| 219 | third_party/xiph/ogg/src/bitwise.c |
| 220 | third_party/xiph/ogg/src/framing.c) |
| 221 |
| 222 | target_include_directories(${NATIVE_LIB} PUBLIC |
| 223 | third_party/xiph/opus/include |
| 224 | third_party/xiph/opus/silk |
| 225 | third_party/xiph/opus/silk/fixed |
| 226 | third_party/xiph/opus/celt |
| 227 | third_party/xiph/opus |
| 228 | third_party/xiph/opusfile/include |
| 229 | third_party/xiph/ogg/include |
| 230 | third_party/libyuv/include |
| 231 | third_party/absl |
| 232 | third_party/boringssl/include |
| 233 | openssl/include |
| 234 | prebuild/include/${ANDROID_ABI} |
| 235 | third_party/ffmpeg |
| 236 | third_party/libvpx |
| 237 | third_party/dav1d/include |
| 238 | emoji |
| 239 | exoplayer/include |
| 240 | intro |
| 241 | tlottie/include |
| 242 | tgcalls/ |
| 243 | webrtc/ |
| 244 | td/tde2e |
| 245 | td/tde2e/td/e2e |
| 246 | ) |
| 247 |
| 248 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,max-page-size=16384") |
| 249 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,-z,common-page-size=16384") |
| 250 | target_link_options(${NATIVE_LIB} PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports.map") |
| 251 | target_link_libraries(${NATIVE_LIB} |
| 252 | -Wl,--whole-archive rnnoise openh264 voipandroid -Wl,--no-whole-archive |
| 253 | webrtc_absl |
| 254 | tgcalls |
| 255 | wasm |
| 256 | tgcalls_tp |
| 257 | tgnet |
| 258 | tlottie |
| 259 | sqlite |
| 260 | swscale |
| 261 | avformat |
| 262 | avcodec |
| 263 | swresample |
| 264 | libvpx |
| 265 | libdav1d |
| 266 | libopus |
| 267 | tde2e |
| 268 | tdutils |
| 269 | yuv |
| 270 | avutil |
| 271 | ssl |
| 272 | crypto |
| 273 | jnigraphics |
| 274 | log |
| 275 | z |
| 276 | GLESv2 |
| 277 | EGL |
| 278 | android |
| 279 | OpenSLES |
| 280 | cpufeatures |
| 281 | breakpad) |
| 282 |
| 283 | #if (${ANDROID_ABI} STREQUAL "x86" OR ${ANDROID_ABI} STREQUAL "x86_64") |
| 284 | # target_link_libraries(${NATIVE_LIB} |
| 285 | # -Wl,--whole-archive vpxasm -Wl,--no-whole-archive |
| 286 | # c) |
| 287 | #endif() |
| 288 |
| 289 | include(AndroidNdkModules) |
| 290 | android_ndk_import_module_cpufeatures() |
| 291 |