diff --git a/CMakeLists.txt b/CMakeLists.txt index ab545e3c4..544ea142d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,7 @@ endif() # Shouldn't be changed without being fully aware of the consequences. set(OSVR_PLUGIN_IGNORE_SUFFIX ".manualload") +set(OSVR_PLUGIN_DEBUG_SUFFIX ".debug") # Figure out what to do with osvr_json_to_c if(CMAKE_CROSSCOMPILING OR ANDROID) diff --git a/cmake-local/osvrConfig.cmake b/cmake-local/osvrConfig.cmake index 8ba84cec7..1ecd12b2c 100644 --- a/cmake-local/osvrConfig.cmake +++ b/cmake-local/osvrConfig.cmake @@ -22,6 +22,9 @@ set(OSVR_CACHED_PLUGIN_DIR "@OSVR_PLUGIN_DIR@" CACHE INTERNAL set(OSVR_PLUGIN_IGNORE_SUFFIX "@OSVR_PLUGIN_IGNORE_SUFFIX@" CACHE INTERNAL "The additional suffix for OSVR plugins that are not to be auto-loaded" FORCE) + +set(OSVR_PLUGIN_DEBUG_SUFFIX "@OSVR_PLUGIN_DEBUG_SUFFIX@" CACHE INTERNAL + "The additional suffix for OSVR plugins that are built in debug mode" FORCE) set(OSVR_CACHED_CONFIG_ROOT "@OSVR_CONFIG_ROOT@" CACHE INTERNAL "The OSVR_CONFIG_ROOT variable for OSVR, for use in installing plugins' sample configs, display descriptors, etc." FORCE) diff --git a/src/osvr/PluginHost/PathConfig.h.cmake_in b/src/osvr/PluginHost/PathConfig.h.cmake_in index f22122fd2..41ba76f0c 100644 --- a/src/osvr/PluginHost/PathConfig.h.cmake_in +++ b/src/osvr/PluginHost/PathConfig.h.cmake_in @@ -35,5 +35,6 @@ #define OSVR_PLUGIN_DIR "@OSVR_PLUGIN_DIR@" #define OSVR_PLUGIN_EXTENSION "@CMAKE_SHARED_MODULE_SUFFIX@" #define OSVR_PLUGIN_IGNORE_SUFFIX "@OSVR_PLUGIN_IGNORE_SUFFIX@" +#define OSVR_PLUGIN_DEBUG_SUFFIX "@OSVR_PLUGIN_DEBUG_SUFFIX@" #endif // INCLUDED_PathConfig_h_GUID_ACBCE484_669E_4BA5_6A87_51519A19EE5A diff --git a/src/osvr/PluginHost/RegistrationContext.cpp b/src/osvr/PluginHost/RegistrationContext.cpp index 629abbe26..3c8b5f10e 100644 --- a/src/osvr/PluginHost/RegistrationContext.cpp +++ b/src/osvr/PluginHost/RegistrationContext.cpp @@ -51,9 +51,6 @@ namespace osvr { namespace pluginhost { static const auto PLUGIN_HOST_LOGGER_NAME = "PluginHost"; -#ifdef _MSC_VER - static const auto PLUGIN_HOST_DEBUG_SUFFIX = ".debug"; -#endif namespace fs = boost::filesystem; struct RegistrationContext::Impl : private boost::noncopyable { @@ -88,16 +85,11 @@ namespace pluginhost { std::string const &name, OSVR_PluginRegContext ctx, bool shouldRethrow = false) { -#if defined(_MSC_VER) && !defined(NDEBUG) - // Visual C++ debug runtime: we append to the plugin name. - const std::string decoratedPluginName = name + PLUGIN_HOST_DEBUG_SUFFIX; -#else - const std::string &decoratedPluginName = name; -#endif + log.debug() << "Trying to load a plugin with the name " - << decoratedPluginName; + << name; try { - plugin = libfunc::loadPluginByName(decoratedPluginName, ctx); + plugin = libfunc::loadPluginByName(name, ctx); return true; } catch (std::runtime_error const &e) { log.debug() << "Failed: " << e.what(); @@ -175,7 +167,7 @@ namespace pluginhost { // Visual C++ debug runtime: we append to the plugin name. Must only // load debug plugins iff we're a debug server const auto isDebugRuntimePlugin = - boost::iends_with(pluginBaseName, PLUGIN_HOST_DEBUG_SUFFIX); + boost::iends_with(pluginBaseName, OSVR_PLUGIN_DEBUG_SUFFIX); #if defined(NDEBUG) /// This is a non-debug build. if (isDebugRuntimePlugin) { diff --git a/src/osvr/PluginHost/SearchPath.cpp b/src/osvr/PluginHost/SearchPath.cpp index 78eeb2cd7..205ab6496 100644 --- a/src/osvr/PluginHost/SearchPath.cpp +++ b/src/osvr/PluginHost/SearchPath.cpp @@ -23,8 +23,8 @@ // limitations under the License. // Internal Includes -#include #include +#include #include #include @@ -33,9 +33,9 @@ #include // Standard includes -#include -#include #include +#include +#include namespace osvr { namespace pluginhost { @@ -172,11 +172,20 @@ namespace pluginhost { } const auto pluginBaseName = pluginCandidate.filename().stem().generic_string(); + +#if defined(_MSC_VER) && !defined(NDEBUG) + // Visual C++ debug runtime: we append to the plugin name. + const std::string decoratedPluginName = + pluginName + OSVR_PLUGIN_DEBUG_SUFFIX; +#else + const std::string &decoratedPluginName = pluginName; +#endif + /// If the name is right or has the manual load suffix, this is /// a good one. if ((pluginBaseName == pluginName) || (pluginBaseName == - pluginName + OSVR_PLUGIN_IGNORE_SUFFIX)) { + decoratedPluginName + OSVR_PLUGIN_IGNORE_SUFFIX)) { return pluginPathName.path().generic_string(); } }