mirror of
https://github.com/hyprwm/Hyprland
synced 2024-12-02 01:05:59 +01:00
Plugin API: Add version query (#3545)
This commit is contained in:
parent
424c9a7e70
commit
d5a572bd39
2 changed files with 35 additions and 2 deletions
|
@ -338,3 +338,12 @@ APICALL std::vector<SFunctionMatch> HyprlandAPI::findFunctionsByName(HANDLE hand
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
APICALL SVersionInfo HyprlandAPI::getHyprlandVersion(HANDLE handle) {
|
||||||
|
auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
|
||||||
|
|
||||||
|
if (!PLUGIN)
|
||||||
|
return {};
|
||||||
|
|
||||||
|
return {GIT_COMMIT_HASH, GIT_TAG, GIT_DIRTY != std::string(""), GIT_BRANCH, GIT_COMMIT_MESSAGE};
|
||||||
|
}
|
|
@ -42,6 +42,14 @@ struct SFunctionMatch {
|
||||||
std::string demangled;
|
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 APICALL extern "C"
|
||||||
#define EXPORT __attribute__((visibility("default")))
|
#define EXPORT __attribute__((visibility("default")))
|
||||||
#define REQUIRED
|
#define REQUIRED
|
||||||
|
@ -250,4 +258,20 @@ namespace HyprlandAPI {
|
||||||
Empty means either none found or handle was invalid
|
Empty means either none found or handle was invalid
|
||||||
*/
|
*/
|
||||||
APICALL std::vector<SFunctionMatch> findFunctionsByName(HANDLE handle, const std::string& name);
|
APICALL std::vector<SFunctionMatch> findFunctionsByName(HANDLE handle, const std::string& name);
|
||||||
|
|
||||||
|
/*
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue