android bundling improvements

replace `jarsigner` with build tools' `apksigner` which is capable of using newer signature schemes

remove the `android-manifest` flag and assume the file exists in the directory we're bundling

make `android-keystore-alias` and `android-keystore-password` optional.
The former is not needed if there's only one key in the keystore, and the latter will be prompted by `apksigner` if missing

don't change the working directory to the bundled directory to prevent confusion when passing a relative path to
`android-keystore`

add the `res`, `assets`, and `lib` directories to the bundle if they exist in the bundled directory
This commit is contained in:
IllusionMan1212
2025-04-05 02:21:56 +02:00
parent 44950d5f37
commit da885fb807
3 changed files with 47 additions and 69 deletions
-17
View File
@@ -551,11 +551,9 @@ struct BuildContext {
String ODIN_ANDROID_NDK_TOOLCHAIN_LIB_LEVEL;
String ODIN_ANDROID_NDK_TOOLCHAIN_SYSROOT;
String ODIN_ANDROID_JAR_SIGNER;
String android_keystore;
String android_keystore_alias;
String android_keystore_password;
String android_manifest;
};
gb_global BuildContext build_context = {0};
@@ -1574,30 +1572,15 @@ gb_internal void init_android_values(bool with_sdk) {
bc->ODIN_ANDROID_NDK_TOOLCHAIN_SYSROOT = concatenate_strings(permanent_allocator(), bc->ODIN_ANDROID_NDK_TOOLCHAIN, str_lit("sysroot/"));
bc->ODIN_ANDROID_JAR_SIGNER = normalize_path(permanent_allocator(), make_string_c(gb_get_env("ODIN_ANDROID_JAR_SIGNER", permanent_allocator())), NIX_SEPARATOR_STRING);
// Strip trailing slash so system() call doesn't fail.
bc->ODIN_ANDROID_JAR_SIGNER = substring(bc->ODIN_ANDROID_JAR_SIGNER, 0, bc->ODIN_ANDROID_JAR_SIGNER.len - 1);
if (with_sdk) {
if (bc->ODIN_ANDROID_SDK.len == 0) {
gb_printf_err("Error: ODIN_ANDROID_SDK not set, which is required for -build-mode:executable for -subtarget:android");
gb_exit(1);
}
if (bc->ODIN_ANDROID_JAR_SIGNER.len == 0) {
gb_printf_err("Error: ODIN_ANDROID_JAR_SIGNER not set, which is required for -build-mode:executable for -subtarget:android");
gb_exit(1);
}
if (bc->android_keystore.len == 0) {
gb_printf_err("Error: -android-keystore:<string> has not been set\n");
gb_exit(1);
}
if (bc->android_keystore_alias.len == 0) {
gb_printf_err("Error: -android-keystore_alias:<string> has not been set\n");
gb_exit(1);
}
if (bc->android_keystore_password.len == 0) {
gb_printf_err("Error: -android-keystore-password:<string> has not been set\n");
gb_exit(1);
}
}
}