Files
MaaAssistantArknights/CMakePresets.json
Aliothmoon c6f930a60d feat: support native android (#16179)
* feat: add android controller support

* feat: add android compile options and add core static options

* fix: add __ANDROID__ macro for Android platform

* fix: move switch break into macro conditional block

* ci: add Android CMake presets (arm64, x64)

* fix: add missing Android TouchMode handling

* fix: remove unnecessary pre-check in android

* fix: restore unnecessary modifications

* fix: unified use __ANDROID__

* refactor: use interpolate_swipe_with_pause in AndroidController

* feat: add Android crash logcat output and native backtrace

* feat: only copy once from external lib screencap

* feat: add Android JNI AttachThread/DetachThread to working_proc

* fix: break control in switch

* fix: update click interval & swipe interval

* ci: restore Android build job with MaaFramework download

* fix: remove thread attach

* ci: temporarily remove MaaAndroidNativeControlUnit.so

* feat(android-ctrl): SWIPE_WITH_PAUSE 由 InstanceOption DeploymentWithPause 控制

* feat: SWIPE_WITH_PAUSE 默认启用

* feat: add android compile options and add core static options

* feat: use maafw controll unit

* fix: minor adjustments

* refactor: adapt maafw android lib

* fix: remove screencap when connect

* chore: change maafw lib use

* feat: adapt maafw control unit click & click_key

* fix: address critical issues in Android native controller

- Restore InstanceOptionKey::ClientType case in set_instance_option,
  which was accidentally removed and broke client type setting on all platforms
- Enable libMaaAndroidNativeControlUnit.so copy step in CI (was commented out),
  so Android artifacts actually include the required control unit library
- Fail connect() early when screen_resolution is missing or invalid in config,
  preventing silent {0,0} resolution that would break swipe and screencap
- Check touch_down() return value in swipe() and abort on failure

* fix: correct bounds_check off-by-one and extract KEYCODE_ESCAPE constant

- bounds_check used <= which allowed coordinates equal to screen width/height
  (off-screen); use < to match the valid range [0, dimension-1]
- Extract magic number 111 into KEYCODE_ESCAPE constexpr in press_esc()

* fix: avoid heap allocation in noexcept terminate/signal handlers

format_signal_reason was returning std::string and using std::format in
its default branch. Called from noexcept custom_terminate_handler before
the outer try block, any allocation failure would throw std::bad_alloc,
triggering recursive std::terminate and aborting crash reporting.

- Change return type to const char* noexcept, returning string literals
- Replace std::format("Signal {}", sig) with "Unknown Signal" (only the
  four registered signals are ever passed, so this branch is unreachable)
- Change signal_info in custom_terminate_handler from std::string to
  const char*, eliminating all allocations on the pre-try path

* fix: suppress unused-variable warning for signal_reason on non-Android
2026-05-12 22:15:15 +08:00

470 lines
16 KiB
JSON

{
"version": 10,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
"patch": 0
},
"configurePresets": [
{
"name": "windows-base",
"hidden": true,
"generator": "Visual Studio 18 2026",
"binaryDir": "${sourceDir}/build",
"$comment": [
"Base for Windows presets; Visual Studio is multi-config (Debug/Release/RelWithDebInfo in same build dir)",
"see https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2018%202026.html"
],
"cacheVariables": {
"BUILD_WPF_GUI": "ON",
"BUILD_DEBUG_DEMO": "ON",
"BUILD_RESOURCE_UPDATER": "ON",
"INSTALL_RESOURCE": "OFF",
"INSTALL_PYTHON": "OFF"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-clang-base",
"hidden": true,
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build",
"$comment": [
"NOT for building — only for generating compile_commands.json for clangd / VS Code",
"run from 'x64 Native Tools Command Prompt for VS' or ensure clang-cl is in PATH",
"to build, use the Visual Studio presets (windows-x64, windows-arm64)"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
},
"cacheVariables": {
"CMAKE_C_COMPILER": "clang-cl",
"CMAKE_CXX_COMPILER": "clang-cl",
"CMAKE_C_COMPILER_TARGET": "x86_64-pc-windows-msvc",
"CMAKE_CXX_COMPILER_TARGET": "x86_64-pc-windows-msvc",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_WPF_GUI": "OFF",
"BUILD_DEBUG_DEMO": "ON",
"BUILD_RESOURCE_UPDATER": "ON",
"INSTALL_RESOURCE": "OFF",
"INSTALL_PYTHON": "OFF"
}
},
{
"name": "windows-x64-clang",
"inherits": "windows-clang-base",
"displayName": "Windows x64 (clang-cl)",
"cacheVariables": {
"MAADEPS_TRIPLET": "maa-x64-windows"
}
},
{
"name": "linux-base",
"hidden": true,
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build",
"$comment": [
"Base for Linux presets; Ninja is multi-config (Debug/Release/RelWithDebInfo in same build dir)",
"see https://cmake.org/cmake/help/latest/generator/Ninja%20Multi-Config.html",
"clangd uses compile_commands.json to provide code completion and navigation",
"so CMAKE_EXPORT_COMPILE_COMMANDS is set to ON",
"see https://clangd.llvm.org/installation.html"
],
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
}
},
{
"name": "macos-base",
"hidden": true,
"generator": "Ninja Multi-Config",
"binaryDir": "${sourceDir}/build",
"$comment": [
"Base for macOS presets; Ninja is multi-config (Debug/Release/RelWithDebInfo in same build dir)",
"see https://cmake.org/cmake/help/latest/generator/Ninja%20Multi-Config.html",
"clangd uses compile_commands.json to provide code completion and navigation",
"so CMAKE_EXPORT_COMPILE_COMMANDS is set to ON",
"see https://clangd.llvm.org/installation.html"
],
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "windows-x64",
"inherits": "windows-base",
"displayName": "Windows x64",
"architecture": "x64",
"cacheVariables": {
"MAADEPS_TRIPLET": "maa-x64-windows"
}
},
{
"name": "windows-arm64",
"inherits": "windows-base",
"displayName": "Windows arm64",
"architecture": "ARM64",
"cacheVariables": {
"MAADEPS_TRIPLET": "maa-arm64-windows"
}
},
{
"name": "linux-x64",
"inherits": "linux-base",
"displayName": "Linux x64",
"toolchainFile": "src/MaaUtils/MaaDeps/cmake/maa-x64-linux-toolchain.cmake",
"cacheVariables": {
"MAADEPS_TRIPLET": "maa-x64-linux"
}
},
{
"name": "linux-arm64",
"inherits": "linux-base",
"displayName": "Linux arm64",
"toolchainFile": "src/MaaUtils/MaaDeps/cmake/maa-arm64-linux-toolchain.cmake",
"cacheVariables": {
"MAADEPS_TRIPLET": "maa-arm64-linux"
}
},
{
"name": "macos-arm64",
"inherits": "macos-base",
"displayName": "macOS arm64",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64"
}
},
{
"name": "macos-x64",
"inherits": "macos-base",
"displayName": "macOS x64",
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "x86_64"
}
},
{
"name": "android-base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"$comment": [
"Base for Android presets; cross-compilation via NDK toolchain",
"CMAKE_TOOLCHAIN_FILE must be passed externally pointing to NDK's android.toolchain.cmake"
],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "Android",
"ANDROID_PLATFORM": "android-28",
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "android-arm64",
"inherits": "android-base",
"displayName": "Android arm64",
"cacheVariables": {
"ANDROID_ABI": "arm64-v8a",
"MAADEPS_TRIPLET": "maa-arm64-android"
}
},
{
"name": "android-x64",
"inherits": "android-base",
"displayName": "Android x64",
"cacheVariables": {
"ANDROID_ABI": "x86_64",
"MAADEPS_TRIPLET": "maa-x64-android"
}
},
{
"name": "publish-base",
"$comment": [
"All the name contains 'publish' are used for github actions",
"see .github/workflows/ci.yml"
],
"hidden": true,
"installDir": "install",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo",
"INSTALL_RESOURCE": "ON",
"INSTALL_PYTHON": "ON",
"BUILD_WPF_GUI": "OFF",
"BUILD_DEBUG_DEMO": "OFF",
"BUILD_RESOURCE_UPDATER": "OFF"
}
},
{
"name": "windows-publish-x64",
"inherits": [
"publish-base",
"windows-x64"
],
"cacheVariables": {
"BUILD_WPF_GUI": "ON"
},
"$comment": [
"github actions only support Visual Studio 17 2022",
"see https://github.com/actions/runner-images/issues/13291"
],
"generator": "Visual Studio 17 2022",
"displayName": "Windows x64 Publish"
},
{
"name": "windows-publish-arm64",
"inherits": [
"publish-base",
"windows-arm64"
],
"cacheVariables": {
"BUILD_WPF_GUI": "ON"
},
"$comment": [
"github actions only support Visual Studio 17 2022",
"see https://github.com/actions/runner-images/issues/13291"
],
"generator": "Visual Studio 17 2022",
"displayName": "Windows arm64 Publish"
},
{
"name": "linux-publish-x64",
"inherits": [
"publish-base",
"linux-x64"
],
"displayName": "Linux x64 Publish"
},
{
"name": "linux-publish-arm64",
"inherits": [
"publish-base",
"linux-arm64"
],
"displayName": "Linux arm64 Publish"
},
{
"name": "macos-publish-x64",
"inherits": [
"publish-base",
"macos-x64"
],
"displayName": "macOS x64 Publish"
},
{
"name": "macos-publish-arm64",
"inherits": [
"publish-base",
"macos-arm64"
],
"displayName": "macOS arm64 Publish"
},
{
"name": "android-publish-arm64",
"inherits": ["publish-base", "android-arm64"],
"displayName": "Android arm64 Publish",
"cacheVariables": {
"INSTALL_PYTHON": "OFF"
}
},
{
"name": "android-publish-x64",
"inherits": ["publish-base", "android-x64"],
"displayName": "Android x64 Publish",
"cacheVariables": {
"INSTALL_PYTHON": "OFF"
}
},
{
"name": "smoke-test",
"$comment": [
"this preset is used for smoke testing",
"see .github/workflows/smoke-testing.yml"
],
"inherits": "macos-arm64",
"displayName": "macOS arm64 Smoke Test",
"installDir": "install",
"cacheVariables": {
"BUILD_SMOKE_TEST": "ON",
"INSTALL_RESOURCE": "ON",
"WITH_HASH_VERSION": "ON"
}
}
],
"buildPresets": [
{
"name": "windows-x64-Debug",
"displayName": "Build Windows x64 Debug",
"configurePreset": "windows-x64",
"configuration": "Debug"
},
{
"name": "windows-x64-Release",
"displayName": "Build Windows x64 Release",
"configurePreset": "windows-x64",
"configuration": "Release"
},
{
"name": "windows-x64-RelWithDebInfo",
"displayName": "Build Windows x64 RelWithDebInfo",
"configurePreset": "windows-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-arm64-Debug",
"displayName": "Build Windows arm64 Debug",
"configurePreset": "windows-arm64",
"configuration": "Debug"
},
{
"name": "windows-arm64-Release",
"displayName": "Build Windows arm64 Release",
"configurePreset": "windows-arm64",
"configuration": "Release"
},
{
"name": "windows-arm64-RelWithDebInfo",
"displayName": "Build Windows arm64 RelWithDebInfo",
"configurePreset": "windows-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-x64-Debug",
"displayName": "Build Linux x64 Debug",
"configurePreset": "linux-x64",
"configuration": "Debug"
},
{
"name": "linux-x64-Release",
"displayName": "Build Linux x64 Release",
"configurePreset": "linux-x64",
"configuration": "Release"
},
{
"name": "linux-x64-RelWithDebInfo",
"displayName": "Build Linux x64 RelWithDebInfo",
"configurePreset": "linux-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-arm64-Debug",
"displayName": "Build Linux arm64 Debug",
"configurePreset": "linux-arm64",
"configuration": "Debug"
},
{
"name": "linux-arm64-Release",
"displayName": "Build Linux arm64 Release",
"configurePreset": "linux-arm64",
"configuration": "Release"
},
{
"name": "linux-arm64-RelWithDebInfo",
"displayName": "Build Linux arm64 RelWithDebInfo",
"configurePreset": "linux-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "macos-x64-Debug",
"displayName": "Build macOS x64 Debug",
"configurePreset": "macos-x64",
"configuration": "Debug"
},
{
"name": "macos-x64-Release",
"displayName": "Build macOS x64 Release",
"configurePreset": "macos-x64",
"configuration": "Release"
},
{
"name": "macos-x64-RelWithDebInfo",
"displayName": "Build macOS x64 RelWithDebInfo",
"configurePreset": "macos-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "macos-arm64-Debug",
"displayName": "Build macOS arm64 Debug",
"configurePreset": "macos-arm64",
"configuration": "Debug"
},
{
"name": "macos-arm64-Release",
"displayName": "Build macOS arm64 Release",
"configurePreset": "macos-arm64",
"configuration": "Release"
},
{
"name": "macos-arm64-RelWithDebInfo",
"displayName": "Build macOS arm64 RelWithDebInfo",
"configurePreset": "macos-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-publish-x64",
"displayName": "Build Windows x64 Publish",
"configurePreset": "windows-publish-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "windows-publish-arm64",
"displayName": "Build Windows arm64 Publish",
"configurePreset": "windows-publish-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-publish-x64",
"displayName": "Build Linux x64 Publish",
"configurePreset": "linux-publish-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "linux-publish-arm64",
"displayName": "Build Linux arm64 Publish",
"configurePreset": "linux-publish-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "macos-publish-x64",
"displayName": "Build macOS x64 Publish",
"configurePreset": "macos-publish-x64",
"configuration": "RelWithDebInfo"
},
{
"name": "macos-publish-arm64",
"displayName": "Build macOS arm64 Publish",
"configurePreset": "macos-publish-arm64",
"configuration": "RelWithDebInfo"
},
{
"name": "android-publish-arm64",
"displayName": "Build Android arm64 Publish",
"configurePreset": "android-publish-arm64"
},
{
"name": "android-publish-x64",
"displayName": "Build Android x64 Publish",
"configurePreset": "android-publish-x64"
},
{
"name": "smoke-test",
"displayName": "Build macOS arm64 Smoke Test",
"configurePreset": "smoke-test",
"configuration": "Debug"
}
]
}