From 7c26024920d3fe684edc66016f71db28e1f7542b Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Fri, 4 Apr 2025 05:22:04 +0200 Subject: fix: strip trailing slashes for android keystore and jarsigner paths The `system()` call on linux was failing to execute the `jarsigner` command because its path had a trailing slash --- src/bundle_command.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/bundle_command.cpp') diff --git a/src/bundle_command.cpp b/src/bundle_command.cpp index b3bca2b51..c5274ca3d 100644 --- a/src/bundle_command.cpp +++ b/src/bundle_command.cpp @@ -132,7 +132,7 @@ i32 bundle_android(String original_init_directory) { if (current_directory.len != 0) { bool ok = set_working_directory(init_directory); if (!ok) { - gb_printf_err("Error: Unable to currectly set the current working directory to '%.*s'\n", LIT(init_directory)); + gb_printf_err("Error: Unable to correctly set the current working directory to '%.*s'\n", LIT(init_directory)); } } @@ -174,7 +174,8 @@ i32 bundle_android(String original_init_directory) { cmd = gb_string_append_length(cmd, build_context.ODIN_ANDROID_JAR_SIGNER.text, build_context.ODIN_ANDROID_JAR_SIGNER.len); cmd = gb_string_append_fmt(cmd, " -storepass android"); if (build_context.android_keystore.len != 0) { - String keystore = concatenate_strings(temporary_allocator(), current_directory, build_context.android_keystore); + String keystore = normalize_path(temporary_allocator(), build_context.android_keystore, NIX_SEPARATOR_STRING); + keystore = substring(keystore, 0, keystore.len - 1); cmd = gb_string_append_fmt(cmd, " -keystore \"%.*s\"", LIT(keystore)); } cmd = gb_string_append_fmt(cmd, " \"%.*s.apk-build\"", LIT(output_apk)); -- cgit v1.2.3 From 4495f0f0f245e4534aa39e153176b42b4d2db8f6 Mon Sep 17 00:00:00 2001 From: IllusionMan1212 Date: Fri, 4 Apr 2025 05:23:12 +0200 Subject: feat: added a `-android-keystore-password` option to pass a password for the keystore instead of hardcoding it as `android` --- src/build_settings.cpp | 5 +++++ src/bundle_command.cpp | 2 +- src/main.cpp | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src/bundle_command.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 8339b111a..1e44a8bc5 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -554,6 +554,7 @@ struct BuildContext { String ODIN_ANDROID_JAR_SIGNER; String android_keystore; String android_keystore_alias; + String android_keystore_password; String android_manifest; }; @@ -1593,6 +1594,10 @@ gb_internal void init_android_values(bool with_sdk) { gb_printf_err("Error: -android-keystore_alias: has not been set\n"); gb_exit(1); } + if (bc->android_keystore_password.len == 0) { + gb_printf_err("Error: -android-keystore-password: has not been set\n"); + gb_exit(1); + } } } diff --git a/src/bundle_command.cpp b/src/bundle_command.cpp index c5274ca3d..11ff4e6e1 100644 --- a/src/bundle_command.cpp +++ b/src/bundle_command.cpp @@ -172,7 +172,7 @@ i32 bundle_android(String original_init_directory) { gb_string_clear(cmd); cmd = gb_string_append_length(cmd, build_context.ODIN_ANDROID_JAR_SIGNER.text, build_context.ODIN_ANDROID_JAR_SIGNER.len); - cmd = gb_string_append_fmt(cmd, " -storepass android"); + cmd = gb_string_append_fmt(cmd, " -storepass \"%.*s\"", LIT(build_context.android_keystore_password)); if (build_context.android_keystore.len != 0) { String keystore = normalize_path(temporary_allocator(), build_context.android_keystore, NIX_SEPARATOR_STRING); keystore = substring(keystore, 0, keystore.len - 1); diff --git a/src/main.cpp b/src/main.cpp index c19bbde22..5a54e9bc3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -277,6 +277,7 @@ gb_internal void usage(String argv0, String argv1 = {}) { print_usage_line(1, "build Compiles directory of .odin files, as an executable."); print_usage_line(1, " One must contain the program's entry point, all must be in the same package."); print_usage_line(1, "run Same as 'build', but also then runs the newly compiled executable."); + print_usage_line(1, "bundle Bundles a directory in a specific layout for that platform."); print_usage_line(1, "check Parses, and type checks a directory of .odin files."); print_usage_line(1, "strip-semicolon Parses, type checks, and removes unneeded semicolons from the entire program."); print_usage_line(1, "test Builds and runs procedures with the attribute @(test) in the initial package."); @@ -411,6 +412,7 @@ enum BuildFlagKind { BuildFlag_AndroidKeystore, BuildFlag_AndroidKeystoreAlias, + BuildFlag_AndroidKeystorePassword, BuildFlag_AndroidManifest, BuildFlag_COUNT, @@ -631,6 +633,7 @@ gb_internal bool parse_build_flags(Array args) { add_flag(&build_flags, BuildFlag_AndroidKeystore, str_lit("android-keystore"), BuildFlagParam_String, Command_bundle_android); add_flag(&build_flags, BuildFlag_AndroidKeystoreAlias, str_lit("android-keystore-alias"), BuildFlagParam_String, Command_bundle_android); + add_flag(&build_flags, BuildFlag_AndroidKeystorePassword, str_lit("android-keystore-password"), BuildFlagParam_String, Command_bundle_android); add_flag(&build_flags, BuildFlag_AndroidManifest, str_lit("android-manifest"), BuildFlagParam_String, Command_bundle_android); @@ -1664,6 +1667,11 @@ gb_internal bool parse_build_flags(Array args) { build_context.android_keystore_alias = value.value_string; break; + case BuildFlag_AndroidKeystorePassword: + GB_ASSERT(value.kind == ExactValue_String); + build_context.android_keystore_password = value.value_string; + break; + case BuildFlag_AndroidManifest: GB_ASSERT(value.kind == ExactValue_String); build_context.android_manifest = value.value_string; -- cgit v1.2.3