Squashed 'external/ircolib/' changes from ce3cd726c..de6e324bd
de6e324bdseparate emu thread10d3daf86Roms List improvements95d202f37Let's make the rom list process on a separate thread so the emulator doesnt take ages to load.fc306967fWow the ROM Header was just completely busted. Game list view works nowbad1691eefuck this shit2b59e5f46game list in progressd26417b83remappable inputs in progressac4af8106inpute72abc240update readme430139dc9Qt6 frontend3080d4d45Fix this small bug too08cd13b85Cop0 unused functions do not actually pose a threat (as per manual). They don't do anything, so shall we.61bb4fb44make idle loop detection a little more specific with where the load goesb037de4c3SAZDFsdff12e81e73eneed to figure out why n64-systemtest loops indefinitely at some address that appears to be valid (i think it's me not invalidating the cache properly)204f0e13bidle skipping seems to work!cb8bb634asdkfjlasdf58e5c89c1Fix compilation issue on my machine (no idea)24fb2898eattempting more serious idle skipping214719577Place rsp.Step inside cached interpreter. Gains about 3 more fpsbb97dcc23mmmmm920b77d38wjkhasdfjhkasdf430ccdab4it's a start...4f42a673aCached interpreter plays Mario 64. Start looking into RSP as wellc9a030787idle skipping works!5fbda03cenew idea366637abaIdle skipping... maybe?609fa2fb0Cache instructions implemented but broken lmao. Commented out for nowe140a6d12- Stop using inheritance for CPU, instead use composition. - Introduce KAIZEN_JIT_ENABLED optional define instead of relying on __aarch64__ and the like. - More cache work68e613057prep cache impl811b4d809fix clang formatfda755f7didkd5024ebbfsmall MI refactor in preparation of (eventually) implementing the RDRAM interface properly694b45341Merge commit '206dcdedf195fb320913584180edb12c7731e396' as 'external/SDL'206dcdedfSquashed 'external/SDL/' content from commit 4d17b99d0a4d16e1cb4need to update sdl848b19920Fix compilation errordb61b5299Merge commit 'e94a94559f28e49678fbcf72199a5258137b0fe9' as 'external/imgui'e94a94559Squashed 'external/imgui/' content from commit 02e9b8cac52edb3757need to update imguic1a705e86Emulate weird JALR behaviour4b4c32f4bFix exception for "unusable COP1" in 4 instructions i missed accidentally (again)df5828142Bug putting 0s in the log everywheref8b580048Make isviewer a sink to file8241e9735Fix exception for "unusable COP1" in 4 instructions i missed accidentallyb29715f20small changesd9a620bc1make use of my new small utility library0d1aa938eAdd 'external/ircolib/' from commit 'ce3cd726c8df8388d554abf8bb55d55020eb4450'e64eb40b3Fuck git git-subtree-dir: external/ircolib git-subtree-split:de6e324bde
This commit is contained in:
+103
@@ -0,0 +1,103 @@
|
||||
#[=======================================================================[
|
||||
|
||||
FindSdlAndroid
|
||||
----------------------
|
||||
|
||||
Locate various executables that are essential to creating an Android APK archive.
|
||||
This find module uses the FindSdlAndroidBuildTools module to locate some Android utils.
|
||||
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` target(s):
|
||||
|
||||
`` SdlAndroid::aapt2 ``
|
||||
Imported executable for the "android package tool" v2
|
||||
|
||||
`` SdlAndroid::apksigner``
|
||||
Imported executable for the APK signer tool
|
||||
|
||||
`` SdlAndroid::d8 ``
|
||||
Imported executable for the dex compiler
|
||||
|
||||
`` SdlAndroid::zipalign ``
|
||||
Imported executable for the zipalign util
|
||||
|
||||
`` SdlAndroid::adb ``
|
||||
Imported executable for the "android debug bridge" tool
|
||||
|
||||
`` SdlAndroid::keytool ``
|
||||
Imported executable for the keytool, a key and certificate management utility
|
||||
|
||||
`` SdlAndroid::zip ``
|
||||
Imported executable for the zip, for packaging and compressing files
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
`` AAPT2_BIN ``
|
||||
Path of aapt2
|
||||
|
||||
`` APKSIGNER_BIN ``
|
||||
Path of apksigner
|
||||
|
||||
`` D8_BIN ``
|
||||
Path of d8
|
||||
|
||||
`` ZIPALIGN_BIN ``
|
||||
Path of zipalign
|
||||
|
||||
`` ADB_BIN ``
|
||||
Path of adb
|
||||
|
||||
`` KEYTOOL_BIN ``
|
||||
Path of keytool
|
||||
|
||||
`` ZIP_BIN ``
|
||||
Path of zip
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_minimum_required(VERSION 3.7...3.28)
|
||||
|
||||
if(NOT PROJECT_NAME MATCHES "^SDL.*")
|
||||
message(WARNING "This module is internal to SDL and is currently not supported.")
|
||||
endif()
|
||||
|
||||
find_package(SdlAndroidBuildTools MODULE)
|
||||
|
||||
function(_sdl_android_find_create_imported_executable NAME)
|
||||
string(TOUPPER "${NAME}" NAME_UPPER)
|
||||
set(varname "${NAME_UPPER}_BIN")
|
||||
find_program("${varname}" NAMES "${NAME}" PATHS ${SDL_ANDROID_BUILD_TOOLS_ROOT})
|
||||
if(EXISTS "${${varname}}" AND NOT TARGET SdlAndroid::${NAME})
|
||||
add_executable(SdlAndroid::${NAME} IMPORTED)
|
||||
set_property(TARGET SdlAndroid::${NAME} PROPERTY IMPORTED_LOCATION "${${varname}}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(SdlAndroidBuildTools_FOUND)
|
||||
_sdl_android_find_create_imported_executable(aapt2)
|
||||
_sdl_android_find_create_imported_executable(apksigner)
|
||||
_sdl_android_find_create_imported_executable(d8)
|
||||
_sdl_android_find_create_imported_executable(zipalign)
|
||||
endif()
|
||||
|
||||
_sdl_android_find_create_imported_executable(adb)
|
||||
_sdl_android_find_create_imported_executable(keytool)
|
||||
_sdl_android_find_create_imported_executable(zip)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SdlAndroid
|
||||
VERSION_VAR
|
||||
REQUIRED_VARS
|
||||
AAPT2_BIN
|
||||
APKSIGNER_BIN
|
||||
D8_BIN
|
||||
ZIPALIGN_BIN
|
||||
KEYTOOL_BIN
|
||||
ZIP_BIN
|
||||
)
|
||||
@@ -0,0 +1,115 @@
|
||||
#[=======================================================================[
|
||||
|
||||
FindSdlAndroidBuildTools
|
||||
----------------------
|
||||
|
||||
Locate the Android build tools directory.
|
||||
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This find module defines the following :prop_tgt:`IMPORTED` target(s):
|
||||
|
||||
<none>
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module will set the following variables in your project:
|
||||
|
||||
`` SdlAndroidBuildTools_FOUND
|
||||
if false, no Android build tools have been found
|
||||
|
||||
`` SDL_ANDROID_BUILD_TOOLS_ROOT
|
||||
path of the Android build tools root directory if found
|
||||
|
||||
`` SDL_ANDROID_BUILD_TOOLS_VERSION
|
||||
the human-readable string containing the android build tools version if found
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
These variables may optionally be set to help this module find the correct files:
|
||||
|
||||
``SDL_ANDROID_BUILD_TOOLS_ROOT``
|
||||
path of the Android build tools root directory
|
||||
|
||||
|
||||
Variables for locating Android platform
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This module responds to the flags:
|
||||
|
||||
``SDL_ANDROID_HOME
|
||||
First, this module will look for platforms in this CMake variable.
|
||||
|
||||
``ANDROID_HOME
|
||||
If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`.
|
||||
|
||||
``$ENV{ANDROID_HOME}
|
||||
If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}`
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_minimum_required(VERSION 3.7...3.28)
|
||||
|
||||
if(NOT PROJECT_NAME MATCHES "^SDL.*")
|
||||
message(WARNING "This module is internal to SDL and is currently not supported.")
|
||||
endif()
|
||||
|
||||
function(_sdl_is_valid_android_build_tools_root RESULT VERSION BUILD_TOOLS_ROOT)
|
||||
set(result TRUE)
|
||||
set(version -1)
|
||||
|
||||
string(REGEX MATCH "/([0-9.]+)$" root_match "${BUILD_TOOLS_ROOT}")
|
||||
if(root_match
|
||||
AND EXISTS "${BUILD_TOOLS_ROOT}/aapt2"
|
||||
AND EXISTS "${BUILD_TOOLS_ROOT}/apksigner"
|
||||
AND EXISTS "${BUILD_TOOLS_ROOT}/d8"
|
||||
AND EXISTS "${BUILD_TOOLS_ROOT}/zipalign")
|
||||
set(result "${BUILD_TOOLS_ROOT}")
|
||||
set(version "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
set(${RESULT} ${result} PARENT_SCOPE)
|
||||
set(${VERSION} ${version} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_find_sdl_android_build_tools_root ROOT)
|
||||
cmake_parse_arguments(fsabtr "" "" "" ${ARGN})
|
||||
set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME})
|
||||
set(root ${ROOT}-NOTFOUND)
|
||||
foreach(home IN LISTS homes)
|
||||
if(NOT IS_DIRECTORY "${home}")
|
||||
continue()
|
||||
endif()
|
||||
file(GLOB build_tools_roots LIST_DIRECTORIES true "${home}/build-tools/*")
|
||||
set(max_build_tools_version -1)
|
||||
set(max_build_tools_root "")
|
||||
foreach(build_tools_root IN LISTS build_tools_roots)
|
||||
_sdl_is_valid_android_build_tools_root(is_valid build_tools_version "${build_tools_root}")
|
||||
if(is_valid AND build_tools_version GREATER max_build_tools_version)
|
||||
set(max_build_tools_version "${build_tools_version}")
|
||||
set(max_build_tools_root "${build_tools_root}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(max_build_tools_version GREATER -1)
|
||||
set(root ${max_build_tools_root})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${ROOT} ${root} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(NOT DEFINED SDL_ANDROID_BUILD_TOOLS_ROOT)
|
||||
_find_sdl_android_build_tools_root(SDL_ANDROID_BUILD_TOOLS_ROOT)
|
||||
set(SDL_ANDROID_BUILD_TOOLS_ROOT "${SDL_ANDROID_BUILD_TOOLS_ROOT}" CACHE PATH "Path of Android build tools")
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SdlAndroidBuildTools
|
||||
VERSION_VAR SDL_ANDROID_BUILD_TOOLS_VERSION
|
||||
REQUIRED_VARS SDL_ANDROID_BUILD_TOOLS_ROOT
|
||||
)
|
||||
@@ -0,0 +1,124 @@
|
||||
#[=======================================================================[
|
||||
|
||||
FindSdlAndroidPlatform
|
||||
----------------------
|
||||
|
||||
Locate the Android SDK platform.
|
||||
|
||||
|
||||
Imported targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This module defines the following :prop_tgt:`IMPORTED` target(s):
|
||||
|
||||
<none>
|
||||
|
||||
Result variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This find module will set the following variables in your project:
|
||||
|
||||
`` SdlAndroidPlatform_FOUND
|
||||
if false, no Android platform has been found
|
||||
|
||||
`` SDL_ANDROID_PLATFORM_ROOT
|
||||
path of the Android SDK platform root directory if found
|
||||
|
||||
`` SDL_ANDROID_PLATFORM_ANDROID_JAR
|
||||
path of the Android SDK platform jar file if found
|
||||
|
||||
`` SDL_ANDROID_PLATFORM_VERSION
|
||||
the human-readable string containing the android platform version if found
|
||||
|
||||
Cache variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
These variables may optionally be set to help this module find the correct files:
|
||||
|
||||
``SDL_ANDROID_PLATFORM_ROOT``
|
||||
path of the Android SDK platform root directory
|
||||
|
||||
|
||||
Variables for locating Android platform
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This module responds to the flags:
|
||||
|
||||
``SDL_ANDROID_HOME
|
||||
First, this module will look for platforms in this CMake variable.
|
||||
|
||||
``ANDROID_HOME
|
||||
If no platform was found in `SDL_ANDROID_HOME`, then try `ANDROID_HOME`.
|
||||
|
||||
``$ENV{ANDROID_HOME}
|
||||
If no platform was found in neither `SDL_ANDROID_HOME` or `ANDROID_HOME`, then try `ANDROID_HOME}`
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_minimum_required(VERSION 3.7...3.28)
|
||||
|
||||
if(NOT PROJECT_NAME MATCHES "^SDL.*")
|
||||
message(WARNING "This module is internal to SDL and is currently not supported.")
|
||||
endif()
|
||||
|
||||
function(_sdl_is_valid_android_platform_root RESULT VERSION PLATFORM_ROOT)
|
||||
set(result FALSE)
|
||||
set(version -1)
|
||||
|
||||
string(REGEX MATCH "/android-([0-9]+)$" root_match "${PLATFORM_ROOT}")
|
||||
if(root_match AND EXISTS "${PLATFORM_ROOT}/android.jar")
|
||||
set(result TRUE)
|
||||
set(version "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
set(${RESULT} ${result} PARENT_SCOPE)
|
||||
set(${VERSION} ${version} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(_sdl_find_android_platform_root ROOT)
|
||||
cmake_parse_arguments(sfapr "" "" "" ${ARGN})
|
||||
set(homes ${SDL_ANDROID_HOME} ${ANDROID_HOME} $ENV{ANDROID_HOME})
|
||||
set(root ${ROOT}-NOTFOUND)
|
||||
foreach(home IN LISTS homes)
|
||||
if(NOT IS_DIRECTORY "${home}")
|
||||
continue()
|
||||
endif()
|
||||
file(GLOB platform_roots LIST_DIRECTORIES true "${home}/platforms/*")
|
||||
set(max_platform_version -1)
|
||||
set(max_platform_root "")
|
||||
foreach(platform_root IN LISTS platform_roots)
|
||||
_sdl_is_valid_android_platform_root(is_valid platform_version "${platform_root}")
|
||||
if(is_valid AND platform_version GREATER max_platform_version)
|
||||
set(max_platform_version "${platform_version}")
|
||||
set(max_platform_root "${platform_root}")
|
||||
endif()
|
||||
endforeach()
|
||||
if(max_platform_version GREATER -1)
|
||||
set(root ${max_platform_root})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${ROOT} ${root} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
set(SDL_ANDROID_PLATFORM_ANDROID_JAR "SDL_ANDROID_PLATFORM_ANDROID_JAR-NOTFOUND")
|
||||
|
||||
if(NOT DEFINED SDL_ANDROID_PLATFORM_ROOT)
|
||||
_sdl_find_android_platform_root(_new_sdl_android_platform_root)
|
||||
set(SDL_ANDROID_PLATFORM_ROOT "${_new_sdl_android_platform_root}" CACHE PATH "Path of Android platform")
|
||||
unset(_new_sdl_android_platform_root)
|
||||
endif()
|
||||
if(SDL_ANDROID_PLATFORM_ROOT)
|
||||
_sdl_is_valid_android_platform_root(_valid SDL_ANDROID_PLATFORM_VERSION "${SDL_ANDROID_PLATFORM_ROOT}")
|
||||
if(_valid)
|
||||
set(SDL_ANDROID_PLATFORM_ANDROID_JAR "${SDL_ANDROID_PLATFORM_ROOT}/android.jar")
|
||||
endif()
|
||||
unset(_valid)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_package_handle_standard_args(SdlAndroidPlatform
|
||||
VERSION_VAR SDL_ANDROID_PLATFORM_VERSION
|
||||
REQUIRED_VARS SDL_ANDROID_PLATFORM_ROOT SDL_ANDROID_PLATFORM_ANDROID_JAR
|
||||
)
|
||||
@@ -0,0 +1,276 @@
|
||||
#[=======================================================================[
|
||||
|
||||
This CMake script contains functions to build an Android APK.
|
||||
It is (currently) limited to packaging binaries for a single architecture.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_minimum_required(VERSION 3.7...3.28)
|
||||
|
||||
if(NOT PROJECT_NAME MATCHES "^SDL.*")
|
||||
message(WARNING "This module is internal to SDL and is currently not supported.")
|
||||
endif()
|
||||
|
||||
function(_sdl_create_outdir_for_target OUTDIRECTORY TARGET)
|
||||
set(outdir "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${TARGET}.dir")
|
||||
# Some CMake versions have a slow `cmake -E make_directory` implementation
|
||||
if(NOT IS_DIRECTORY "${outdir}")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${outdir}")
|
||||
endif()
|
||||
set("${OUTDIRECTORY}" "${outdir}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(sdl_create_android_debug_keystore TARGET)
|
||||
set(output "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_debug.keystore")
|
||||
add_custom_command(OUTPUT ${output}
|
||||
COMMAND ${CMAKE_COMMAND} -E rm -f "${output}"
|
||||
COMMAND SdlAndroid::keytool -genkey -keystore "${output}" -storepass android -alias androiddebugkey -keypass android -keyalg RSA -keysize 2048 -validity 10000 -dname "C=US, O=Android, CN=Android Debug"
|
||||
)
|
||||
add_custom_target(${TARGET} DEPENDS "${output}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${output}")
|
||||
endfunction()
|
||||
|
||||
function(sdl_android_compile_resources TARGET)
|
||||
cmake_parse_arguments(arg "" "RESFOLDER" "RESOURCES" ${ARGN})
|
||||
|
||||
if(NOT arg_RESFOLDER AND NOT arg_RESOURCES)
|
||||
message(FATAL_ERROR "Missing RESFOLDER or RESOURCES argument (need one or both)")
|
||||
endif()
|
||||
_sdl_create_outdir_for_target(outdir "${TARGET}")
|
||||
set(out_files "")
|
||||
|
||||
set(res_files "")
|
||||
if(arg_RESFOLDER)
|
||||
get_filename_component(arg_RESFOLDER "${arg_RESFOLDER}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
file(GLOB_RECURSE res_folder_files "${arg_RESFOLDER}/*")
|
||||
list(APPEND res_files ${res_folder_files})
|
||||
|
||||
foreach(res_file IN LISTS res_files)
|
||||
file(RELATIVE_PATH rel_res_file "${arg_RESFOLDER}" "${res_file}")
|
||||
string(REPLACE "/" "_" rel_comp_path "${rel_res_file}")
|
||||
if(res_file MATCHES ".*res/values.*\\.xml$")
|
||||
string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}")
|
||||
endif()
|
||||
set(comp_path "${outdir}/${rel_comp_path}.flat")
|
||||
add_custom_command(
|
||||
OUTPUT "${comp_path}"
|
||||
COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}"
|
||||
DEPENDS ${res_file}
|
||||
)
|
||||
list(APPEND out_files "${comp_path}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(arg_RESOURCES)
|
||||
list(APPEND res_files ${arg_RESOURCES})
|
||||
foreach(res_file IN LISTS arg_RESOURCES)
|
||||
string(REGEX REPLACE ".*/res/" "" rel_res_file ${res_file})
|
||||
string(REPLACE "/" "_" rel_comp_path "${rel_res_file}")
|
||||
if(res_file MATCHES ".*res/values.*\\.xml$")
|
||||
string(REGEX REPLACE "\\.xml" ".arsc" rel_comp_path "${rel_comp_path}")
|
||||
endif()
|
||||
set(comp_path "${outdir}/${rel_comp_path}.flat")
|
||||
add_custom_command(
|
||||
OUTPUT "${comp_path}"
|
||||
COMMAND SdlAndroid::aapt2 compile -o "${outdir}" "${res_file}"
|
||||
DEPENDS ${res_file}
|
||||
)
|
||||
list(APPEND out_files "${comp_path}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
add_custom_target(${TARGET} DEPENDS ${out_files})
|
||||
set_property(TARGET "${TARGET}" PROPERTY OUTPUTS "${out_files}")
|
||||
set_property(TARGET "${TARGET}" PROPERTY SOURCES "${res_files}")
|
||||
endfunction()
|
||||
|
||||
function(sdl_android_link_resources TARGET)
|
||||
cmake_parse_arguments(arg "NO_DEBUG" "MIN_SDK_VERSION;TARGET_SDK_VERSION;ANDROID_JAR;OUTPUT_APK;MANIFEST;PACKAGE" "RES_TARGETS" ${ARGN})
|
||||
|
||||
if(arg_MANIFEST)
|
||||
get_filename_component(arg_MANIFEST "${arg_MANIFEST}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
else()
|
||||
message(FATAL_ERROR "sdl_add_android_link_resources_target requires a Android MANIFEST path (${arg_MANIFEST})")
|
||||
endif()
|
||||
if(NOT arg_PACKAGE)
|
||||
file(READ "${arg_MANIFEST}" manifest_contents)
|
||||
string(REGEX MATCH "package=\"([a-zA-Z0-9_.]+)\"" package_match "${manifest_contents}")
|
||||
if(NOT package_match)
|
||||
message(FATAL_ERROR "Could not extract package from Android manifest (${arg_MANIFEST})")
|
||||
endif()
|
||||
set(arg_PACKAGE "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
set(depends "")
|
||||
|
||||
_sdl_create_outdir_for_target(outdir "${TARGET}")
|
||||
string(REPLACE "." "/" java_r_path "${arg_PACKAGE}")
|
||||
get_filename_component(java_r_path "${java_r_path}" ABSOLUTE BASE_DIR "${outdir}")
|
||||
set(java_r_path "${java_r_path}/R.java")
|
||||
|
||||
set(command SdlAndroid::aapt2 link)
|
||||
if(NOT arg_NO_DEBUG)
|
||||
list(APPEND command --debug-mode)
|
||||
endif()
|
||||
if(arg_MIN_SDK_VERSION)
|
||||
list(APPEND command --min-sdk-version ${arg_MIN_SDK_VERSION})
|
||||
endif()
|
||||
if(arg_TARGET_SDK_VERSION)
|
||||
list(APPEND command --target-sdk-version ${arg_TARGET_SDK_VERSION})
|
||||
endif()
|
||||
if(arg_ANDROID_JAR)
|
||||
list(APPEND command -I "${arg_ANDROID_JAR}")
|
||||
else()
|
||||
list(APPEND command -I "${SDL_ANDROID_PLATFORM_ANDROID_JAR}")
|
||||
endif()
|
||||
if(NOT arg_OUTPUT_APK)
|
||||
set(arg_OUTPUT_APK "${TARGET}.apk")
|
||||
endif()
|
||||
get_filename_component(arg_OUTPUT_APK "${arg_OUTPUT_APK}" ABSOLUTE BASE_DIR "${outdir}")
|
||||
list(APPEND command -o "${arg_OUTPUT_APK}")
|
||||
list(APPEND command --java "${outdir}")
|
||||
list(APPEND command --manifest "${arg_MANIFEST}")
|
||||
foreach(res_target IN LISTS arg_RES_TARGETS)
|
||||
list(APPEND command $<TARGET_PROPERTY:${res_target},OUTPUTS>)
|
||||
list(APPEND depends $<TARGET_PROPERTY:${res_target},OUTPUTS>)
|
||||
endforeach()
|
||||
add_custom_command(
|
||||
OUTPUT "${arg_OUTPUT_APK}" "${java_r_path}"
|
||||
COMMAND ${command}
|
||||
DEPENDS ${depends} ${arg_MANIFEST}
|
||||
COMMAND_EXPAND_LISTS
|
||||
VERBATIM
|
||||
)
|
||||
add_custom_target(${TARGET} DEPENDS "${arg_OUTPUT_APK}" "${java_r_path}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${arg_OUTPUT_APK}")
|
||||
set_property(TARGET ${TARGET} PROPERTY JAVA_R "${java_r_path}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUTS "${${arg_OUTPUT_APK}};${java_r_path}")
|
||||
endfunction()
|
||||
|
||||
function(sdl_add_to_apk_unaligned TARGET)
|
||||
cmake_parse_arguments(arg "" "APK_IN;NAME;OUTDIR" "ASSETS;NATIVE_LIBS;DEX" ${ARGN})
|
||||
|
||||
if(NOT arg_APK_IN)
|
||||
message(FATAL_ERROR "Missing APK_IN argument")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${arg_APK_IN})
|
||||
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
|
||||
endif()
|
||||
|
||||
_sdl_create_outdir_for_target(workdir ${TARGET})
|
||||
|
||||
if(NOT arg_OUTDIR)
|
||||
set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT arg_NAME)
|
||||
string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}")
|
||||
if(NOT arg_NAME MATCHES "\\.apk")
|
||||
set(arg_NAME "${arg_NAME}.apk")
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}")
|
||||
|
||||
set(apk_libdir "lib/${ANDROID_ABI}")
|
||||
|
||||
set(depends "")
|
||||
|
||||
set(commands
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory -rf "${apk_libdir}" "assets"
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${apk_libdir}" "assets"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>" "${apk_file}"
|
||||
)
|
||||
|
||||
set(dex_i "1")
|
||||
foreach(dex IN LISTS arg_DEX)
|
||||
set(suffix "${dex_i}")
|
||||
if(suffix STREQUAL "1")
|
||||
set(suffix "")
|
||||
endif()
|
||||
list(APPEND commands
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy "$<TARGET_PROPERTY:${dex},OUTPUT>" "classes${suffix}.dex"
|
||||
COMMAND SdlAndroid::zip -u -q -j "${apk_file}" "classes${suffix}.dex"
|
||||
)
|
||||
math(EXPR dex_i "${dex_i}+1")
|
||||
list(APPEND depends "$<TARGET_PROPERTY:${dex},OUTPUT>")
|
||||
endforeach()
|
||||
|
||||
foreach(native_lib IN LISTS arg_NATIVE_LIBS)
|
||||
list(APPEND commands
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy $<TARGET_FILE:${native_lib}> "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>"
|
||||
COMMAND SdlAndroid::zip -u -q "${apk_file}" "${apk_libdir}/$<TARGET_FILE_NAME:${native_lib}>"
|
||||
)
|
||||
endforeach()
|
||||
if(arg_ASSETS)
|
||||
list(APPEND commands
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy ${arg_ASSETS} "assets"
|
||||
COMMAND SdlAndroid::zip -u -r -q "${apk_file}" "assets"
|
||||
)
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT "${apk_file}"
|
||||
${commands}
|
||||
DEPENDS ${arg_NATIVE_LIBS} ${depends} "$<TARGET_PROPERTY:${arg_APK_IN},OUTPUT>"
|
||||
WORKING_DIRECTORY "${workdir}"
|
||||
)
|
||||
add_custom_target(${TARGET} DEPENDS "${apk_file}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
|
||||
endfunction()
|
||||
|
||||
function(sdl_apk_align TARGET APK_IN)
|
||||
cmake_parse_arguments(arg "" "NAME;OUTDIR" "" ${ARGN})
|
||||
|
||||
if(NOT TARGET ${arg_APK_IN})
|
||||
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
|
||||
endif()
|
||||
|
||||
if(NOT arg_OUTDIR)
|
||||
set(arg_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
|
||||
if(NOT arg_NAME)
|
||||
string(REGEX REPLACE "[:-]+" "." arg_NAME "${TARGET}")
|
||||
if(NOT arg_NAME MATCHES "\\.apk")
|
||||
set(arg_NAME "${arg_NAME}.apk")
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(apk_file "${arg_NAME}" ABSOLUTE BASE_DIR "${arg_OUTDIR}")
|
||||
|
||||
add_custom_command(OUTPUT "${apk_file}"
|
||||
COMMAND SdlAndroid::zipalign -f 4 "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "${apk_file}"
|
||||
DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>"
|
||||
)
|
||||
add_custom_target(${TARGET} DEPENDS "${apk_file}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
|
||||
endfunction()
|
||||
|
||||
function(sdl_apk_sign TARGET APK_IN)
|
||||
cmake_parse_arguments(arg "" "OUTPUT;KEYSTORE" "" ${ARGN})
|
||||
|
||||
if(NOT TARGET ${arg_APK_IN})
|
||||
message(FATAL_ERROR "APK_IN (${arg_APK_IN}) must be a target providing an apk")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET ${arg_KEYSTORE})
|
||||
message(FATAL_ERROR "APK_KEYSTORE (${APK_KEYSTORE}) must be a target providing a keystore")
|
||||
endif()
|
||||
|
||||
if(NOT arg_OUTPUT)
|
||||
string(REGEX REPLACE "[:-]+" "." arg_OUTPUT "${TARGET}")
|
||||
if(NOT arg_OUTPUT MATCHES "\\.apk")
|
||||
set(arg_OUTPUT "${arg_OUTPUT}.apk")
|
||||
endif()
|
||||
endif()
|
||||
get_filename_component(apk_file "${arg_OUTPUT}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
add_custom_command(OUTPUT "${apk_file}"
|
||||
COMMAND SdlAndroid::apksigner sign
|
||||
--ks "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>"
|
||||
--ks-pass pass:android --in "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" --out "${apk_file}"
|
||||
DEPENDS "$<TARGET_PROPERTY:${APK_IN},OUTPUT>" "$<TARGET_PROPERTY:${arg_KEYSTORE},OUTPUT>"
|
||||
BYPRODUCTS "${apk_file}.idsig"
|
||||
)
|
||||
add_custom_target(${TARGET} DEPENDS "${apk_file}")
|
||||
set_property(TARGET ${TARGET} PROPERTY OUTPUT "${apk_file}")
|
||||
endfunction()
|
||||
@@ -0,0 +1,74 @@
|
||||
#[=======================================================================[
|
||||
|
||||
This CMake script is meant to be used in CMake script mode (cmake -P).
|
||||
It wraps commands that communicate with an actual Android device.
|
||||
Because
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
cmake_minimum_required(VERSION 3.16...3.28)
|
||||
|
||||
if(NOT CMAKE_SCRIPT_MODE_FILE)
|
||||
message(FATAL_ERROR "This file can only be used in CMake script mode")
|
||||
endif()
|
||||
if(NOT ADB)
|
||||
set(ADB "adb")
|
||||
endif()
|
||||
|
||||
if(NOT ACTION)
|
||||
message(FATAL_ERROR "Missing ACTION argument")
|
||||
endif()
|
||||
|
||||
if(ACTION STREQUAL "uninstall")
|
||||
# The uninstall action attempts to uninstall all packages. All failures are ignored.
|
||||
foreach(package IN LISTS PACKAGES)
|
||||
message("Uninstalling ${package} ...")
|
||||
execute_process(
|
||||
COMMAND ${ADB} uninstall ${package}
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
message("... result=${res}")
|
||||
endforeach()
|
||||
elseif(ACTION STREQUAL "install")
|
||||
# The install actions attempts to install APK's to an Android device using adb. Failures are ignored.
|
||||
set(failed_apks "")
|
||||
foreach(apk IN LISTS APKS)
|
||||
message("Installing ${apk} ...")
|
||||
execute_process(
|
||||
COMMAND ${ADB} install -d -r --streaming ${apk}
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
message("... result=${res}")
|
||||
if(NOT res EQUAL 0)
|
||||
list(APPEND failed_apks ${apk})
|
||||
endif()
|
||||
endforeach()
|
||||
if(failed_apks)
|
||||
message(FATAL_ERROR "Failed to install ${failed_apks}")
|
||||
endif()
|
||||
elseif(ACTION STREQUAL "build-install-run")
|
||||
if(NOT EXECUTABLES)
|
||||
message(FATAL_ERROR "Missing EXECUTABLES (don't know what executables to build/install and start")
|
||||
endif()
|
||||
if(NOT BUILD_FOLDER)
|
||||
message(FATAL_ERROR "Missing BUILD_FOLDER (don't know where to build the APK's")
|
||||
endif()
|
||||
set(install_targets "")
|
||||
foreach(executable IN LISTS EXECUTABLES)
|
||||
list(APPEND install_targets "install-${executable}")
|
||||
endforeach()
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target ${install_targets}
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
if(NOT res EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to install APK(s) for ${EXECUTABLES}")
|
||||
endif()
|
||||
list(GET EXECUTABLES 0 start_executable)
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} --build "${BUILD_FOLDER}" --target start-${start_executable}
|
||||
RESULT_VARIABLE res
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Unknown ACTION=${ACTION}")
|
||||
endif()
|
||||
Reference in New Issue
Block a user