You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-18 14:21:41 +00:00
Merge pull request #76446 from reduz/add-gdextension-api-compatibility
Add a backwards-compatibility system for GDExtension
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user