Skip to content

Commit

Permalink
Allow exporting release Android builds without a debug keystore
Browse files Browse the repository at this point in the history
  • Loading branch information
YeldhamDev committed Jun 19, 2023
1 parent 116f783 commit 41a75cf
Show file tree
Hide file tree
Showing 17 changed files with 26 additions and 24 deletions.
2 changes: 1 addition & 1 deletion editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ void EditorNode::_fs_changed() {
} else { // Normal project export.
String config_error;
bool missing_templates;
if (!platform->can_export(export_preset, config_error, missing_templates)) {
if (!platform->can_export(export_preset, config_error, missing_templates, export_defer.debug)) {
ERR_PRINT(vformat("Cannot export project with preset \"%s\" due to configuration errors:\n%s", preset_name, config_error));
err = missing_templates ? ERR_FILE_NOT_FOUND : ERR_UNCONFIGURED;
} else {
Expand Down
5 changes: 3 additions & 2 deletions editor/export/editor_export_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1788,11 +1788,12 @@ void EditorExportPlatform::gen_export_flags(Vector<String> &r_flags, int p_flags
}
}

bool EditorExportPlatform::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatform::can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
bool valid = true;

#ifndef ANDROID_ENABLED
String templates_error;
valid = valid && has_valid_export_configuration(p_preset, templates_error, r_missing_templates);
valid = valid && has_valid_export_configuration(p_preset, templates_error, r_missing_templates, p_debug);

if (!templates_error.is_empty()) {
r_error += templates_error;
Expand Down
4 changes: 2 additions & 2 deletions editor/export/editor_export_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ class EditorExportPlatform : public RefCounted {

String test_etc2() const;
String test_bc() const;
bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const = 0;
bool can_export(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const = 0;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const = 0;

virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const = 0;
Expand Down
2 changes: 1 addition & 1 deletion editor/export/editor_export_platform_pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Ref<Texture2D> EditorExportPlatformPC::get_logo() const {
return logo;
}

bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformPC::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;

Expand Down
2 changes: 1 addition & 1 deletion editor/export/editor_export_platform_pc.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class EditorExportPlatformPC : public EditorExportPlatform {
virtual String get_os_name() const override;
virtual Ref<Texture2D> get_logo() const override;

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path);
Expand Down
11 changes: 6 additions & 5 deletions platform/android/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2227,7 +2227,7 @@ String EditorExportPlatformAndroid::get_apksigner_path(int p_target_sdk, bool p_
return apksigner_path;
}

bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;
const bool gradle_build_enabled = p_preset->get("gradle_build/use_gradle_build");
Expand Down Expand Up @@ -2286,7 +2286,8 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
err += TTR("Either Debug Keystore, Debug User AND Debug Password settings must be configured OR none of them.") + "\n";
}

if (!FileAccess::exists(dk)) {
// Use OR to make the export UI able to show this error.
if ((p_debug || !dk.is_empty()) && !FileAccess::exists(dk)) {
dk = EDITOR_GET("export/android/debug_keystore");
if (!FileAccess::exists(dk)) {
valid = false;
Expand All @@ -2303,7 +2304,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
err += TTR("Either Release Keystore, Release User AND Release Password settings must be configured OR none of them.") + "\n";
}

if (!rk.is_empty() && !FileAccess::exists(rk)) {
if (!p_debug && !rk.is_empty() && !FileAccess::exists(rk)) {
valid = false;
err += TTR("Release keystore incorrectly configured in the export preset.") + "\n";
}
Expand All @@ -2323,7 +2324,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
valid = false;
}

// Validate that adb is available
// Validate that adb is available.
String adb_path = get_adb_path();
if (!FileAccess::exists(adb_path)) {
err += TTR("Unable to find Android SDK platform-tools' adb command.");
Expand All @@ -2345,7 +2346,7 @@ bool EditorExportPlatformAndroid::has_valid_export_configuration(const Ref<Edito
if (!target_sdk_version.is_valid_int()) {
target_sdk_version = itos(DEFAULT_TARGET_SDK_VERSION);
}
// Validate that apksigner is available
// Validate that apksigner is available.
String apksigner_path = get_apksigner_path(target_sdk_version.to_int());
if (!FileAccess::exists(apksigner_path)) {
err += TTR("Unable to find Android SDK build-tools' apksigner command.");
Expand Down
2 changes: 1 addition & 1 deletion platform/android/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

static String get_apksigner_path(int p_target_sdk = -1, bool p_check_executes = false);

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;

virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
Expand Down
2 changes: 1 addition & 1 deletion platform/ios/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1899,7 +1899,7 @@ Error EditorExportPlatformIOS::export_project(const Ref<EditorExportPreset> &p_p
return OK;
}

bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformIOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;

Expand Down
2 changes: 1 addition & 1 deletion platform/ios/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform {
}
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;

virtual void get_platform_features(List<String> *r_features) const override {
Expand Down
2 changes: 1 addition & 1 deletion platform/macos/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,7 @@ Error EditorExportPlatformMacOS::export_project(const Ref<EditorExportPreset> &p
return err;
}

bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformMacOS::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;

Expand Down
2 changes: 1 addition & 1 deletion platform/macos/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class EditorExportPlatformMacOS : public EditorExportPlatform {
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;

virtual void get_platform_features(List<String> *r_features) const override {
Expand Down
2 changes: 1 addition & 1 deletion platform/uwp/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void EditorExportPlatformUWP::get_export_options(List<ExportOption> *r_options)
}
}

bool EditorExportPlatformUWP::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformUWP::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
#ifndef DEV_ENABLED
// We don't provide export templates for the UWP platform currently as it
// has not been ported for Godot 4.0. This is skipped in DEV_ENABLED so that
Expand Down
2 changes: 1 addition & 1 deletion platform/uwp/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ class EditorExportPlatformUWP : public EditorExportPlatform {

virtual void get_export_options(List<ExportOption> *r_options) const override;

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;

virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
Expand Down
2 changes: 1 addition & 1 deletion platform/web/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ Ref<Texture2D> EditorExportPlatformWeb::get_logo() const {
return logo;
}

bool EditorExportPlatformWeb::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformWeb::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err;
bool valid = false;
bool extensions = (bool)p_preset->get("variant/extensions_support");
Expand Down
2 changes: 1 addition & 1 deletion platform/web/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class EditorExportPlatformWeb : public EditorExportPlatform {
virtual String get_os_name() const override;
virtual Ref<Texture2D> get_logo() const override;

virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
virtual Error export_project(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path, int p_flags = 0) override;
Expand Down
4 changes: 2 additions & 2 deletions platform/windows/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,9 @@ Error EditorExportPlatformWindows::_code_sign(const Ref<EditorExportPreset> &p_p
return OK;
}

bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const {
bool EditorExportPlatformWindows::has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug) const {
String err = "";
bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates);
bool valid = EditorExportPlatformPC::has_valid_export_configuration(p_preset, err, r_missing_templates, p_debug);

String rcedit_path = EDITOR_GET("export/windows/rcedit");
if (p_preset->get("application/modify_resources") && rcedit_path.is_empty()) {
Expand Down
2 changes: 1 addition & 1 deletion platform/windows/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class EditorExportPlatformWindows : public EditorExportPlatformPC {
virtual Error sign_shared_object(const Ref<EditorExportPreset> &p_preset, bool p_debug, const String &p_path) override;
virtual List<String> get_binary_extensions(const Ref<EditorExportPreset> &p_preset) const override;
virtual void get_export_options(List<ExportOption> *r_options) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates) const override;
virtual bool has_valid_export_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error, bool &r_missing_templates, bool p_debug = false) const override;
virtual bool has_valid_project_configuration(const Ref<EditorExportPreset> &p_preset, String &r_error) const override;
virtual bool get_export_option_visibility(const EditorExportPreset *p_preset, const String &p_option) const override;
virtual String get_export_option_warning(const EditorExportPreset *p_preset, const StringName &p_name) const override;
Expand Down

0 comments on commit 41a75cf

Please sign in to comment.