From 672c7e8688e0cc2ffc62be3c7245422921426cf8 Mon Sep 17 00:00:00 2001 From: luvletter2333 Date: Fri, 4 Feb 2022 15:06:59 +0800 Subject: [PATCH] Fix libvpx x86 build --- TMessagesProj/jni/CMakeLists.txt | 4 ---- TMessagesProj/jni/build_libvpx_clang.sh | 15 +++++++++++++-- TMessagesProj/jni/patches/libvpx_x86_fix.patch | 17 +++++++++++++++++ bin/init/libs.sh | 2 +- 4 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 TMessagesProj/jni/patches/libvpx_x86_fix.patch diff --git a/TMessagesProj/jni/CMakeLists.txt b/TMessagesProj/jni/CMakeLists.txt index fd43ea665..3825a097e 100644 --- a/TMessagesProj/jni/CMakeLists.txt +++ b/TMessagesProj/jni/CMakeLists.txt @@ -25,10 +25,6 @@ else() set(LINKER_FLAGS "${LINKER_FLAGS} -Wl,-exclude-libs,ALL -Wl,--gc-sections -Wl,--strip-all") endif() -message("CFLAGS ${C_FLAGS}") -message("CXX_FLAGS ${CXX_FLAGS}") - - if (${ANDROID_ABI} STREQUAL "armeabi-v7a" OR ${ANDROID_ABI} STREQUAL "arm64-v8a") enable_language(ASM) else() diff --git a/TMessagesProj/jni/build_libvpx_clang.sh b/TMessagesProj/jni/build_libvpx_clang.sh index 704c5c3a1..a443812fc 100755 --- a/TMessagesProj/jni/build_libvpx_clang.sh +++ b/TMessagesProj/jni/build_libvpx_clang.sh @@ -26,8 +26,11 @@ function build_one { export CPPFLAGS="${CFLAGS}" export CXXFLAGS="${CFLAGS} -std=c++11" export ASFLAGS="-D__ANDROID__" - export LDFLAGS="-L$${PLATFORM}/usr/lib" + export LDFLAGS="-L${PLATFORM}/usr/lib" + if [ "x86" = ${ARCH} ]; then + patch -p1 < ../patches/libvpx_x86_fix.patch + fi echo "Cleaning..." make clean || true @@ -60,6 +63,10 @@ function build_one { --disable-webm-io make -j$COMPILATION_PROC_COUNT install + + if [ "x86" = ${ARCH} ]; then + patch -p1 -R < ../patches/libvpx_x86_fix.patch + fi } function setCurrentPlatform { @@ -115,6 +122,7 @@ function build { for arg in "$@"; do case "${arg}" in x86_64) + ANDROID_API=21 ARCH=x86_64 ARCH_NAME=x86_64 PREBUILT_ARCH=x86_64 @@ -128,6 +136,7 @@ function build { build_one ;; x86) + ANDROID_API=21 ARCH=x86 ARCH_NAME=i686 PREBUILT_ARCH=x86 @@ -141,6 +150,7 @@ function build { build_one ;; arm64) + ANDROID_API=21 ARCH=arm64 ARCH_NAME=aarch64 PREBUILT_ARCH=aarch64 @@ -154,6 +164,7 @@ function build { build_one ;; arm) + ANDROID_API=21 ARCH=arm ARCH_NAME=arm PREBUILT_ARCH=arm @@ -173,7 +184,7 @@ function build { } if (( $# == 0 )); then - build x86_64 x86 arm arm64 + build x86 x86_64 arm arm64 else build $@ fi diff --git a/TMessagesProj/jni/patches/libvpx_x86_fix.patch b/TMessagesProj/jni/patches/libvpx_x86_fix.patch new file mode 100644 index 000000000..42e67640e --- /dev/null +++ b/TMessagesProj/jni/patches/libvpx_x86_fix.patch @@ -0,0 +1,17 @@ +Index: vpx_dsp/add_noise.c +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/vpx_dsp/add_noise.c b/vpx_dsp/add_noise.c +--- a/vpx_dsp/add_noise.c (revision 626ff35955c2c35b806b3e0ecf551a1a8611cdbf) ++++ b/vpx_dsp/add_noise.c (date 1643957537362) +@@ -18,6 +18,8 @@ + #include "vpx_dsp/postproc.h" + #include "vpx_ports/mem.h" + ++#define rand() ((int)lrand48()) ++ + void vpx_plane_add_noise_c(uint8_t *start, const int8_t *noise, int blackclamp, + int whiteclamp, int width, int height, int pitch) { + int i, j; diff --git a/bin/init/libs.sh b/bin/init/libs.sh index f9875e6ae..17296be3a 100755 --- a/bin/init/libs.sh +++ b/bin/init/libs.sh @@ -2,6 +2,6 @@ source "bin/init/env.sh" +bin/init/libs/libvpx.sh bin/init/libs/ffmpeg.sh bin/init/libs/boringssl.sh -bin/init/libs/libvpx.sh