diff --git a/CMakePresets.json b/CMakePresets.json index 9a3e9290d43..c7c24f61b3b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -6,6 +6,36 @@ "hidden": true, "binaryDir": "${sourceDir}/cmake-out" }, + { + "name": "android-arm64-v8a", + "displayName": "Build executorch core and JNI bindings on android arm64-v8a", + "inherits": ["common"], + "binaryDir": "${sourceDir}/cmake-out-android-arm64-v8a", + "cacheVariables": { + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake", + "ANDROID_ABI": "arm64-v8a" + }, + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": ["Darwin", "Linux", "Windows"] + } + }, + { + "name": "android-x86_64", + "displayName": "Build executorch core and JNI bindings on android x86_64", + "inherits": ["common"], + "binaryDir": "${sourceDir}/cmake-out-android-x86_64", + "cacheVariables": { + "EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/android.cmake", + "ANDROID_ABI": "x86_64" + }, + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": ["Darwin", "Linux", "Windows"] + } + }, { "name": "macos", "displayName": "Build ExecuTorch for macOS", diff --git a/scripts/build_android_library.sh b/scripts/build_android_library.sh index d01e37affff..7bc52f01863 100755 --- a/scripts/build_android_library.sh +++ b/scripts/build_android_library.sh @@ -36,28 +36,12 @@ build_android_native_library() { cmake . -DCMAKE_INSTALL_PREFIX="${CMAKE_OUT}" \ -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \ - -DANDROID_ABI="${ANDROID_ABI}" \ + --preset "android-${ANDROID_ABI}" \ -DANDROID_PLATFORM=android-26 \ - -DBUILD_TESTING=OFF \ - -DEXECUTORCH_PAL_DEFAULT=android \ - -DEXECUTORCH_ENABLE_LOGGING=ON \ - -DEXECUTORCH_BUILD_ANDROID_JNI=ON \ - -DEXECUTORCH_BUILD_DEVTOOLS=ON \ -DEXECUTORCH_ENABLE_EVENT_TRACER="${EXECUTORCH_ANDROID_PROFILING:-OFF}" \ - -DEXECUTORCH_LOG_LEVEL=Info \ - -DEXECUTORCH_BUILD_XNNPACK=ON \ - -DEXECUTORCH_XNNPACK_SHARED_WORKSPACE=ON \ - -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \ - -DEXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR=ON \ -DEXECUTORCH_BUILD_EXTENSION_LLM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \ -DEXECUTORCH_BUILD_EXTENSION_LLM_RUNNER="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \ - -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \ - -DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \ - -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \ -DEXECUTORCH_BUILD_EXTENSION_TRAINING=ON \ - -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \ - -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \ - -DEXECUTORCH_BUILD_KERNELS_LLM="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \ -DEXECUTORCH_BUILD_LLAMA_JNI="${EXECUTORCH_BUILD_EXTENSION_LLM:-ON}" \ -DEXECUTORCH_BUILD_NEURON="${EXECUTORCH_BUILD_NEURON}" \ -DNEURON_BUFFER_ALLOCATOR_LIB="${NEURON_BUFFER_ALLOCATOR_LIB}" \ diff --git a/tools/cmake/preset/android.cmake b/tools/cmake/preset/android.cmake new file mode 100644 index 00000000000..a89f5425e0b --- /dev/null +++ b/tools/cmake/preset/android.cmake @@ -0,0 +1,31 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# All rights reserved. +# +# This source code is licensed under the BSD-style license found in the +# LICENSE file in the root directory of this source tree. + +set_overridable_option(BUILD_TESTING OFF) + +set_overridable_option(EXECUTORCH_BUILD_ANDROID_JNI ON) +set_overridable_option(EXECUTORCH_PAL_DEFAULT android) +set_overridable_option(EXECUTORCH_ENABLE_EVENT_TRACER OFF) +set_overridable_option(EXECUTORCH_ENABLE_LOGGING ON) +set_overridable_option(EXECUTORCH_LOG_LEVEL Info) + +set_overridable_option(EXECUTORCH_BUILD_DEVTOOLS ON) + +set_overridable_option(EXECUTORCH_BUILD_XNNPACK ON) +set_overridable_option(EXECUTORCH_XNNPACK_SHARED_WORKSPACE ON) + +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_DATA_LOADER ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_FLAT_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_MODULE ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TENSOR ON) +set_overridable_option(EXECUTORCH_BUILD_EXTENSION_TRAINING ON) + +set_overridable_option(EXECUTORCH_BUILD_KERNELS_LLM ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_OPTIMIZED ON) +set_overridable_option(EXECUTORCH_BUILD_KERNELS_QUANTIZED ON)