From 39cd19d2e38dad62a55b0540eeb717397fba3714 Mon Sep 17 00:00:00 2001 From: Frank Gaede <frank.gaede@desy.de> Date: Tue, 22 Mar 2016 13:11:13 +0000 Subject: [PATCH] - added some fixes and debug printout for Mac (APPLE) - plugin mechanism still broken ... --- GaudiPluginService/CMakeLists.txt | 4 ++++ GaudiPluginService/src/PluginService.cpp | 13 +++++++++++++ GaudiPluginService/src/listcomponents.cpp | 21 ++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/GaudiPluginService/CMakeLists.txt b/GaudiPluginService/CMakeLists.txt index 404e2e2e4..c8bf19e02 100644 --- a/GaudiPluginService/CMakeLists.txt +++ b/GaudiPluginService/CMakeLists.txt @@ -6,6 +6,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) #add_library(DD4hepGaudiPluginMgr SHARED src/PluginService.cpp src/capi_pluginservice.cpp interface/DD4hep.cpp) add_library(DD4hepGaudiPluginMgr SHARED src/PluginService.cpp interface/DD4hep.cpp) add_definitions(-DGaudi=DD4hep_Flavor) +if( APPLE ) + add_definitions( -DAPPLE) +endif() + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") target_link_libraries(DD4hepGaudiPluginMgr ${CMAKE_DL_LIBS}) SET_TARGET_PROPERTIES(DD4hepGaudiPluginMgr PROPERTIES VERSION ${DD4hep_VERSION} SOVERSION ${DD4hep_SOVERSION}) diff --git a/GaudiPluginService/src/PluginService.cpp b/GaudiPluginService/src/PluginService.cpp index 4337611b7..a86549756 100644 --- a/GaudiPluginService/src/PluginService.cpp +++ b/GaudiPluginService/src/PluginService.cpp @@ -148,9 +148,14 @@ namespace Gaudi { namespace PluginService { #ifdef WIN32 const char* envVar = "PATH"; const char sep = ';'; +#else +#ifdef APPLE + const char* envVar = "DYLD_LIBRARY_PATH"; + const char sep = ':'; #else const char* envVar = "LD_LIBRARY_PATH"; const char sep = ':'; +#endif #endif char *search_path = ::getenv(envVar); if (search_path) { @@ -248,6 +253,14 @@ namespace Gaudi { namespace PluginService { entry = facts.insert(std::make_pair(id, FactoryInfo("unknown", factory, type, rtype, className, props))).first; +#if APPLE +#define DEBUG_FOR_MAC 1 +#endif + +#if DEBUG_FOR_MAC + std::cout << " -- registering factory id: " << id << " class : " << className << " with registry " << this << std::endl ; +#endif + } else { // do not replace an existing factory with a new one if (!entry->second.ptr) { diff --git a/GaudiPluginService/src/listcomponents.cpp b/GaudiPluginService/src/listcomponents.cpp index 733f6a7dd..ac547eb46 100644 --- a/GaudiPluginService/src/listcomponents.cpp +++ b/GaudiPluginService/src/listcomponents.cpp @@ -46,6 +46,15 @@ int main(int argc, char* argv[]) { Gaudi::PluginService::Details::Registry::instance(); typedef Gaudi::PluginService::Details::Registry::KeyType key_type; +#if APPLE +#define DEBUG_FOR_MAC 1 +#endif + +#if DEBUG_FOR_MAC + Gaudi::PluginService::SetDebug( 2 ) ; +#endif + + // cache to keep track of the loaded factories std::map<key_type, std::string> loaded; { @@ -57,6 +66,11 @@ int main(int argc, char* argv[]) { } } +#if DEBUG_FOR_MAC + std::cout << " --- using registry : " << ® << " --- with " << loaded.size() << " pre-loeaded libraries " << std::endl ; +#endif + + // Parse command line std::list<char*> libs; std::string output_opt("-"); @@ -103,10 +117,15 @@ int main(int argc, char* argv[]) { // loop over the list of libraries passed on the command line for (char* lib: libs) { - if (dlopen(lib, RTLD_LAZY | RTLD_LOCAL)) { + if (dlopen(lib, RTLD_LAZY | RTLD_GLOBAL)) { std::set<key_type> factories = reg.loadedFactories(); std::set<key_type>::const_iterator f; + +#if DEBUG_FOR_MAC + std::cout << " --- registry : " << ® << " --- has " << factories.size() << " factories " << std::endl ; +#endif + for (f = factories.begin(); f != factories.end(); ++f) { if (loaded.find(*f) == loaded.end()) { -- GitLab