Skip to content

Commit

Permalink
[infra] Update android build (#13406)
Browse files Browse the repository at this point in the history
This commit updates android toolchain cmake script
- Get shared stl c++ library path by find_library
- Support ARM Compute Library build on latest NDK

ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
  • Loading branch information
hseok-oh authored Jul 12, 2024
1 parent c063aa7 commit 9c65b9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ set(ANDROID_ABI arm64-v8a)
set(ANDROID_API_LEVEL 29)
set(ANDROID_PLATFORM android-${ANDROID_API_LEVEL})
set(ANDROID_STL c++_shared)
set(ANDROID_STL_LIB "${NDK_DIR}/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so")

# Find package in the host. `nnfw_find_package` won't work without this
# Others (library, path) will follow android.toolchain.cmake settings
Expand All @@ -23,6 +22,8 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER)
# Use the toolchain file that NDK provides
include(${NDK_DIR}/build/cmake/android.toolchain.cmake)

find_library(ANDROID_STL_LIB c++_shared PATHS /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE})

# Install libc++_shared.so to lib folder
install(FILES ${ANDROID_STL_LIB} DESTINATION lib)

Expand Down
8 changes: 7 additions & 1 deletion infra/nnfw/cmake/packages/ARMComputeConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,14 @@ function(_ARMCompute_Build ARMComputeInstall_DIR)

set(SCONS_CC "gcc")
set(SCONS_CXX "g++")
# Refer https://android.googlesource.com/platform/external/armnn/+/HEAD/BuildGuideAndroidNDK.md#build-arm-compute-library
if(ANDROID)
list(APPEND SCONS_OPTIONS "toolchain_prefix=${ANDROID_TOOLCHAIN_PREFIX}")
if(ANDROID_NDK_MAJOR LESS 22)
# Use legacy toolchain
list(APPEND SCONS_OPTIONS "toolchain_prefix=${ANDROID_TOOLCHAIN_PREFIX}")
else(ANDROID_NDK_MAJOR LESS 22)
list(APPEND SCONS_OPTIONS "toolchain_prefix=${ANDROID_TOOLCHAIN_ROOT}/bin/llvm-")
endif(ANDROID_NDK_MAJOR LESS 22)
list(APPEND SCONS_OPTIONS "compiler_prefix=${ANDROID_TOOLCHAIN_ROOT}/bin/aarch64-linux-android${ANDROID_API_LEVEL}-")
set(SCONS_CC "clang")
set(SCONS_CXX "clang++")
Expand Down

0 comments on commit 9c65b9d

Please sign in to comment.