Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GDExtension: Add status to get_godot_version #103199

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

raulsntos
Copy link
Member

I find myself needing the status for the .NET upgrade tool to determine the version of the packages to use in the upgraded project.

@raulsntos raulsntos added this to the 4.x milestone Feb 23, 2025
@raulsntos raulsntos requested a review from a team as a code owner February 23, 2025 03:56
@raulsntos raulsntos force-pushed the gdextension/version+status branch 2 times, most recently from ec4bb90 to 71b599d Compare February 23, 2025 04:01
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

This looks good, but we also need to remove the registration of the old get_godot_version (without the 2) if Godot is compiled with DISABLED_DEPRECATED. This shouldn't affect the gdextension_interface.h, only whether or not gdextension_get_godot_version() is implemented and if REGISTER_INTERFACE_FUNC(get_godot_version) is called.

@Bromeon
Copy link
Contributor

Bromeon commented Feb 24, 2025

What about other version fields, such as build?

Dictionary Engine::get_version_info() const {
Dictionary dict;
dict["major"] = VERSION_MAJOR;
dict["minor"] = VERSION_MINOR;
dict["patch"] = VERSION_PATCH;
dict["hex"] = VERSION_HEX;
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;
String hash = String(VERSION_HASH);
dict["hash"] = hash.is_empty() ? String("unknown") : hash;
dict["timestamp"] = VERSION_TIMESTAMP;
String stringver = String(dict["major"]) + "." + String(dict["minor"]);
if ((int)dict["patch"] != 0) {
stringver += "." + String(dict["patch"]);
}
stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")";
dict["string"] = stringver;
return dict;
}

Comment on lines 793 to 803
typedef struct {
uint32_t major;
uint32_t minor;
uint32_t patch;
const char *status;
const char *string;
} GDExtensionGodotVersion2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use the opportunity to document each field with a short example value, so it's clear how they look?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I copied the examples from version.h

@raulsntos raulsntos force-pushed the gdextension/version+status branch from 71b599d to 8429df8 Compare February 24, 2025 16:09
@raulsntos
Copy link
Member Author

What about other version fields, such as build?

status was the only one I needed. I can add other fields if you want me to.

To be honest, I forgot Engine::get_version_info existed and, since that's already exposed to scripting, it covers my use case.

@dsnopek
Copy link
Contributor

dsnopek commented Feb 24, 2025

What about other version fields, such as build?

Ah, yeah, we should probably include all the same information from Engine.get_version_info.

To be honest, I forgot Engine::get_version_info existed and, since that's already exposed to scripting, it covers my use case.

FYI, having get_godot_version in the GDExtension interface is useful even with Engine.get_version_info() being available, in case we need to check the version before fully initializing the GDExtension. We're using this presently in godot-cpp, in order to bail early if a 4.1+ extension is loaded on 4.0, because we wouldn't even be able to initialize the GDExtension far enough to actually call Engine.get_version_info()

…ersion`

Added in a new `get_godot_version2` function with a new
`GDExtensionGodotVersion2` to avoid breaking compatibility.
@raulsntos raulsntos force-pushed the gdextension/version+status branch from 8429df8 to 05ffa21 Compare February 24, 2025 16:38
Copy link
Contributor

@dsnopek dsnopek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good to me :-)

@dsnopek dsnopek modified the milestones: 4.x, 4.5 Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants