diff options
author | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2025-08-30 16:53:58 -0700 |
commit | 6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch) | |
tree | 34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake | |
parent | 8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff) |
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake')
-rw-r--r-- | src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake new file mode 100644 index 0000000..15dea2d --- /dev/null +++ b/src/contrib/SDL-3.2.20/cmake/android/SdlAndroidScript.cmake | |||
@@ -0,0 +1,74 @@ | |||
1 | #[=======================================================================[ | ||
2 | |||
3 | This CMake script is meant to be used in CMake script mode (cmake -P). | ||
4 | It wraps commands that communicate with an actual Android device. | ||
5 | Because | ||
6 | |||
7 | #]=======================================================================] | ||
8 | |||
9 | cmake_minimum_required(VERSION 3.16...3.28) | ||
10 | |||
11 | if(NOT CMAKE_SCRIPT_MODE_FILE) | ||
12 | message(FATAL_ERROR "This file can only be used in CMake script mode") | ||
13 | endif() | ||
14 | if(NOT ADB) | ||
15 | set(ADB "adb") | ||
16 | endif() | ||
17 | |||
18 | if(NOT ACTION) | ||
19 | message(FATAL_ERROR "Missing ACTION argument") | ||
20 | endif() | ||
21 | |||
22 | if(ACTION STREQUAL "uninstall") | ||
23 | # The uninstall action attempts to uninstall all packages. All failures are ignored. | ||
24 | foreach(package IN LISTS PACKAGES) | ||
25 | message("Uninstalling ${package} ...") | ||
26 | execute_process( | ||
27 | COMMAND ${ADB} uninstall ${package} | ||
28 | RESULT_VARIABLE res | ||
29 | ) | ||
30 | message("... result=${res}") | ||
31 | endforeach() | ||
32 | elseif(ACTION STREQUAL "install") | ||
33 | # The install actions attempts to install APK's to an Android device using adb. Failures are ignored. | ||
34 | set(failed_apks "") | ||
35 | foreach(apk IN LISTS APKS) | ||
36 | message("Installing ${apk} ...") | ||
37 | execute_process( | ||
38 | COMMAND ${ADB} install -d -r --streaming ${apk} | ||
39 | RESULT_VARIABLE res | ||
40 | ) | ||
41 | message("... result=${res}") | ||
42 | if(NOT res EQUAL 0) | ||
43 | list(APPEND failed_apks ${apk}) | ||
44 | endif() | ||
45 | endforeach() | ||
46 | if(failed_apks) | ||
47 | message(FATAL_ERROR "Failed to install ${failed_apks}") | ||
48 | endif() | ||
49 | elseif(ACTION STREQUAL "build-install-run") | ||
50 | if(NOT EXECUTABLES) | ||
51 | message(FATAL_ERROR "Missing EXECUTABLES (don't know what executables to build/install and start") | ||
52 | endif() | ||
53 | if(NOT BUILD_FOLDER) | ||
54 | message(FATAL_ERROR "Missing BUILD_FOLDER (don't know where to build the APK's") | ||
55 | endif() | ||
56 | set(install_targets "") | ||
57 | foreach(executable IN LISTS EXECUTABLES) | ||
58 | list(APPEND install_targets "install-${executable}") | ||
59 | endforeach() | ||
60 | execute_process( | ||
61 | COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target ${install_targets} | ||
62 | RESULT_VARIABLE res | ||
63 | ) | ||
64 | if(NOT res EQUAL 0) | ||
65 | message(FATAL_ERROR "Failed to install APK(s) for ${EXECUTABLES}") | ||
66 | endif() | ||
67 | list(GET EXECUTABLES 0 start_executable) | ||
68 | execute_process( | ||
69 | COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target start-${start_executable} | ||
70 | RESULT_VARIABLE res | ||
71 | ) | ||
72 | else() | ||
73 | message(FATAL_ERROR "Unknown ACTION=${ACTION}") | ||
74 | endif() | ||