Add CMake-generated Android APK packaging - #105
Conversation
|
Thanks for the PR @Solessfir ! We would have to split it into parts, as-is there are too many separated things to review. Just some overall notes:
Afterward we can have a look separatly at:
|
|
Yep, makes sense. I'll split it up and start with the packaging part. I'll simplify the Gradle layout and check what's actually needed for both Android Studio and command-line builds. Then we can go through events, swapchain and controllers separately. |
721faf0 to
fe44ac7
Compare
|
Done, narrowed this to packaging only and flattened it to a single Release and Debug builds work from the command line. The example uses Android's built-in NativeActivity, so it doesn't depend on the Tempest backend changes. I haven't checked Android Studio import locally yet. Events, swapchain and controllers are kept out of this PR for separate review later. |
| @DEPENDENCIES@.each { implementation it } | ||
| } | ||
|
|
||
| // Multi-gigabyte asset packages need full repackaging to avoid stale ZIP offsets. |
There was a problem hiding this comment.
Do you need multi-gig .apk? I've been assuming that gothic-assets will be located somewhere in external-storage folder.
| } | ||
| packagingOptions { | ||
| jniLibs { | ||
| useLegacyPackaging true |
There was a problem hiding this comment.
do you need it? You already have max-page-size=16384 CMakeLists.txt
| message(FATAL_ERROR "Android packaging requires an out-of-source build") | ||
| endif() | ||
|
|
||
| set(TEMPEST_ANDROID_COMPILE_SDK 35 CACHE STRING "Android compile and target SDK") |
There was a problem hiding this comment.
should we rather about existing cmake variables here?
maybe only set some defaults...
…s to the application
|
| project(TempestAndroidPackaging LANGUAGES NONE) | ||
|
|
||
| include(../../Engine/cmake/TempestAndroid.cmake) | ||
| tempest_android_application(TempestExample |
There was a problem hiding this comment.
Would it be possible to have one cmake file instead of two?
Ideally, I'm thinking about:
# will be hidden at 'add_subdirectory(Tempest)' level
include(../../Engine/cmake/TempestAndroid.cmake)
and then:
# similar to old Tegra sdk
add_android_apk(target_name package manifest CPP_SOURCE ...)
and in OpenGothic we will add something similar to:
# at very start
if(ANDROID)
add_library(Gothic2Notr SHARED) # generally same as regular PC build
else()
add_executable(Gothic2Notr)
endif()
...
# close to the end
if(ANDROID)
add_android_apk(Gothic2Notr_apk
MANIFEST AndroidManifest.xml.in
CODE Gothic2Notr
PACKAGE_NAME "opengothic.gothic2"
)
endif()
| endif() | ||
| get_filename_component(APP_NATIVE_SOURCE_DIR "${APP_NATIVE_SOURCE_DIR}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
| if(APP_NATIVE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR NOT EXISTS "${APP_NATIVE_SOURCE_DIR}/CMakeLists.txt") | ||
| message(FATAL_ERROR "NATIVE_SOURCE_DIR must name a separate native CMake project") |
There was a problem hiding this comment.
We probably don't need this (see comment in Examples/Android/CMakeLists.txt)
|
|
There are many small things that I wish to change, but this can wait :) |
First part of Android support, limited to APK packaging. Events, Vulkan swapchain handling and controllers are left for separate PRs.
build.gradlefrom CMake, with no root/app split. The application supplies its own manifest.add_android_apk(... CODE target ...)in the same CMakeLists.txt. Tempest includes the helper automatically. Gradle builds that same project, with packaging generation disabled in its inner build.settings.gradleorgradle.propertiesare included.Usage
With JDK 17, Gradle 8.9, the Android SDK, CMake and Ninja configured (replace
/path/to/ndkwith the NDK installation directory):APK:
build/android-example/TempestExample-apk/build/outputs/apk/release/TempestExample-apk-release.apkA short usage example is in
Examples/Android/README.md. Release builds use the local debug signing key unless distribution signing is configured.Verified Windows command-line Release and Debug ARM64 builds, uncompressed native-library packaging, APK signing and 16 KiB alignment. Also checked custom NDK/API/STL settings and an x86_64 RelWithDebInfo build with a separate full symbol archive. Android Studio import has not been checked locally.