mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 15:21:56 -05:00
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:
@@ -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) {
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user