From f6a9129219b2de293476b7fd8a355f0fd0448f3f Mon Sep 17 00:00:00 2001 From: Fredia Huya-Kouadio Date: Sat, 11 Nov 2023 17:20:04 -0800 Subject: [PATCH] Preserve the output from the gradle build command Updates `EditorNode#execute_and_show_output(...)` to return the output of the executed command. (cherry picked from commit 136b7f9c528f5036befba8b39e4bb41bd9d9890f) --- editor/editor_node.cpp | 5 ++++- editor/editor_node.h | 2 +- platform/android/export/export_plugin.cpp | 14 ++++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index cfa8885b526..75a56ba2668 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -6690,7 +6690,7 @@ static void _execute_thread(void *p_ud) { eta->done.set(); } -int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List &p_arguments, bool p_close_on_ok, bool p_close_on_errors) { +int EditorNode::execute_and_show_output(const String &p_title, const String &p_path, const List &p_arguments, bool p_close_on_ok, bool p_close_on_errors, String *r_output) { if (execute_output_dialog) { execute_output_dialog->set_title(p_title); execute_output_dialog->get_ok_button()->set_disabled(true); @@ -6736,6 +6736,9 @@ int EditorNode::execute_and_show_output(const String &p_title, const String &p_p execute_output_dialog->get_ok_button()->set_disabled(false); } + if (r_output) { + *r_output = eta.output; + } return eta.exitcode; } diff --git a/editor/editor_node.h b/editor/editor_node.h index 40e78f2961d..ba2144e2bdf 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -932,7 +932,7 @@ public: bool has_scenes_in_session(); - int execute_and_show_output(const String &p_title, const String &p_path, const List &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false); + int execute_and_show_output(const String &p_title, const String &p_path, const List &p_arguments, bool p_close_on_ok = true, bool p_close_on_errors = false, String *r_output = nullptr); EditorNode(); ~EditorNode(); diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp index 2fdff06c720..233a168a00d 100644 --- a/platform/android/export/export_plugin.cpp +++ b/platform/android/export/export_plugin.cpp @@ -2939,10 +2939,13 @@ Error EditorExportPlatformAndroid::export_project_helper(const Refexecute_and_show_output(TTR("Building Android Project (gradle)"), build_command, cmdline); + String build_project_output; + int result = EditorNode::get_singleton()->execute_and_show_output(TTR("Building Android Project (gradle)"), build_command, cmdline, true, false, &build_project_output); if (result != 0) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Building of Android project failed, check output for the error. Alternatively visit docs.godotengine.org for Android build documentation.")); + add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Building of Android project failed, check output for the error:") + "\n\n" + build_project_output); return ERR_CANT_CREATE; + } else { + print_verbose(build_project_output); } List copy_args; @@ -2969,10 +2972,13 @@ Error EditorExportPlatformAndroid::export_project_helper(const Refexecute_and_show_output(TTR("Moving output"), build_command, copy_args); + String copy_binary_output; + int copy_result = EditorNode::get_singleton()->execute_and_show_output(TTR("Moving output"), build_command, copy_args, true, false, ©_binary_output); if (copy_result != 0) { - add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Unable to copy and rename export file, check gradle project directory for outputs.")); + add_message(EXPORT_MESSAGE_ERROR, TTR("Export"), TTR("Unable to copy and rename export file:") + "\n\n" + copy_binary_output); return ERR_CANT_CREATE; + } else { + print_verbose(copy_binary_output); } print_verbose("Successfully completed Android gradle build.");