Skip to content

Commit 1976647

Browse files
authored
Android preset (#11119)
1 parent ff7c5e5 commit 1976647

File tree

3 files changed

+62
-17
lines changed

3 files changed

+62
-17
lines changed

CMakePresets.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@
66
"hidden": true,
77
"binaryDir": "${sourceDir}/cmake-out"
88
},
9+
{
10+
"name": "android-arm64-v8a",
11+
"displayName": "Build executorch core and JNI bindings on android arm64-v8a",
12+
"inherits": ["common"],
13+
"binaryDir": "${sourceDir}/cmake-out-android-arm64-v8a",
14+
"cacheVariables": {
15+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake",
16+
"ANDROID_ABI": "arm64-v8a"
17+
},
18+
"condition": {
19+
"type": "inList",
20+
"string": "${hostSystemName}",
21+
"list": ["Darwin", "Linux", "Windows"]
22+
}
23+
},
24+
{
25+
"name": "android-x86_64",
26+
"displayName": "Build executorch core and JNI bindings on android x86_64",
27+
"inherits": ["common"],
28+
"binaryDir": "${sourceDir}/cmake-out-android-x86_64",
29+
"cacheVariables": {
30+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake",
31+
"ANDROID_ABI": "x86_64"
32+
},
33+
"condition": {
34+
"type": "inList",
35+
"string": "${hostSystemName}",
36+
"list": ["Darwin", "Linux", "Windows"]
37+
}
38+
},
939
{
1040
"name": "macos",
1141
"displayName": "Build ExecuTorch for macOS",

scripts/build_android_library.sh

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,12 @@ build_android_native_library() {
3636

3737
cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \
3838
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
39-
-DANDROID_ABI="${ANDROID_ABI}" \
39+
--preset "android-${ANDROID_ABI}" \
4040
-DANDROID_PLATFORM=android-26 \
41-
-DBUILD_TESTING=OFF \
42-
-DEXECUTORCH_PAL_DEFAULT=android \
43-
-DEXECUTORCH_ENABLE_LOGGING=ON \
44-
-DEXECUTORCH_BUILD_ANDROID_JNI=ON \
45-
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
4641
-DEXECUTORCH_ENABLE_EVENT_TRACER="${EXECUTORCH_ANDROID_PROFILING:-OFF}" \
47-
-DEXECUTORCH_LOG_LEVEL=Info \
48-
-DEXECUTORCH_BUILD_XNNPACK=ON \
49-
-DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \
50-
-DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
51-
-DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \
5242
-DEXECUTORCH_BUILD_EXTENSION_LLM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
5343
-DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
54-
-DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
55-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
56-
-DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
5744
-DEXECUTORCH_BUILD_EXTENSION_TRAINING=ON \
58-
-DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
59-
-DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
60-
-DEXECUTORCH_BUILD_KERNELS_LLM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
6145
-DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \
6246
-DEXECUTORCH_BUILD_NEURON="${EXECUTORCH_BUILD_NEURON}" \
6347
-DNEURON_BUFFER_ALLOCATOR_LIB="${NEURON_BUFFER_ALLOCATOR_LIB}" \

tools/cmake/preset/android.cmake

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
# All rights reserved.
3+
#
4+
# This source code is licensed under the BSD-style license found in the
5+
# LICENSE file in the root directory of this source tree.
6+
7+
set_overridable_option(BUILD_TESTING OFF)
8+
9+
set_overridable_option(EXECUTORCH_BUILD_ANDROID_JNI ON)
10+
set_overridable_option(EXECUTORCH_PAL_DEFAULT android)
11+
set_overridable_option(EXECUTORCH_ENABLE_EVENT_TRACER OFF)
12+
set_overridable_option(EXECUTORCH_ENABLE_LOGGING ON)
13+
set_overridable_option(EXECUTORCH_LOG_LEVEL Info)
14+
15+
set_overridable_option(EXECUTORCH_BUILD_DEVTOOLS ON)
16+
17+
set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON)
18+
set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON)
19+
20+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON)
21+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON)
22+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM ON)
23+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON)
24+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON)
25+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON)
26+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON)
27+
set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON)
28+
29+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM ON)
30+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON)
31+
set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)

0 commit comments

Comments
 (0)