| 96 | typedef void (*InitCallback)(Plugin*); |
| 97 | |
| 98 | static InitCallback loadPluginCallback(Plugin* plugin) { |
| 99 | // Load plugin library |
| 100 | std::string libraryExt; |
| 101 | #if defined ARCH_LIN |
| 102 | libraryExt = "so"; |
| 103 | #elif defined ARCH_WIN |
| 104 | libraryExt = "dll"; |
| 105 | #elif defined ARCH_MAC |
| 106 | libraryExt = "dylib"; |
| 107 | #endif |
| 108 | |
| 109 | std::string libraryFilename = "plugin." + libraryExt; |
| 110 | std::string libraryPath = system::join(plugin->path, libraryFilename); |
| 111 | |
| 112 | // Check file existence |
| 113 | if (!system::isFile(libraryPath)) |
| 114 | throw Exception("Plugin binary not found at %s", libraryPath.c_str()); |
| 115 | |
| 116 | // Load dynamic/shared library |
| 117 | plugin->handle = loadLibrary(libraryPath); |
| 118 | |
| 119 | // Get plugin's init() function |
| 120 | InitCallback initCallback = (InitCallback) getSymbol(plugin->handle, "init"); |
| 121 | if (!initCallback) |
| 122 | throw Exception("Failed to read init() symbol in %s", libraryPath.c_str()); |
| 123 | |
| 124 | return initCallback; |
| 125 | } |
| 126 | |
| 127 | |
| 128 | /** If path is blank, loads Core */ |
no test coverage detected