Add option to install android build template for export

This PR adds a new "--install-android-build-template" command-line option which causes the android build template to be installed before exporting the project.
This commit is contained in:
Malcolm Nixon 2023-12-05 23:35:52 -05:00
parent 7233bc6736
commit 988c1bf298
3 changed files with 12 additions and 3 deletions

View File

@ -974,6 +974,9 @@ void EditorNode::_fs_changed() {
} else { // Normal project export. } else { // Normal project export.
String config_error; String config_error;
bool missing_templates; bool missing_templates;
if (export_defer.android_build_template) {
export_template_manager->install_android_template();
}
if (!platform->can_export(export_preset, config_error, missing_templates, export_defer.debug)) { 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_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; err = missing_templates ? ERR_FILE_NOT_FOUND : ERR_UNCONFIGURED;
@ -4676,11 +4679,12 @@ void EditorNode::_begin_first_scan() {
requested_first_scan = true; requested_first_scan = true;
} }
Error EditorNode::export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only) { Error EditorNode::export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only, bool p_android_build_template) {
export_defer.preset = p_preset; export_defer.preset = p_preset;
export_defer.path = p_path; export_defer.path = p_path;
export_defer.debug = p_debug; export_defer.debug = p_debug;
export_defer.pack_only = p_pack_only; export_defer.pack_only = p_pack_only;
export_defer.android_build_template = p_android_build_template;
cmdline_export_mode = true; cmdline_export_mode = true;
return OK; return OK;
} }

View File

@ -264,6 +264,7 @@ private:
String path; String path;
bool debug = false; bool debug = false;
bool pack_only = false; bool pack_only = false;
bool android_build_template = false;
} export_defer; } export_defer;
static EditorNode *singleton; static EditorNode *singleton;
@ -882,7 +883,7 @@ public:
void _copy_warning(const String &p_str); void _copy_warning(const String &p_str);
Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only); Error export_preset(const String &p_preset, const String &p_path, bool p_debug, bool p_pack_only, bool p_android_build_template);
bool is_project_exporting() const; bool is_project_exporting() const;
Control *get_gui_base() { return gui_base; } Control *get_gui_base() { return gui_base; }

View File

@ -510,6 +510,7 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" The target directory must exist.\n"); OS::get_singleton()->print(" The target directory must exist.\n");
OS::get_singleton()->print(" --export-debug <preset> <path> Export the project in debug mode using the given preset and output path. See --export-release description for other considerations.\n"); OS::get_singleton()->print(" --export-debug <preset> <path> Export the project in debug mode using the given preset and output path. See --export-release description for other considerations.\n");
OS::get_singleton()->print(" --export-pack <preset> <path> Export the project data only using the given preset and output path. The <path> extension determines whether it will be in PCK or ZIP format.\n"); OS::get_singleton()->print(" --export-pack <preset> <path> Export the project data only using the given preset and output path. The <path> extension determines whether it will be in PCK or ZIP format.\n");
OS::get_singleton()->print(" --install-android-build-template Install the android build template. Used in conjunction with --export-release or --export-debug.\n");
#ifndef DISABLE_DEPRECATED #ifndef DISABLE_DEPRECATED
OS::get_singleton()->print(" --convert-3to4 [<max_file_kb>] [<max_line_size>]\n"); OS::get_singleton()->print(" --convert-3to4 [<max_file_kb>] [<max_line_size>]\n");
OS::get_singleton()->print(" Converts project from Godot 3.x to Godot 4.x.\n"); OS::get_singleton()->print(" Converts project from Godot 3.x to Godot 4.x.\n");
@ -2793,6 +2794,7 @@ bool Main::start() {
String _export_preset; String _export_preset;
bool export_debug = false; bool export_debug = false;
bool export_pack_only = false; bool export_pack_only = false;
bool install_android_build_template = false;
#ifdef MODULE_GDSCRIPT_ENABLED #ifdef MODULE_GDSCRIPT_ENABLED
String gdscript_docs_path; String gdscript_docs_path;
#endif #endif
@ -2825,6 +2827,8 @@ bool Main::start() {
editor = true; editor = true;
} else if (args[i] == "-p" || args[i] == "--project-manager") { } else if (args[i] == "-p" || args[i] == "--project-manager") {
project_manager = true; project_manager = true;
} else if (args[i] == "--install-android-build-template") {
install_android_build_template = true;
#endif // TOOLS_ENABLED #endif // TOOLS_ENABLED
} else if (args[i].length() && args[i][0] != '-' && positional_arg.is_empty()) { } else if (args[i].length() && args[i][0] != '-' && positional_arg.is_empty()) {
positional_arg = args[i]; positional_arg = args[i];
@ -3274,7 +3278,7 @@ bool Main::start() {
sml->get_root()->add_child(editor_node); sml->get_root()->add_child(editor_node);
if (!_export_preset.is_empty()) { if (!_export_preset.is_empty()) {
editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only); editor_node->export_preset(_export_preset, positional_arg, export_debug, export_pack_only, install_android_build_template);
game_path = ""; // Do not load anything. game_path = ""; // Do not load anything.
} }