summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2023-05-15 13:43:46 +0200
committerRémi Verschelde <rverschelde@gmail.com>2023-05-15 13:43:46 +0200
commit70dcfdab1f4fd348925264c241e28f99349a1e0d (patch)
tree53269068d55de8d4a552f7cd4a43f8e4a0f00df1 /main
parent88f5b8d68767a4a4ef94b2780dc4d416df6fd721 (diff)
parentd8078d3f4ce338d39ee591641e44020fb98cca2a (diff)
downloadredot-engine-70dcfdab1f4fd348925264c241e28f99349a1e0d.tar.gz
Merge pull request #76446 from reduz/add-gdextension-api-compatibility
Add a backwards-compatibility system for GDExtension
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/main/main.cpp b/main/main.cpp
index b9f2daf020..f9f2449721 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -221,6 +221,8 @@ static bool print_fps = false;
#ifdef TOOLS_ENABLED
static bool dump_gdextension_interface = false;
static bool dump_extension_api = false;
+static bool validate_extension_api = false;
+static String validate_extension_api_file;
#endif
bool profile_gpu = false;
@@ -494,6 +496,7 @@ void Main::print_help(const char *p_binary) {
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");
OS::get_singleton()->print(" --dump-gdextension-interface Generate GDExtension header file 'gdextension_interface.h' in the current folder. This file is the base file required to implement a GDExtension.\n");
OS::get_singleton()->print(" --dump-extension-api Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.\n");
+ OS::get_singleton()->print(" --validate-extension-api <path> Validate an extension API file dumped (with the option above) from a previous version of the engine to ensure API compatibility. If incompatibilities or errors are detected, the return code will be non zero.\n");
OS::get_singleton()->print(" --startup-benchmark Benchmark the startup time and print it to console.\n");
OS::get_singleton()->print(" --startup-benchmark-file <path> Benchmark the startup time and save it to a given file in JSON format.\n");
#ifdef TESTS_ENABLED
@@ -1171,6 +1174,25 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// run the project instead of a cmdline tool.
// Needs full refactoring to fix properly.
main_args.push_back(I->get());
+ } else if (I->get() == "--validate-extension-api") {
+ // Register as an editor instance to use low-end fallback if relevant.
+ editor = true;
+ cmdline_tool = true;
+ validate_extension_api = true;
+ // Hack. Not needed but otherwise we end up detecting that this should
+ // run the project instead of a cmdline tool.
+ // Needs full refactoring to fix properly.
+ main_args.push_back(I->get());
+
+ if (I->next()) {
+ validate_extension_api_file = I->next()->get();
+
+ N = I->next()->next();
+ } else {
+ OS::get_singleton()->print("Missing file to load argument after --validate-extension-api, aborting.");
+ goto error;
+ }
+
} else if (I->get() == "--export-release" || I->get() == "--export-debug" ||
I->get() == "--export-pack") { // Export project
// Actually handling is done in start().
@@ -2743,6 +2765,12 @@ bool Main::start() {
return false;
}
+ if (validate_extension_api) {
+ bool valid = GDExtensionAPIDump::validate_extension_json_file(validate_extension_api_file) == OK;
+ OS::get_singleton()->set_exit_code(valid ? EXIT_SUCCESS : EXIT_FAILURE);
+ return false;
+ }
+
#ifndef DISABLE_DEPRECATED
if (converting_project) {
int ret = ProjectConverter3To4(converter_max_kb_file, converter_max_line_length).convert();