Clean up ProjectConverter3To4 architecture, move renames map to separate file
This allows properly limiting what features depend on the RegEx module (doing the actual conversion) and what features only require the renames data (GDScript suggestions). Also better excludes the conversion command line options when actually disabling deprecated code. Fixes #73029.
This commit is contained in:
@ -93,13 +93,17 @@
|
||||
#include "editor/editor_settings.h"
|
||||
#include "editor/editor_translation.h"
|
||||
#include "editor/progress_dialog.h"
|
||||
#include "editor/project_converter_3_to_4.h"
|
||||
#include "editor/project_manager.h"
|
||||
#include "editor/register_editor_types.h"
|
||||
|
||||
#ifndef NO_EDITOR_SPLASH
|
||||
#include "main/splash_editor.gen.h"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
#include "editor/project_converter_3_to_4.h"
|
||||
#endif // DISABLE_DEPRECATED
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#include "modules/modules_enabled.gen.h" // For mono.
|
||||
|
||||
@ -163,8 +167,10 @@ static OS::ProcessID editor_pid = 0;
|
||||
static bool found_project = false;
|
||||
static bool auto_build_solutions = false;
|
||||
static String debug_server_uri;
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
static int converter_max_kb_file = 4 * 1024; // 4MB
|
||||
static int converter_max_line_length = 100000;
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
HashMap<Main::CLIScope, Vector<String>> forwardable_cli_arguments;
|
||||
#endif
|
||||
@ -423,10 +429,12 @@ void Main::print_help(const char *p_binary) {
|
||||
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-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");
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
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(" --validate-conversion-3to4 [<max_file_kb>] [<max_line_size>]\n");
|
||||
OS::get_singleton()->print(" Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n");
|
||||
#endif // DISABLE_DEPRECATED
|
||||
OS::get_singleton()->print(" --doctool [<path>] Dump the engine API reference to the given <path> (defaults to current dir) in XML format, merging if existing files are found.\n");
|
||||
OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
|
||||
OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n");
|
||||
@ -1108,6 +1116,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
editor = true;
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
} else if (I->get() == "--convert-3to4") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
@ -1138,6 +1147,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // DISABLE_DEPRECATED
|
||||
} else if (I->get() == "--doctool") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
@ -1147,7 +1157,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
|
||||
audio_driver = NULL_AUDIO_DRIVER;
|
||||
display_driver = NULL_DISPLAY_DRIVER;
|
||||
main_args.push_back(I->get());
|
||||
#endif
|
||||
#endif // TOOLS_ENABLED
|
||||
} else if (I->get() == "--path") { // set path of project to start or edit
|
||||
|
||||
if (I->next()) {
|
||||
@ -2370,7 +2380,7 @@ bool Main::start() {
|
||||
bool converting_project = false;
|
||||
bool validating_converting_project = false;
|
||||
#endif // DISABLE_DEPRECATED
|
||||
#endif
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
|
||||
List<String> args = OS::get_singleton()->get_cmdline_args();
|
||||
@ -2395,7 +2405,7 @@ bool Main::start() {
|
||||
editor = true;
|
||||
} else if (args[i] == "-p" || args[i] == "--project-manager") {
|
||||
project_manager = true;
|
||||
#endif
|
||||
#endif // TOOLS_ENABLED
|
||||
} else if (args[i].length() && args[i][0] != '-' && positional_arg.is_empty()) {
|
||||
positional_arg = args[i];
|
||||
|
||||
@ -2553,18 +2563,22 @@ bool Main::start() {
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
if (converting_project) {
|
||||
int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
int ret = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert();
|
||||
if (ret) {
|
||||
OS::get_singleton()->set_exit_code(EXIT_SUCCESS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (validating_converting_project) {
|
||||
int exit_code = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).validate_conversion();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
bool ret = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).validate_conversion();
|
||||
if (ret) {
|
||||
OS::get_singleton()->set_exit_code(EXIT_SUCCESS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // DISABLE_DEPRECATED
|
||||
|
||||
#endif
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
if (script.is_empty() && game_path.is_empty() && String(GLOBAL_GET("application/run/main_scene")) != "") {
|
||||
game_path = GLOBAL_GET("application/run/main_scene");
|
||||
|
||||
Reference in New Issue
Block a user