git: Properly verify that plugins built from the plugin template can be loaded by ImHex (#2352)

This commit is contained in:
Nik
2025-07-24 20:35:02 +02:00
committed by GitHub
parent 0e720a1e02
commit 2e200a2ab8
7 changed files with 70 additions and 28 deletions

View File

@@ -415,7 +415,37 @@ namespace hex::plugin::builtin {
}
void handleDebugModeCommand(const std::vector<std::string> &) {
hex::dbg::setDebugModeEnabled(true);
dbg::setDebugModeEnabled(true);
}
void handleValidatePluginCommand(const std::vector<std::string> &args) {
if (args.size() != 1) {
log::println("usage: imhex --validate-plugin <plugin path>");
std::exit(EXIT_FAILURE);
}
log::resumeLogging();
const auto plugin = Plugin(args[0]);
if (!plugin.isLoaded()) {
log::println("Plugin couldn't be loaded. Make sure the plugin was built using the SDK of this ImHex version!");
std::exit(EXIT_FAILURE);
}
if (!plugin.isValid()) {
log::println("Plugin is missing required init function! Make sure your plugin has a IMHEX_PLUGIN_SETUP or IMHEX_LIBRARY_SETUP block!");
std::exit(EXIT_FAILURE);
}
if (!plugin.initializePlugin()) {
log::println("An error occurred while trying to initialize the plugin. Check the logs for more information.");
std::exit(EXIT_FAILURE);
}
log::println("Plugin is valid!");
std::exit(EXIT_SUCCESS);
}