From: vsr Date: Fri, 20 Jan 2017 12:35:03 +0000 (+0300) Subject: Patch for MacOS (from SALOME forum) X-Git-Tag: V8_3_0a2~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=531c1656a2501cfeeefe6ad6a21fb2aa134612bb;p=modules%2Fkernel.git Patch for MacOS (from SALOME forum) --- diff --git a/bin/nameserver.py b/bin/nameserver.py index 726e1d4c9..f9d1a3a2c 100755 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -105,6 +105,8 @@ class NamingServer(Server): Server.initArgs(self) if sys.platform == "win32": env_ld_library_path = ['env', 'LD_LIBRARY_PATH=' + os.getenv("PATH")] + elif sys.platform == "darwin": + env_ld_library_path = ['env', 'DYLD_LIBRARY_PATH=' + os.getenv("DYLD_LIBRARY_PATH"), 'DYLD_FALLBACK_LIBRARY_PATH=' + os.getenv("DYLD_FALLBACK_LIBRARY_PATH")] else: env_ld_library_path = ['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] self.CMD = ['xterm', '-e']+ env_ld_library_path + ['python'] diff --git a/bin/runSalome.py b/bin/runSalome.py index 29ea4e3d1..33886c27f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -89,11 +89,14 @@ def kill_salome(args): class InterpServer(Server): def __init__(self,args): self.args=args - if sys.platform != "win32": - env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] - self.CMD=['xterm', '-e']+ env_ld_library_path + ['python'] - else: + if sys.platform == "win32": self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python'] + elif sys.platform == "darwin": + env_ld_library_path=['env', 'DYLD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] + self.CMD=['xterm', '-e'] + env_ld_library_path + ['python'] + else: + env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] + self.CMD=['xterm', '-e'] + env_ld_library_path + ['python'] def run(self): global process_id diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 71f3aea55..7c034fd9b 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -91,7 +91,7 @@ class SalomeContext: if len(configFileNames) == 0: raise SalomeContextException("No configuration files given") - reserved=['PATH', 'DYLD_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH', 'INCLUDE', 'LIBPATH', 'SALOME_PLUGINS_PATH'] + reserved=['PATH', 'DYLD_FALLBACK_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'MANPATH', 'PV_PLUGIN_PATH', 'INCLUDE', 'LIBPATH', 'SALOME_PLUGINS_PATH'] for filename in configFileNames: basename, extension = os.path.splitext(filename) if extension == ".cfg": @@ -142,6 +142,11 @@ class SalomeContext: def addToLdLibraryPath(self, value): if platform.system() == 'Windows': self.addToVariable('PATH', value) + elif platform.system() == 'Darwin': + if "LAPACK" in value: + self.addToVariable('DYLD_FALLBACK_LIBRARY_PATH', value) + else: + self.addToVariable('DYLD_LIBRARY_PATH', value) else: self.addToVariable('LD_LIBRARY_PATH', value) # diff --git a/bin/server.py b/bin/server.py index 432a6c6ad..75b6b16e0 100755 --- a/bin/server.py +++ b/bin/server.py @@ -62,7 +62,11 @@ class Server: myargs=self.ARGS if self.args.get('xterm'): # (Debian) send LD_LIBRARY_PATH to children shells (xterm) - if sys.platform != "win32": + if sys.platform == "darwin": + env_ld_library_path=['env', 'DYLD_LIBRARY_PATH=' + + os.getenv("DYLD_FALLBACK_LIBRARY_PATH")] + myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path + elif sys.platform != "win32": env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path diff --git a/bin/setenv.py b/bin/setenv.py index b8eb466f8..693a51feb 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -177,6 +177,9 @@ def set_env(args, modules_list, modules_root_dir, silent=False): if sys.platform == "win32": add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), "PATH") + elif sys.platform == "darwin": + add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), + "DYLD_LIBRARY_PATH") else: add_path(os.path.join(module_root_dir,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH") diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 8a84c67d1..311b5f7d8 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -893,14 +893,19 @@ void Engines_Component_i::sendMessage(const char *event_type, std::string Engines_Component_i::GetDynLibraryName(const char *componentName) { -#ifndef WIN32 - std::string ret="lib"; - ret+=componentName; - ret+="Engine.so"; + std::string prefix, suffix; + std::string cname = componentName; +#if !defined(WIN32) + prefix = "lib"; +#endif +#if defined(WIN32) + suffix = "dll"; +#elif defined(__APPLE__) + suffix = "dylib"; #else - std::string ret=componentName; - ret+="Engine.dll"; + suffix = "so"; #endif + std::string ret = prefix + cname + std::string("Engine.") + suffix; return ret; } diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index a7eb1197d..b681a0124 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -78,7 +78,11 @@ extern "C" {void SigIntHandler( int ) ; } #ifndef WIN32 #define LIB "lib" +#ifdef __APPLE__ +#define ENGINESO "Engine.dylib" +#else #define ENGINESO "Engine.so" +#endif #else #define LIB "" #define ENGINESO "Engine.dll" @@ -519,7 +523,11 @@ Engines_Container_i::load_component_CppImplementation(const char* componentName, { //not loadable. Try to find the lib file in LD_LIBRARY_PATH std::string path; +#ifdef __APPLE__ + char* p=getenv("DYLD_LIBRARY_PATH"); +#else char* p=getenv("LD_LIBRARY_PATH"); +#endif if(p)path=p; path=path+SEP+"/usr/lib"+SEP+"/lib"; diff --git a/src/KERNEL_PY/salome_test.py b/src/KERNEL_PY/salome_test.py index c70a0f5b3..e0bdd983f 100755 --- a/src/KERNEL_PY/salome_test.py +++ b/src/KERNEL_PY/salome_test.py @@ -184,10 +184,7 @@ else: # ---- create hypotheses -if sys.platform == "win32": - stdMeshersEngine = "StdMeshersEngine" -else: - stdMeshersEngine = "libStdMeshersEngine.so" +stdMeshersEngine = "StdMeshersEngine" print print "--- Create hypotheses ..." diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 9d7a5db9e..8f4c19fe5 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -631,7 +631,11 @@ void LifeCycleCORBATest::testgetLocalFile_localComputer() { SALOME_LifeCycleCORBA _LCC(&_NS); std::string origFileName = getenv("KERNEL_ROOT_DIR"); +#ifdef __APPLE__ + origFileName += "/lib/salome/libSalomeLifeCycleCORBA.dylib"; +#else origFileName += "/lib/salome/libSalomeLifeCycleCORBA.so.0.0.0"; +#endif SALOME_FileTransferCORBA transfer( Kernel_Utils::GetHostname(), origFileName); std::string local = transfer.getLocalFile(); @@ -649,7 +653,11 @@ void LifeCycleCORBATest::testgetLocalFile_remoteComputer() { SALOME_LifeCycleCORBA _LCC(&_NS); std::string origFileName = getenv("KERNEL_ROOT_DIR"); +#ifdef __APPLE__ + origFileName += "/lib/salome/libSalomeContainer.dylib"; +#else origFileName += "/lib/salome/libSalomeContainer.so.0.0.0"; +#endif SALOME_FileTransferCORBA transfer( GetRemoteHost(), origFileName); std::string local = transfer.getLocalFile(); diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index ed1c745a5..ddda604a4 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -149,7 +149,11 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName) // --- try dlopen C++ component +#ifdef __APPLE__ + std::string impl_name = std::string ("lib") + aCompName + std::string("Engine.dylib"); +#else std::string impl_name = std::string ("lib") + aCompName + std::string("Engine.so"); +#endif _numInstanceMutex.lock(); // lock to be alone // (see decInstanceCnt, finalize_removal)) @@ -303,7 +307,11 @@ Engines_MPIContainer_i::Lcreate_component_instance( const char* genericRegisterN //--- try C++ +#ifdef __APPLE__ + std::string impl_name = std::string ("lib") + genericRegisterName +std::string("Engine.dylib"); +#else std::string impl_name = std::string ("lib") + genericRegisterName +std::string("Engine.so"); +#endif if (_library_map.count(impl_name) != 0) // C++ component { void* handle = _library_map[impl_name]; diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx index fd75687f9..f5fb351fc 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.cxx @@ -828,7 +828,11 @@ std::string Engines_Parallel_Component_i::GetDynLibraryName(const char *componen #ifndef WIN32 std::string ret="lib"; ret+=componentName; +#ifdef __APPLE__ + ret+="Engine.dylib"; +#else ret+="Engine.so"; +#endif #else std::string ret=componentName; ret+="Engine.dll"; diff --git a/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx b/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx index c337776e2..25267d785 100644 --- a/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx @@ -158,7 +158,11 @@ Container_proxy_impl_final::load_component_Library(const char* componentName, CO MESSAGE("Try to load C++ component"); #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName + string("Engine.so"); +#endif #else std::string impl_name = aCompName + string("Engine.dll"); #endif @@ -313,7 +317,11 @@ Container_proxy_impl_final::create_component_instance_env(const char* componentN // On commence par créer le proxy #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName + string("Engine.so"); +#endif #else std::string impl_name = aCompName + string("Engine.dll"); #endif diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx index 263b8531c..14a612934 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx @@ -295,7 +295,11 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName, bool ret = false; std::string aCompName = componentName; #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName + string("Engine.so"); +#endif #else std::string impl_name = aCompName + string("Engine.dll"); #endif @@ -423,7 +427,11 @@ Engines_Parallel_Container_i::create_component_instance_env(const char*genericRe std::string aCompName = genericRegisterName; #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName +string("Engine.so"); +#endif #else std::string impl_name = aCompName +string("Engine.dll"); #endif @@ -935,7 +943,11 @@ Engines_Parallel_Container_i::create_paco_component_node_instance(const char* co std::string _proxy_containerName = proxy_containerName; #ifndef WIN32 +#ifdef __APPLE__ + string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else string impl_name = string ("lib") + aCompName +string("Engine.so"); +#endif #else string impl_name = aCompName +string("Engine.dll"); #endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx index bfada6418..f1571a2ab 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx +++ b/src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx @@ -29,8 +29,12 @@ static HMODULE _libHandle = 0; #else #include static void* _libHandle = NULL; +#ifdef __APPLE__ +#define SALOMEDS_LIB_NAME "libSalomeDS.dylib" +#else #define SALOMEDS_LIB_NAME "libSalomeDS.so" #endif +#endif #define SOBJECT_FACTORY "SObjectFactory" #define SCOMPONENT_FACTORY "SComponentFactory" diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx index e346706cf..6a5a962ac 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx @@ -113,7 +113,11 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() #ifndef WIN32 void* handle; std::string impl_name = std::string ("lib") + traceKind +#ifdef __APPLE__ + + std::string("TraceCollector.dylib"); +#else + std::string("TraceCollector.so"); +#endif handle = dlopen( impl_name.c_str() , RTLD_LAZY | RTLD_GLOBAL ) ; #else HINSTANCE handle; @@ -173,13 +177,16 @@ int LocalTraceBufferPool::insert(int traceType, const char* msg) // wait until there is a free buffer in the pool +#ifdef __APPLE__ + dispatch_semaphore_wait(_freeBufferSemaphore, DISPATCH_TIME_FOREVER); +#else int ret = -1; while (ret) { ret = sem_wait(&_freeBufferSemaphore); if (ret) perror(" LocalTraceBufferPool::insert, sem_wait"); } - +#endif // get the next free buffer available (mutex protected) unsigned long myInsertPos = lockedIncrement(_insertPos); @@ -197,12 +204,20 @@ int LocalTraceBufferPool::insert(int traceType, const char* msg) // increment the full buffer semaphore // (if previously 0, awake thread in charge of trace) +#ifdef __APPLE__ + dispatch_semaphore_signal(_fullBufferSemaphore); +#else ret = sem_post(&_fullBufferSemaphore); +#endif - // returns the number of free buffers + // returns the number of free buffers +#ifdef __APPLE__ + return 0; +#else sem_getvalue(&_freeBufferSemaphore, &ret); return ret; +#endif } // ============================================================================ @@ -218,13 +233,16 @@ int LocalTraceBufferPool::retrieve(LocalTrace_TraceInfo& aTrace) // wait until there is a buffer in the pool, with a message to print +#ifdef __APPLE__ + dispatch_semaphore_wait(_fullBufferSemaphore, DISPATCH_TIME_FOREVER); +#else int ret = -1; while (ret) { ret = sem_wait(&_fullBufferSemaphore); if (ret) MESSAGE (" LocalTraceBufferPool::retrieve, sem_wait"); } - +#endif // get the next buffer to print unsigned long myRetrievePos = lockedIncrement(_retrievePos); @@ -241,12 +259,20 @@ int LocalTraceBufferPool::retrieve(LocalTrace_TraceInfo& aTrace) // threads are waiting to put a trace: the waken up thread is not // necessarily the first thread to wait. +#ifdef __APPLE__ + dispatch_semaphore_signal(_freeBufferSemaphore); +#else ret = sem_post(&_freeBufferSemaphore); +#endif // returns the number of full buffers +#ifdef __APPLE__ + return 0; +#else sem_getvalue(&_fullBufferSemaphore, &ret); return ret; +#endif } // ============================================================================ @@ -282,10 +308,16 @@ LocalTraceBufferPool::LocalTraceBufferPool() for (int i=0; i #include +#ifdef __APPLE__ +#include +#endif #include "BaseTraceCollector.hxx" #include "BasicsGenericDestructor.hxx" @@ -68,8 +71,13 @@ class SALOMELOCALTRACE_EXPORT LocalTraceBufferPool : public PROTECTED_DELETE static BaseTraceCollector *_myThreadTrace; LocalTrace_TraceInfo _myBuffer[TRACE_BUFFER_SIZE]; +#ifdef __APPLE__ + dispatch_semaphore_t _freeBufferSemaphore; // to wait until there is a free buffer + dispatch_semaphore_t _fullBufferSemaphore; // to wait until there is a buffer to print +#else sem_t _freeBufferSemaphore; // to wait until there is a free buffer sem_t _fullBufferSemaphore; // to wait until there is a buffer to print +#endif pthread_mutex_t _incrementMutex; // to lock position variables for increment unsigned long _position; unsigned long _insertPos; diff --git a/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx index 8e329e5b6..b46d5ae53 100644 --- a/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx +++ b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx @@ -18,12 +18,11 @@ // // Author : Anthony GEAY (EDF R&D) +#include #include "SALOMESDS_BasicDataServer.hxx" #include "SALOMESDS_DataScopeServer.hxx" #include "SALOMESDS_Exception.hxx" -#include - using namespace SALOMESDS; BasicDataServer::BasicDataServer(DataScopeServerBase *father, const std::string& varName):_father(father),_var_name(varName) diff --git a/src/TestMPIContainer/TestMPIContainer.cxx b/src/TestMPIContainer/TestMPIContainer.cxx index 6a5ad8aaf..183a72eec 100644 --- a/src/TestMPIContainer/TestMPIContainer.cxx +++ b/src/TestMPIContainer/TestMPIContainer.cxx @@ -71,7 +71,11 @@ int main (int argc, char * argv[]) containerName += hostName + "/MPIFactoryServer_" + argv[2]; std::string dirn(getenv("KERNEL_ROOT_DIR")); +#ifdef __APPLE__ + dirn += "/lib/salome/libSalomeTestMPIComponentEngine.dylib"; +#else dirn += "/lib/salome/libSalomeTestMPIComponentEngine.so"; +#endif // Try to resolve MPI Container obj = NS.Resolve(containerName.c_str()) ;