Skip to content

Commit a1e3d48

Browse files
authored
Build Android in one pass (#12323)
### Summary Now trigger cmake once. Fixes #10120 ### Test plan CI
1 parent 97a61f4 commit a1e3d48

File tree

3 files changed

+6
-20
lines changed

3 files changed

+6
-20
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,4 +732,8 @@ if(EXECUTORCH_BUILD_VULKAN)
732732
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/backends/vulkan)
733733
endif()
734734

735+
if(EXECUTORCH_BUILD_ANDROID_JNI)
736+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/android)
737+
endif()
738+
735739
include(Test.cmake)

extension/android/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ set_target_properties(fbjni PROPERTIES
6161
)
6262

6363
set(executorch_DIR ${CMAKE_CURRENT_BINARY_DIR}/../../lib/cmake/ExecuTorch)
64-
find_package(executorch CONFIG REQUIRED)
6564
target_link_options_shared_lib(executorch)
6665

6766
add_library(executorch_jni SHARED jni/jni_layer.cpp jni/log.cpp jni/jni_layer_runtime.cpp)

scripts/build_android_library.sh

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ build_android_native_library() {
4141
-DBUILD_TESTING=OFF \
4242
-DEXECUTORCH_PAL_DEFAULT=android \
4343
-DEXECUTORCH_ENABLE_LOGGING=ON \
44+
-DEXECUTORCH_BUILD_ANDROID_JNI=ON \
4445
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
4546
-DEXECUTORCH_ENABLE_EVENT_TRACER="${EXECUTORCH_ANDROID_PROFILING:-OFF}" \
4647
-DEXECUTORCH_LOG_LEVEL=Info \
@@ -55,6 +56,7 @@ build_android_native_library() {
5556
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
5657
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
5758
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
59+
-DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
5860
-DEXECUTORCH_BUILD_NEURON="${EXECUTORCH_BUILD_NEURON}" \
5961
-DNEURON_BUFFER_ALLOCATOR_LIB="${NEURON_BUFFER_ALLOCATOR_LIB}" \
6062
-DEXECUTORCH_BUILD_QNN="${EXECUTORCH_BUILD_QNN}" \
@@ -71,25 +73,6 @@ build_android_native_library() {
7173
fi
7274
cmake --build "${CMAKE_OUT}" -j "${CMAKE_JOBS}" --target install --config "${EXECUTORCH_CMAKE_BUILD_TYPE}"
7375

74-
cmake extension/android \
75-
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
76-
-DANDROID_ABI="${ANDROID_ABI}" \
77-
-DANDROID_PLATFORM=android-26 \
78-
-DBUILD_TESTING=OFF \
79-
-DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
80-
-DEXECUTORCH_ENABLE_LOGGING=ON \
81-
-DEXECUTORCH_LOG_LEVEL=Info \
82-
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
83-
-DEXECUTORCH_ANDROID_PROFILING="${EXECUTORCH_ANDROID_PROFILING:-OFF}" \
84-
-DNEURON_BUFFER_ALLOCATOR_LIB="$NEURON_BUFFER_ALLOCATOR_LIB" \
85-
-DEXECUTORCH_BUILD_KERNELS_CUSTOM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
86-
-DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
87-
-DSUPPORT_REGEX_LOOKAHEAD=ON \
88-
-DCMAKE_BUILD_TYPE="${EXECUTORCH_CMAKE_BUILD_TYPE}" \
89-
-B"${CMAKE_OUT}"/extension/android
90-
91-
cmake --build "${CMAKE_OUT}"/extension/android -j "${CMAKE_JOBS}" --config "${EXECUTORCH_CMAKE_BUILD_TYPE}"
92-
9376
# Copy artifacts to ABI specific directory
9477
local SO_STAGE_DIR="cmake-out-android-so/${ANDROID_ABI}"
9578
mkdir -p ${SO_STAGE_DIR}

0 commit comments

Comments
 (0)