Merge pull request #51950 from qarmin/bad_godot4_converter
This commit is contained in:
commit
4bbe7f0b98
|
@ -28,6 +28,7 @@ jobs:
|
|||
doc-test: true
|
||||
bin: "./bin/godot.linuxbsd.opt.tools.64.mono"
|
||||
build-mono: true
|
||||
proj-conv: true
|
||||
artifact: true
|
||||
|
||||
- name: Editor with doubles and GCC sanitizers (target=debug, tools=yes, float=64, tests=yes, use_asan=yes, use_ubsan=yes)
|
||||
|
@ -147,6 +148,17 @@ jobs:
|
|||
curr="$(pwd)/libvk_swiftshader.so"
|
||||
sed -i "s|PATH_TO_CHANGE|$curr|" vk_swiftshader_icd.json
|
||||
|
||||
# Test 3.x -> 4.x project converter
|
||||
- name: Test project converter
|
||||
if: ${{ matrix.proj-conv }}
|
||||
run: |
|
||||
mkdir converter_test
|
||||
cd converter_test
|
||||
touch project.godot
|
||||
../${{ matrix.bin }} --headless --audio-driver Dummy --validate-conversion-3to4
|
||||
cd ..
|
||||
rm converter_test -rf
|
||||
|
||||
# Download and extract zip archive with project, folder is renamed to be able to easy change used project
|
||||
- name: Download test project
|
||||
if: ${{ matrix.proj-test }}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,83 @@
|
|||
/*************************************************************************/
|
||||
/* project_converter_3_to_4.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef PROJECT_CONVERTER_3_TO_4_H
|
||||
#define PROJECT_CONVERTER_3_TO_4_H
|
||||
|
||||
#include "core/core_bind.h"
|
||||
#include "core/io/file_access.h"
|
||||
#include "core/object/ref_counted.h"
|
||||
#include "core/string/ustring.h"
|
||||
|
||||
class ProjectConverter3To4 {
|
||||
void rename_enums(String &file_content);
|
||||
Vector<String> check_for_rename_enums(Vector<String> &file_content);
|
||||
|
||||
void rename_classes(String &file_content);
|
||||
Vector<String> check_for_rename_classes(Vector<String> &file_content);
|
||||
|
||||
void rename_gdscript_functions(String &file_content);
|
||||
Vector<String> check_for_rename_gdscript_functions(Vector<String> &file_content);
|
||||
|
||||
void rename_csharp_functions(String &file_content);
|
||||
Vector<String> check_for_rename_csharp_functions(Vector<String> &file_content);
|
||||
|
||||
void rename_gdscript_keywords(String &file_content);
|
||||
Vector<String> check_for_rename_gdscript_keywords(Vector<String> &file_content);
|
||||
|
||||
void custom_rename(String &file_content, String from, String to);
|
||||
Vector<String> check_for_custom_rename(Vector<String> &file_content, String from, String to);
|
||||
|
||||
void rename_common(const char *array[][2], String &file_content);
|
||||
Vector<String> check_for_rename_common(const char *array[][2], Vector<String> &file_content);
|
||||
|
||||
Vector<String> check_for_files();
|
||||
|
||||
Vector<String> parse_arguments(const String &line);
|
||||
int get_end_parenthess(const String &line) const;
|
||||
String connect_arguments(const Vector<String> &line, int from, int to = -1) const;
|
||||
String get_starting_space(const String &line) const;
|
||||
String get_object_of_execution(const String &line) const;
|
||||
|
||||
String line_formatter(int current_line, String from, String to, String line);
|
||||
String simple_line_formatter(int current_line, String old_line, String line);
|
||||
|
||||
bool test_single_array(const char *array[][2], bool ignore_second_check = false);
|
||||
bool test_conversion_single_additional(String name, String expected, void (ProjectConverter3To4::*func)(String &), String what);
|
||||
bool test_conversion_single_normal(String name, String expected, const char *array[][2], String what);
|
||||
bool test_array_names();
|
||||
bool test_conversion();
|
||||
|
||||
public:
|
||||
int validate_conversion();
|
||||
int convert();
|
||||
};
|
||||
|
||||
#endif // PROJECT_CONVERTER_3_TO_4_H
|
|
@ -87,6 +87,7 @@
|
|||
#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"
|
||||
#ifndef NO_EDITOR_SPLASH
|
||||
#include "main/splash_editor.gen.h"
|
||||
|
@ -368,6 +369,8 @@ void Main::print_help(const char *p_binary) {
|
|||
OS::get_singleton()->print(" <path> should be absolute or relative to the project directory, and include the filename for the binary (e.g. 'builds/game.exe'). The target directory should exist.\n");
|
||||
OS::get_singleton()->print(" --export-debug <preset> <path> Same as --export, but using the debug template.\n");
|
||||
OS::get_singleton()->print(" --export-pack <preset> <path> Same as --export, but only export the game pack for the given preset. The <path> extension determines whether it will be in PCK or ZIP format.\n");
|
||||
OS::get_singleton()->print(" --convert-3to4 Converts project from Godot 3.x to Godot 4.x.\n");
|
||||
OS::get_singleton()->print(" --validate-conversion-3to4 Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x.\n");
|
||||
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");
|
||||
|
@ -996,6 +999,14 @@ 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());
|
||||
} else if (I->get() == "--convert-3to4") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
} else if (I->get() == "--validate-conversion-3to4") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
main_args.push_back(I->get());
|
||||
} else if (I->get() == "--doctool") {
|
||||
// Actually handling is done in start().
|
||||
cmdline_tool = true;
|
||||
|
@ -2035,6 +2046,8 @@ bool Main::start() {
|
|||
String _export_preset;
|
||||
bool export_debug = false;
|
||||
bool export_pack_only = false;
|
||||
bool converting_project = false;
|
||||
bool validating_converting_project = false;
|
||||
#endif
|
||||
|
||||
main_timer_sync.init(OS::get_singleton()->get_ticks_usec());
|
||||
|
@ -2050,6 +2063,10 @@ bool Main::start() {
|
|||
#ifdef TOOLS_ENABLED
|
||||
} else if (args[i] == "--no-docbase") {
|
||||
doc_base = false;
|
||||
} else if (args[i] == "--convert-3to4") {
|
||||
converting_project = true;
|
||||
} else if (args[i] == "--validate-conversion-3to4") {
|
||||
validating_converting_project = true;
|
||||
} else if (args[i] == "-e" || args[i] == "--editor") {
|
||||
editor = true;
|
||||
} else if (args[i] == "-p" || args[i] == "--project-manager") {
|
||||
|
@ -2203,6 +2220,18 @@ bool Main::start() {
|
|||
NativeExtensionAPIDump::generate_extension_json_file("extension_api.json");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (converting_project) {
|
||||
int exit_code = ProjectConverter3To4().convert();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
if (validating_converting_project) {
|
||||
int exit_code = ProjectConverter3To4().validate_conversion();
|
||||
OS::get_singleton()->set_exit_code(exit_code);
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
if (script.is_empty() && game_path.is_empty() && String(GLOBAL_GET("application/run/main_scene")) != "") {
|
||||
|
|
|
@ -78,6 +78,8 @@ _arguments \
|
|||
'--export[export the project using the given preset and matching release template]:export preset name then path' \
|
||||
'--export-debug[same as --export, but using the debug template]:export preset name then path' \
|
||||
'--export-pack[same as --export, but only export the game pack for the given preset]:export preset name then path' \
|
||||
'--convert-3to4[converts project from Godot 3.x to Godot 4.x]' \
|
||||
'--validate-conversion-3to4[shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x]' \
|
||||
'--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory (optional):_dirs' \
|
||||
'--no-docbase[disallow dumping the base types (used with --doctool)]' \
|
||||
'--build-solutions[build the scripting solutions (e.g. for C# projects)]' \
|
||||
|
|
|
@ -81,6 +81,8 @@ _complete_godot_options() {
|
|||
--export
|
||||
--export-debug
|
||||
--export-pack
|
||||
--convert-3to4
|
||||
--validate-conversion-3to4
|
||||
--doctool
|
||||
--no-docbase
|
||||
--build-solutions
|
||||
|
|
|
@ -93,6 +93,8 @@ complete -c godot -l check-only -d "Only parse for errors and quit (use with --s
|
|||
complete -c godot -l export -d "Export the project using the given preset and matching release template" -x
|
||||
complete -c godot -l export-debug -d "Same as --export, but using the debug template" -x
|
||||
complete -c godot -l export-pack -d "Same as --export, but only export the game pack for the given preset" -x
|
||||
complete -c godot -l convert-3to4 -d "Converts project from Godot 3.x to Godot 4.x"
|
||||
complete -c godot -l validate-conversion-3to4 -d "Shows what elements will be renamed when converting project from Godot 3.x to Godot 4.x"
|
||||
complete -c godot -l doctool -d "Dump the engine API reference to the given path in XML format, merging if existing files are found" -r
|
||||
complete -c godot -l no-docbase -d "Disallow dumping the base types (used with --doctool)"
|
||||
complete -c godot -l build-solutions -d "Build the scripting solutions (e.g. for C# projects)"
|
||||
|
|
Loading…
Reference in New Issue