diff --git a/GaudiPluginService/CMakeLists.txt b/GaudiPluginService/CMakeLists.txt index 404e2e2e4b557e19c59dc8c6d0a44cf2fc149235..c8bf19e02e374b85875e16202649ad6b8279cdb6 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 4337611b7656e4e029edd9b8e900a5446b76a7e4..a865497567e43e66c644d7e701903cbb49eec632 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 733f6a7dd586905b05cd9cb953dc96bcbc86c501..ac547eb46bf702c88cc294602e9e1bb8a0eec09e 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()) {