From d06ae837fee7cf2c117b150e9927b2eb082ad580 Mon Sep 17 00:00:00 2001 From: ausmuschang Date: Thu, 16 Apr 2020 15:22:50 +0800 Subject: [PATCH] 1.Split third_party CMakeLists.txt to three part to solve ExternalProject_Add build sequence problem. 2.Fix curdir issue. --- app/third_party/CMakeLists.txt | 55 ------------------- app/third_party/CMakeLists_libogg.txt | 18 ++++++ app/third_party/CMakeLists_libopus.txt | 18 ++++++ app/third_party/CMakeLists_opus-tools.txt | 23 ++++++++ app/third_party/build/build_all.sh | 12 ++++ app/third_party/build/include_files_helper.sh | 3 +- 6 files changed, 73 insertions(+), 56 deletions(-) delete mode 100644 app/third_party/CMakeLists.txt create mode 100644 app/third_party/CMakeLists_libogg.txt create mode 100644 app/third_party/CMakeLists_libopus.txt create mode 100644 app/third_party/CMakeLists_opus-tools.txt diff --git a/app/third_party/CMakeLists.txt b/app/third_party/CMakeLists.txt deleted file mode 100644 index f78b276..0000000 --- a/app/third_party/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -include(ExternalProject) - -set(libopus_src ${CMAKE_CURRENT_SOURCE_DIR}/libopus/src) -ExternalProject_Add(external_libopus - GIT_REPOSITORY "https://github.com/xiph/opus" - GIT_TAG "ad8fe90db79b7d2a135e3dfd2ed6631b0c5662ab" - SOURCE_DIR "${libopus_src}" - CONFIGURE_COMMAND ${CMAKE_COMMAND} ${libopus_src} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DANDROID_ABI=${ANDROID_ABI} - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/libopus/${ANDROID_ABI} - INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install - && - ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/build/libopus/${ANDROID_ABI}/lib/libopus.a - ${CMAKE_CURRENT_SOURCE_DIR}/libopus/lib/${ANDROID_ABI}/ - ) - -set(opus_tools_src ${CMAKE_CURRENT_SOURCE_DIR}/opus_tools/src) -ExternalProject_Add(external_opus_tools - GIT_REPOSITORY "https://github.com/xiph/opus-tools/" - GIT_TAG "14f650f64260115098d55fb91e1f83110cb628d3" - SOURCE_DIR "${opus_tools_src}" - CONFIGURE_COMMAND . ${CMAKE_CURRENT_SOURCE_DIR}/build/include_files_helper.sh ${CMAKE_CURRENT_SOURCE_DIR}/build/ - COMMAND ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI}/include/ogg/config_types.h - ${CMAKE_CURRENT_SOURCE_DIR}/../src/main/cpp/libogg/ - COMMAND ${CMAKE_COMMAND} ${opus_tools_src} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DANDROID_ABI=${ANDROID_ABI} - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI} - BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI}/lib/ - INSTALL_COMMAND "" - COMMAND - ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI}/lib/libopus_header.a - ${CMAKE_CURRENT_SOURCE_DIR}/opus_tools/lib/${ANDROID_ABI}/ - ) - -set(libogg_src ${CMAKE_CURRENT_SOURCE_DIR}/libogg/src) -ExternalProject_Add(external_libogg - GIT_REPOSITORY "https://github.com/xiph/ogg.git" - GIT_TAG "934385378f45f11586b03b6214bf5f363649f3b6" - SOURCE_DIR "${libogg_src}" - CONFIGURE_COMMAND ${CMAKE_COMMAND} ${libogg_src} - -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} - -DANDROID_ABI=${ANDROID_ABI} - -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI} - INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install - && - ${CMAKE_COMMAND} -E copy - ${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI}/lib/libogg.a - ${CMAKE_CURRENT_SOURCE_DIR}/libogg/lib/${ANDROID_ABI}/ - ) diff --git a/app/third_party/CMakeLists_libogg.txt b/app/third_party/CMakeLists_libogg.txt new file mode 100644 index 0000000..d6aebdf --- /dev/null +++ b/app/third_party/CMakeLists_libogg.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.4.1) +include(ExternalProject) + +set(libogg_src ${CMAKE_CURRENT_SOURCE_DIR}/libogg/src) +ExternalProject_Add(external_libogg + GIT_REPOSITORY "https://github.com/xiph/ogg.git" + GIT_TAG "934385378f45f11586b03b6214bf5f363649f3b6" + SOURCE_DIR "${libogg_src}" + CONFIGURE_COMMAND ${CMAKE_COMMAND} ${libogg_src} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DANDROID_ABI=${ANDROID_ABI} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI} + INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install + && + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI}/lib/libogg.a + ${CMAKE_CURRENT_SOURCE_DIR}/libogg/lib/${ANDROID_ABI}/ + ) diff --git a/app/third_party/CMakeLists_libopus.txt b/app/third_party/CMakeLists_libopus.txt new file mode 100644 index 0000000..d27ff0e --- /dev/null +++ b/app/third_party/CMakeLists_libopus.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.4.1) +include(ExternalProject) + +set(libopus_src ${CMAKE_CURRENT_SOURCE_DIR}/libopus/src) +ExternalProject_Add(external_libopus + GIT_REPOSITORY "https://github.com/xiph/opus" + GIT_TAG "ad8fe90db79b7d2a135e3dfd2ed6631b0c5662ab" + SOURCE_DIR "${libopus_src}" + CONFIGURE_COMMAND ${CMAKE_COMMAND} ${libopus_src} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DANDROID_ABI=${ANDROID_ABI} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/libopus/${ANDROID_ABI} + INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install + && + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/build/libopus/${ANDROID_ABI}/lib/libopus.a + ${CMAKE_CURRENT_SOURCE_DIR}/libopus/lib/${ANDROID_ABI}/ + ) diff --git a/app/third_party/CMakeLists_opus-tools.txt b/app/third_party/CMakeLists_opus-tools.txt new file mode 100644 index 0000000..d2e3deb --- /dev/null +++ b/app/third_party/CMakeLists_opus-tools.txt @@ -0,0 +1,23 @@ +cmake_minimum_required(VERSION 3.4.1) +include(ExternalProject) + +set(opus_tools_src ${CMAKE_CURRENT_SOURCE_DIR}/opus_tools/src) +ExternalProject_Add(external_opus_tools + GIT_REPOSITORY "https://github.com/xiph/opus-tools/" + GIT_TAG "14f650f64260115098d55fb91e1f83110cb628d3" + SOURCE_DIR "${opus_tools_src}" + CONFIGURE_COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/build/include_files_helper.sh ${CMAKE_CURRENT_SOURCE_DIR}/build/ + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/build/libogg/${ANDROID_ABI}/include/ogg/config_types.h + ${CMAKE_CURRENT_SOURCE_DIR}/../src/main/cpp/libogg/ + COMMAND ${CMAKE_COMMAND} ${opus_tools_src} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DANDROID_ABI=${ANDROID_ABI} + -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI} + BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI}/lib/ + INSTALL_COMMAND "" + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_BINARY_DIR}/build/opus_tools/${ANDROID_ABI}/lib/libopus_header.a + ${CMAKE_CURRENT_SOURCE_DIR}/opus_tools/lib/${ANDROID_ABI}/ + ) diff --git a/app/third_party/build/build_all.sh b/app/third_party/build/build_all.sh index 42f906c..170047a 100755 --- a/app/third_party/build/build_all.sh +++ b/app/third_party/build/build_all.sh @@ -28,9 +28,21 @@ do if [ ! -d ../out ]; then mkdir ../out fi + cp ../CMakeLists_libogg.txt ../CMakeLists.txt cd ../out cmake -DCMAKE_TOOLCHAIN_FILE="${NDK_PATH}"/build/cmake/android.toolchain.cmake -DANDROID_ABI=${android_abi[$i]} .. make + echo "Ogg for ${android_abi[$i]} build done." + cp ../CMakeLists_libopus.txt ../CMakeLists.txt + cd ../out + cmake -DCMAKE_TOOLCHAIN_FILE="${NDK_PATH}"/build/cmake/android.toolchain.cmake -DANDROID_ABI=${android_abi[$i]} .. + make + echo "Opus for ${android_abi[$i]} build done." + cp ../CMakeLists_opus-tools.txt ../CMakeLists.txt + cd ../out + cmake -DCMAKE_TOOLCHAIN_FILE="${NDK_PATH}"/build/cmake/android.toolchain.cmake -DANDROID_ABI=${android_abi[$i]} .. + make + echo "Opus-tools for ${android_abi[$i]} build done." cd ../build rm -rf ../out done diff --git a/app/third_party/build/include_files_helper.sh b/app/third_party/build/include_files_helper.sh index fcbc1f8..dd2db2e 100644 --- a/app/third_party/build/include_files_helper.sh +++ b/app/third_party/build/include_files_helper.sh @@ -1,8 +1,9 @@ +#!/bin/bash # To get the third party deps to build, we do some string replacement in the # headers. In principle, this should be done with include paths, but since # users of our tool probably have their own means of managing dependencies, # this is good enough for our purposes. -curdir=$1 +curdir=$(dirname "$0")/ echo "current dir is $curdir" if [ ! -d ${curdir}../../src/main/cpp/libogg ]; then mkdir ${curdir}../../src/main/cpp/libogg