Commit 15043922 authored by T.J. Corona's avatar T.J. Corona Committed by Kitware Robot

Merge topic 'runtime-loaded-plugins'

69875131 Add support for loading plugins at runtime
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: John Tourtellott's avatarJohn Tourtellott <john.tourtellott@kitware.com>
Merge-request: !685
parents 6e12e90b 69875131
Pipeline #131247 running with stage
......@@ -78,13 +78,7 @@ def configFile(srcdir, blddir, templateFile, outputFile, keywords):
ofile.close()
if readTheDocs or localReadTheDocs:
"""Configure files and run Doxygen ourselves"""
# Configure some files
configFile(sourcedir, builddir, '../cmake/Version.h.in', '../modelbuilder/Version.h', {
'@cmb_version_major@': 6,
'@cmb_version_minor@': 0,
'@cmb_version_patch@': 0,
'@cmb_version@': '6.0.0'})
"""Run Doxygen ourselves"""
# Run doxygen ourselves on ReadTheDocs.org so that doxylinks will work.
if not localSkipDoxygen:
runDoxygen(sourcedir, builddir, 'cmb.doxyfile.in', 'cmb.doxyfile')
......
......@@ -5,7 +5,10 @@ include(${PARAVIEW_USE_FILE})
# Headers that are not Qt subclasses
set(modelbuilder_HDRS
mbPluginConfigLoader.h
mbMenuBuilder.h
${CMAKE_CURRENT_BINARY_DIR}/mbVersion.h
)
# Headers that are Qt subclasses (and thus need moc run on them)
......@@ -17,6 +20,7 @@ set(modelbuilder_MOC_HDRS
# Implementation files.
set(modelbuilder_SRCS
mbPluginConfigLoader.cxx
mbMainWindow.cxx
mbMenuBuilder.cxx
mbTestEventPlayer.cxx
......@@ -69,6 +73,11 @@ include_directories(
)
# ${CMAKE_CURRENT_SOURCE_DIR}/Documentation)
configure_file(
${PROJECT_SOURCE_DIR}/cmake/Version.h.in
${CMAKE_CURRENT_BINARY_DIR}/mbVersion.h
)
configure_file(
mbTestData.h.in
${CMAKE_CURRENT_BINARY_DIR}/mbTestData.h
......
......@@ -10,6 +10,7 @@
#include "modelbuilder/mbMainWindow.h"
#include "modelbuilder/mbMenuBuilder.h"
#include "modelbuilder/mbPluginConfigLoader.h"
#include "modelbuilder/mbTestEventPlayer.h"
#include "modelbuilder/mbTestEventTranslator.h"
#include "modelbuilder/ui_mbFileMenu.h"
......@@ -163,6 +164,8 @@ mbMainWindow::mbMainWindow()
#ifdef DIRECTLY_LINK_TO_SMTK
smtk::extension::paraview::initializeDefaultPlugins();
smtk::extension::paraview::loadDefaultPlugins();
#else
mbPluginConfigLoader::loadPluginConfigFile();
#endif
// Allow multiple panels to dock side-by-side, which is
......
//=============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=============================================================================
#include "mbPluginConfigLoader.h"
#include "mbVersion.h"
#include "vtkPResourceFileLocator.h"
#include "vtkPVPluginTracker.h"
#include "vtkProcessModule.h"
#include "vtkVersion.h"
#include <vtksys/String.hxx>
#include <vtksys/SystemTools.hxx>
namespace
{
/**
* Locate a plugin library or a config file anchored at standard locations
* for locating plugins.
*/
std::string locatePluginConfigFile(const char* plugin)
{
auto pm = vtkProcessModule::GetProcessModule();
// Make sure we can get the options before going further
if (pm == NULL)
{
return std::string();
}
const std::string exe_dir = pm->GetSelfDir();
const std::string vtklib = vtkGetLibraryPathForSymbol(GetVTKVersion);
std::vector<std::string> prefixes = {
std::string("modelbuilder-" CMB_VERSION "/plugins/") + plugin,
std::string("modelbuilder-" CMB_VERSION "/plugins/"),
std::string("lib/modelbuilder-" CMB_VERSION "/plugins/") + plugin,
std::string("lib/modelbuilder-" CMB_VERSION "/plugins/"),
#if defined(__APPLE__)
// needed for Apps
std::string("Plugins/") + plugin,
std::string("Plugins/"),
#elif defined(_WIN32)
std::string("plugins/") + plugin,
std::string("plugins/"),
#endif
std::string()
};
const std::string landmark = plugin;
vtkNew<vtkPResourceFileLocator> locator;
// Now, try the prefixes we so careful put together.
if (!vtklib.empty())
{
auto pluginpath =
locator->Locate(vtksys::SystemTools::GetFilenamePath(vtklib), prefixes, landmark);
if (!pluginpath.empty())
{
return pluginpath + "/" + landmark;
}
}
if (!exe_dir.empty())
{
auto pluginpath = locator->Locate(exe_dir, prefixes, landmark);
if (!pluginpath.empty())
{
return pluginpath + "/" + landmark;
}
}
return std::string();
}
}
void mbPluginConfigLoader::loadPluginConfigFile()
{
std::string pluginFileLocation = locatePluginConfigFile(".plugins");
vtkPVPluginTracker::GetInstance()->LoadPluginConfigurationXML(pluginFileLocation.c_str());
}
//=============================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=============================================================================
#ifndef modelbuilder_mbPluginConfigLoader_h
#define modelbuilder_mbPluginConfigLoader_h
class mbPluginConfigLoader
{
public:
/**\brief Load the plugin config file.
*
*/
static void loadPluginConfigFile();
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment