Commit c84a401
committed
Update Android libraries and scripts, support Android 15 and 16
Library changes
---------------
For Android (and Emscripten), replace libcrypto and libssl provided by OpenSSL with those provided by BoringSSL, as the former does not support using Android's system certificate store. This previously required embedding a certificate store separately in the APK, limiting the lifetime of the app until the certificate expires. With BoringSSL we can set `CURLOPT_CAPATH` for curl handles to use the Android system certificate store directly.
Upgrade/downgrade libraries to fixed versions used on other platforms for parity, or latest release versions when more desirable or necessary for Android:
- libpng: unspecified --> v1.6.43
- curl: curl-8_8_0 (unchanged)
- freetype: unspecified --> VER-2-13-2
- SDL: unspecified --> release-2.32.10
- ogg: unspecified --> v1.3.5
- opus: unspecified --> v1.5.2
- opusfile: unspecified --> v0.12
- sqlite3: amalgamation-3360000 --> amalgamation-3460000
Remove unused precompiled zlib library, which is not necessary for Android because the bundled `src/engine/external/zlib` can be compiled. It is only necessary for the Emscripten build because `src/engine/external/zlib` does not compile, but Emscripten libraries are not currently included in the ddnet-libs repository. Change the version of zlib used for the Emscripten build to v1.3.1.2 to fix build failures.
Remove unused `libSDL2main.a` library, which is not necessary for Android.
Support for Android 15 and 16
-----------------------------
Bump versions of Android NDK, build tools, command line tools and Gradle to support [16 KiB pages sizes](https://developer.android.com/guide/practices/page-sizes), which is required to support Android 15 (API 35).
Compile libraries with the correct flags for Android API 24 - 36 support. Fix various Android-specific CFLAGS not being set correctly when building some libraries. See the Android CMake toolchain files and https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md for documentation of the flags being used. The only deviation from the default flags is that we build the libraries and the client without debug information (in Release mode), as the automatic stripping of debug information during the Gradle build does not work. This reduces the final APK size in Release mode by around 1/3 or 60 MiB.
Bump target/compile API level to 36 to support Android 16. Set `android:enableOnBackInvokedCallback="false"` in the manifest to disable the [predictive back gesture](https://developer.android.com/guide/navigation/custom-back/predictive-back-gesture) and keep the legacy behavior of the back button.
Fix Gradle deprecation warnings with latest Gradle version, by using `=` for property assignment in `build.gradle`.
Towards reproducible builds
---------------------------
Pin specific release version or commits for all libraries instead of building the default branch.
Make the library build reproducible by removing the embedded absolute build paths of the libraries using the `-ffile-prefix-map` flag. Also separately remove the absolute paths of the Android NDK and the Emscripten SDK which were being embedded in libraries and in the Android and Emscripten client, respectively.
Remove embedded paths of the build folder in addition to the source folder, as some compilers (Android) also seem to embed it separately for generated source files.
Order entries in Android asset integrity index file lexicographically instead of using non-deterministic file enumeration order.
Explicitly set `ANDROID_HOME` in the CI, as it was already defined and preinstalled Android tools were used instead.
Use fixed Rust default version for Android build in CI.
Overall, this should make the Android build almost reproducible if the specified versions of Android NDK and the JDK are used. Still not reproducible is the Vulkan shader compilation/optimization and something minor about the client binary compilation.
Streamline library building process
-----------------------------------
- Add log messages.
- Add error message when building for Android if the Android NDK could not be found. Avoid different warning when building for Emscripten and not having the Android NDK installed.
- Specify the correct libpng include and library paths when building libfreetype to enable PNG support in the latter.
- Disable protocol support in libcurl for all protocols except those enabled on other platforms: HTTPS, HTTP, FTPS, FTP, FILE.
- Use ninja for building CMake-based libraries to reduce building time.
- Specify exact build targets when building CMake-based libraries to avoid building unused extra tools.
- Avoid building zlib for Android, as it can be build from `src/engine/external/zlib` and only needs to be build separately for Emscripten.
- Avoid rebuilding the sqlite3 and opusfile libraries if they are unchanged by generating minimal Makefiles.
- Avoid copying build script files to the build folders of individual libraries, instead invoke the scripts within the build folders with absolute paths.
- Avoid copying libopus and libogg files when building libopusfile, instead reference the files in the existing build folders.
Improve documentation
---------------------
- Add missing instruction to install libtool to the README. Without libtool the initial project configuration of libopusfile fails, although it seems to work on the second attempt anyway.
- Add instructions for updating the Android SDK and Gradle versions to the README.
- Add instructions to delete old Android/Emscripten-specific libraries files before copying new files to ddnet-libs, to avoid old files being left behind.
- Explain how to perform a clean build of the libraries.
Various refactoring
-------------------
- Add `set -e` to all scripts to enable strict error handling and always exit on errors. Remove `|| exit 1` that are made unnecessary by this.
- Add shellcheck source directives to comments so that shellcheck can correctly check the sourced shell scripts, instead of disabling the check. The paths in the source directives are relative to project root, the folder where shellcheck is executed.
- Consolidate common flags and functions for Android and Emscripten building in the `_build_common.sh` file.
- Consistently use `ON` for CMake settings instead of `1` or `TRUE`.
- Use local variables when possible.1 parent 3f623af commit c84a401
File tree
25 files changed
+833
-592
lines changed- .github/workflows
- cmake
- toolchains
- scripts
- android
- files
- gradle/wrapper
- compile_libs
25 files changed
+833
-592
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
260 | 261 | | |
261 | 262 | | |
262 | 263 | | |
263 | 264 | | |
264 | 265 | | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
| 266 | + | |
288 | 267 | | |
289 | 268 | | |
290 | 269 | | |
| |||
302 | 281 | | |
303 | 282 | | |
304 | 283 | | |
305 | | - | |
| 284 | + | |
| 285 | + | |
306 | 286 | | |
307 | 287 | | |
308 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
309 | 294 | | |
310 | 295 | | |
311 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
| 310 | + | |
310 | 311 | | |
311 | 312 | | |
312 | 313 | | |
| |||
689 | 690 | | |
690 | 691 | | |
691 | 692 | | |
692 | | - | |
693 | | - | |
| 693 | + | |
| 694 | + | |
694 | 695 | | |
695 | 696 | | |
696 | 697 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
276 | | - | |
| 275 | + | |
277 | 276 | | |
278 | 277 | | |
279 | 278 | | |
280 | | - | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
281 | 285 | | |
282 | 286 | | |
283 | 287 | | |
284 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
285 | 292 | | |
286 | | - | |
| 293 | + | |
287 | 294 | | |
288 | | - | |
| 295 | + | |
| 296 | + | |
289 | 297 | | |
290 | | - | |
| 298 | + | |
291 | 299 | | |
292 | 300 | | |
293 | 301 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
29 | | - | |
| 28 | + | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 35 | | |
43 | 36 | | |
44 | 37 | | |
| |||
47 | 40 | | |
48 | 41 | | |
49 | 42 | | |
| 43 | + | |
50 | 44 | | |
51 | 45 | | |
52 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
54 | 58 | | |
55 | 59 | | |
56 | 60 | | |
| 61 | + | |
| 62 | + | |
57 | 63 | | |
58 | 64 | | |
59 | 65 | | |
| |||
Submodule ddnet-libs updated 620 files
0 commit comments