From d5a572bd39e5b29af8a17af792a43b409ae1cb06 Mon Sep 17 00:00:00 2001 From: Vaxry <43317083+vaxerski@users.noreply.github.com> Date: Sat, 14 Oct 2023 18:47:43 +0100 Subject: Plugin API: Add version query (#3545) --- src/plugins/PluginAPI.hpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'src/plugins/PluginAPI.hpp') diff --git a/src/plugins/PluginAPI.hpp b/src/plugins/PluginAPI.hpp index c14c820a..2809c3f6 100644 --- a/src/plugins/PluginAPI.hpp +++ b/src/plugins/PluginAPI.hpp @@ -42,6 +42,14 @@ struct SFunctionMatch { std::string demangled; }; +struct SVersionInfo { + std::string hash; + std::string tag; + bool dirty = false; + std::string branch; + std::string message; +}; + #define APICALL extern "C" #define EXPORT __attribute__((visibility("default"))) #define REQUIRED @@ -250,4 +258,20 @@ namespace HyprlandAPI { Empty means either none found or handle was invalid */ APICALL std::vector findFunctionsByName(HANDLE handle, const std::string& name); -}; \ No newline at end of file + + /* + Returns the hyprland version data. It's highly advised to not run plugins compiled + for a different hash. + */ + APICALL SVersionInfo getHyprlandVersion(HANDLE handle); +}; + +/* + Get the hash this plugin/server was compiled with. + + This function will end up in both hyprland and any/all plugins, + and can be found by a simple dlsym() +*/ +APICALL inline EXPORT const char* __hyprland_api_get_hash() { + return GIT_COMMIT_HASH; +} -- cgit v1.2.3