mirror of https://github.com/OpenMW/openmw.git
Initial stab at OSG plugin checker
It doesn't work yet due to osgDB::listAllAvailablePlugins returning a list of paths to dynamic libraries. That means: * the check fails when the required plugin is linked statically. * we're going to have to do something to slice up the filenames. * there'll probably be unicode errors when the OpenMW installation path isn't representable by the current eight-bit code page on Windows. Alternatively, we can switch to listing the required file extension support, and use osgDB::Registry::instance()->getReaderWriterList() and each element's supportedExtensions() function, but I don't think we've actually got that list of extensions anywhere and it might get desynced with the existing list of plugins if we add more.fix-osga-rotate-wildly
parent
99164b3a0e
commit
c2d1a4c861
@ -0,0 +1,47 @@
|
||||
#include "components/misc/osgpluginchecker.hpp"
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <osgDB/PluginQuery>
|
||||
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::string_view USED_OSG_PLUGINS = "${USED_OSG_PLUGINS}";
|
||||
|
||||
constexpr std::vector<std::string_view> getRequiredOSGPlugins()
|
||||
{
|
||||
std::vector<std::string_view> requiredOSGPlugins;
|
||||
auto currentStart = USED_OSG_PLUGINS.begin();
|
||||
while (currentStart != USED_OSG_PLUGINS.end())
|
||||
{
|
||||
auto currentEnd = std::find(currentStart, USED_OSG_PLUGINS.end(), ';');
|
||||
requiredOSGPlugins.emplace_back(currentStart, currentEnd);
|
||||
if (currentEnd == USED_OSG_PLUGINS.end())
|
||||
break;
|
||||
currentStart = currentEnd + 1;
|
||||
}
|
||||
return requiredOSGPlugins;
|
||||
}
|
||||
}
|
||||
|
||||
bool checkRequiredOSGPluginsArePresent()
|
||||
{
|
||||
auto availableOSGPlugins = osgDB::listAllAvailablePlugins();
|
||||
auto requiredOSGPlugins = getRequiredOSGPlugins();
|
||||
bool haveAllPlugins = true;
|
||||
for (std::string_view plugin : requiredOSGPlugins)
|
||||
{
|
||||
if (std::find(availableOSGPlugins.begin(), availableOSGPlugins.end(), plugin) == availableOSGPlugins.end())
|
||||
{
|
||||
Log(Debug::Error) << "Missing OSG plugin: " << plugin;
|
||||
haveAllPlugins = false;
|
||||
}
|
||||
}
|
||||
return haveAllPlugins;
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
#ifndef OPENMW_COMPONENTS_MISC_OSGPLUGINCHECKER_HPP
|
||||
#define OPENMW_COMPONENTS_MISC_OSGPLUGINCHECKER_HPP
|
||||
|
||||
namespace Misc
|
||||
{
|
||||
bool checkRequiredOSGPluginsArePresent();
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue