Merge pull request #1073 from Spartan322/4.4-add/dropin-gdextension-version-check

[4.4] Add Godot drop-in replacement for GDExtension version checks
This commit is contained in:
George L. Albany
2025-08-09 02:47:23 -04:00
committed by GitHub

View File

@@ -316,8 +316,26 @@ Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
} else {
compatible = VERSION_PATCH >= compatibility_minimum[2];
}
bool disable_godot_checks = config->get_value("configuration", "disable_godot_checks", false);
if (!compatible && !disable_godot_checks) {
// Check Godot version lexicographically.
if (GODOT_VERSION_MAJOR != compatibility_minimum[0]) {
compatible = GODOT_VERSION_MAJOR > compatibility_minimum[0];
} else if (GODOT_VERSION_MINOR != compatibility_minimum[1]) {
compatible = GODOT_VERSION_MINOR > compatibility_minimum[1];
} else {
compatible = GODOT_VERSION_PATCH >= compatibility_minimum[2];
}
}
if (!compatible) {
ERR_PRINT(vformat("GDExtension only compatible with Redot version %d.%d.%d or later: %s", compatibility_minimum[0], compatibility_minimum[1], compatibility_minimum[2], p_path));
if (disable_godot_checks) {
ERR_PRINT(vformat("GDExtension only compatible with Redot version %d.%d.%d or later: %s", compatibility_minimum[0], compatibility_minimum[1], compatibility_minimum[2], p_path));
} else {
ERR_PRINT(vformat("GDExtension only compatible with Redot/Godot version %d.%d.%d or later: %s", compatibility_minimum[0], compatibility_minimum[1], compatibility_minimum[2], p_path));
}
return ERR_INVALID_DATA;
}
@@ -348,8 +366,26 @@ Error GDExtensionLibraryLoader::parse_gdextension_file(const String &p_path) {
}
#endif
if (!compatible && !disable_godot_checks) {
if (GODOT_VERSION_MAJOR != compatibility_maximum[0]) {
compatible = GODOT_VERSION_MAJOR < compatibility_maximum[0];
} else if (GODOT_VERSION_MINOR != compatibility_maximum[1]) {
compatible = GODOT_VERSION_MINOR < compatibility_maximum[1];
}
#if GODOT_VERSION_PATCH
// #if check to avoid -Wtype-limits warning when 0.
else {
compatible = GODOT_VERSION_PATCH <= compatibility_maximum[2];
}
#endif
}
if (!compatible) {
ERR_PRINT(vformat("GDExtension only compatible with Redot version %s or earlier: %s", compat_string, p_path));
if (disable_godot_checks) {
ERR_PRINT(vformat("GDExtension only compatible with Redot version %s or earlier: %s", compat_string, p_path));
} else {
ERR_PRINT(vformat("GDExtension only compatible with Redot/Godot version %s or earlier: %s", compat_string, p_path));
}
return ERR_INVALID_DATA;
}
}