From 1719f4a4748b7ace4fd07a214c61558ccedce794 Mon Sep 17 00:00:00 2001 From: Gabriel Calero Date: Fri, 5 Oct 2018 23:49:06 -0300 Subject: [PATCH] Build libplugins_libhifiCodec.so --- android/app/CMakeLists.txt | 2 ++ android/app/build.gradle | 2 ++ android/build.gradle | 28 +++++++++++++++++++------ cmake/macros/TargetHifiAudioCodec.cmake | 22 +++++++++++++++++++ plugins/hifiCodec/CMakeLists.txt | 5 +---- 5 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 cmake/macros/TargetHifiAudioCodec.cmake diff --git a/android/app/CMakeLists.txt b/android/app/CMakeLists.txt index d24a84c6a5..9930a9e152 100644 --- a/android/app/CMakeLists.txt +++ b/android/app/CMakeLists.txt @@ -7,6 +7,8 @@ target_bullet() set(INTERFACE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../interface") add_subdirectory("${INTERFACE_DIR}" "libraries/interface") include_directories("${INTERFACE_DIR}/src") +set(HIFI_CODEC_PLUGIN_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../plugins/hifiCodec") +add_subdirectory("${HIFI_CODEC_PLUGIN_DIR}" "libraries/hifiCodecPlugin") target_link_libraries(native-lib android log m interface) diff --git a/android/app/build.gradle b/android/app/build.gradle index 24c067b176..13d3a0fc41 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -80,8 +80,10 @@ android { if (Os.isFamily(Os.FAMILY_UNIX)) { def uploadDumpSymsTask = rootProject.getTasksByName("uploadBreakpadDumpSyms${variant.name.capitalize()}", false).first() def runDumpSymsTask = rootProject.getTasksByName("runBreakpadDumpSyms${variant.name.capitalize()}", false).first() + def renameHifiACTask = rootProject.getTasksByName("renameHifiACTask${variant.name.capitalize()}", false).first() runDumpSymsTask.dependsOn(task) variant.assemble.dependsOn(uploadDumpSymsTask) + variant.assemble.dependsOn(renameHifiACTask) } } diff --git a/android/build.gradle b/android/build.gradle index aa7aa399b2..72015aab2e 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -143,11 +143,9 @@ def packages = [ includeLibs: ['libtbb.so', 'libtbbmalloc.so'], ], hifiAC: [ - file: 'libplugins_libhifiCodec.zip', - versionId: 'i31pW.qNbvFOXRxbyiJUxg3sphaFNmZU', - checksum: '9412a8e12c88a4096c1fc843bb9fe52d', - sharedLibFolder: '', - includeLibs: ['libplugins_libhifiCodec.so'] + baseUrl: 'http://s3.amazonaws.com/hifi-public/dependencies/', + file: 'codecSDK-android_armv8-2.0.zip', + checksum: '1cbef929675818fc64c4101b72f84a6a' ], etc2comp: [ file: 'etc2comp-patched-armv8-libcpp.tgz', @@ -367,7 +365,8 @@ task downloadDependencies { doLast { packages.each { entry -> def filename = entry.value['file']; - def url = baseUrl + filename; + def dependencyBaseUrl = entry.value['baseUrl'] + def url = (dependencyBaseUrl?.trim() ? dependencyBaseUrl : baseUrl) + filename; if (entry.value.containsKey('versionId')) { url = url + '?versionId=' + entry.value['versionId'] } @@ -668,6 +667,23 @@ task uploadBreakpadDumpSymsRelease(type:io.github.httpbuilderng.http.HttpTask, d } } +task renameHifiACTaskDebug() { + doLast { + def sourceFile = new File("${appDir}/build/intermediates/cmake/debug/obj/arm64-v8a/","libhifiCodec.so") + def destinationFile = new File("${appDir}/src/main/jniLibs/", "libplugins_libhifiCodec.so)") + copy { from sourceFile; into destinationFile.parent; rename(sourceFile.name, destinationFile.name) } + } +} +task renameHifiACTaskRelease(type: Copy) { + doLast { + doLast { + def sourceFile = new File("${appDir}/build/intermediates/cmake/release/obj/arm64-v8a/","libhifiCodec.so") + def destinationFile = new File("${appDir}/src/main/jniLibs/arm64-v8a", "libplugins_libhifiCodec.so") + copy { from sourceFile; into destinationFile.parent; rename(sourceFile.name, destinationFile.name) } + } + } +} + // FIXME this code is prototyping the desired functionality for doing build time binary dependency resolution. // See the comment on the qtBundle task above /* diff --git a/cmake/macros/TargetHifiAudioCodec.cmake b/cmake/macros/TargetHifiAudioCodec.cmake new file mode 100644 index 0000000000..98c24e684c --- /dev/null +++ b/cmake/macros/TargetHifiAudioCodec.cmake @@ -0,0 +1,22 @@ +# +# Copyright 2018 High Fidelity, Inc. +# Created by Gabriel Calero and Cristian Duarte on 2018/10/05 +# +# Distributed under the Apache License, Version 2.0. +# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +# +macro(TARGET_HIFIAUDIOCODEC) + if (ANDROID) + set(HIFIAC_INSTALL_DIR ${HIFI_ANDROID_PRECOMPILED}/hifiAC/codecSDK) + set(HIFIAC_LIB_DIR "${HIFIAC_INSTALL_DIR}/Release") + set(HIFIAC_INCLUDE_DIRS "${HIFIAC_INSTALL_DIR}/include" CACHE TYPE INTERNAL) + list(APPEND HIFIAC_LIBS "${HIFIAC_LIB_DIR}/libaudio.a") + set(HIFIAC_LIBRARIES ${HIFIAC_LIBS} CACHE TYPE INTERNAL) + else() + add_dependency_external_projects(hifiAudioCodec) + target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES}) + endif() + target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAC_INCLUDE_DIRS}) + target_link_libraries(${TARGET_NAME} ${HIFIAC_LIBRARIES}) +endmacro() diff --git a/plugins/hifiCodec/CMakeLists.txt b/plugins/hifiCodec/CMakeLists.txt index 9ecaf7b511..0d4f093fc2 100644 --- a/plugins/hifiCodec/CMakeLists.txt +++ b/plugins/hifiCodec/CMakeLists.txt @@ -9,10 +9,7 @@ set(TARGET_NAME hifiCodec) setup_hifi_client_server_plugin() link_hifi_libraries(audio plugins) -add_dependency_external_projects(hifiAudioCodec) -target_include_directories(${TARGET_NAME} PRIVATE ${HIFIAUDIOCODEC_INCLUDE_DIRS}) -target_link_libraries(${TARGET_NAME} ${HIFIAUDIOCODEC_LIBRARIES}) - +target_hifiAudioCodec() if (BUILD_SERVER) install_beside_console() endif ()