]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Patch for MacOS (from SALOME forum)
authorvsr <vsr@opencascade.com>
Fri, 20 Jan 2017 12:35:03 +0000 (15:35 +0300)
committervsr <vsr@opencascade.com>
Fri, 20 Jan 2017 12:35:03 +0000 (15:35 +0300)
18 files changed:
bin/nameserver.py
bin/runSalome.py
bin/salomeContext.py
bin/server.py
bin/setenv.py
src/Container/Component_i.cxx
src/Container/Container_i.cxx
src/KERNEL_PY/salome_test.py
src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx
src/MPIContainer/MPIContainer_i.cxx
src/ParallelContainer/SALOME_ParallelComponent_i.cxx
src/ParallelContainer/SALOME_ParallelContainerProxy_i.cxx
src/ParallelContainer/SALOME_ParallelContainer_i.cxx
src/SALOMEDSClient/SALOMEDSClient_ClientFactory.cxx
src/SALOMELocalTrace/LocalTraceBufferPool.cxx
src/SALOMELocalTrace/LocalTraceBufferPool.hxx
src/SALOMESDS/SALOMESDS_BasicDataServer.cxx
src/TestMPIContainer/TestMPIContainer.cxx

index 726e1d4c9084fac1f8499c5493a6d445c5f1f5c1..f9d1a3a2c6609fc6dfd643360a2aabef71aaa409 100755 (executable)
@@ -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']
index 29ea4e3d1ea1ca5d49aedd6e488396a5f8907621..33886c27ff6a9717d13b00417071dabbdcffc5d8 100755 (executable)
@@ -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
index 71f3aea55ad0879e8e0035e4ce89dd1a6ffb7f8f..7c034fd9b6530b20b8a7b8c27a4a13411438b66e 100644 (file)
@@ -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)
   #
index 432a6c6adcd7e4de0bde40cb48b5ae2a76a5e872..75b6b16e011967c10ce6a6d2410774834559de30 100755 (executable)
@@ -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
index b8eb466f8137327c7c2901b5d7b6fd1e141fc2a2..693a51feb09365dfcd52bab439c2f341c3846b62 100755 (executable)
@@ -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")
index 8a84c67d14f95a59ad0f30b83fef99af8c111d3a..311b5f7d8d282c67d729fee02288a586d79026a8 100644 (file)
@@ -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;
 }
 
index a7eb1197d0366006cc26ca5c43242c0f14224c08..b681a0124fcf7595b4e1eadab09e5016772a86c7 100644 (file)
@@ -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";
 
index c70a0f5b357c13f84ed945b5c9c7a059c33bc1e7..e0bdd983fa127d62530e3c0bf15b5bdab8894474 100755 (executable)
@@ -184,10 +184,7 @@ else:
 
 # ---- create hypotheses 
 
-if sys.platform == "win32":
-  stdMeshersEngine = "StdMeshersEngine"
-else:
-  stdMeshersEngine = "libStdMeshersEngine.so"
+stdMeshersEngine = "StdMeshersEngine"
 
 print
 print "--- Create hypotheses ..."
index 9d7a5db9e3fa8cf0ac00c0619dbc96e7d04e64af..8f4c19fe5380d21c015da32602828c2c7e5e3f45 100644 (file)
@@ -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();
index ed1c745a5ab9d0c945d5663c387913e0322ebe44..ddda604a465bacadb00a44df7fbf701941e9b5eb 100644 (file)
@@ -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];
index fd75687f98c4b4457c6eba9bb3a2146929eb28b9..f5fb351fcfec955efc3ec92e4b48b487e0390cbd 100644 (file)
@@ -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";
index c337776e2842af9404d92f0d0bede5b86240bc5a..25267d785900ccbea38f0679002e48456c3ffc60 100644 (file)
@@ -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
index 263b8531c582bf87cc4bc155c005f8b24ccd0e6d..14a6129349da0061d327af399049a825514c9e4f 100644 (file)
@@ -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
index bfada64186f7bcdb28ec8057b11751b845159d66..f1571a2abc4be198408adf86b01d99594a912d8b 100644 (file)
@@ -29,8 +29,12 @@ static HMODULE _libHandle = 0;
 #else
 #include <dlfcn.h>
 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"
index e346706cfa8d00b34fe53b7a4b00243cf5ab86e0..6a5a962ac89e2a552542d56df7f6130adcdba20a 100644 (file)
@@ -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<TRACE_BUFFER_SIZE; i++)
     strcpy(&(_myBuffer[i].trace[MAXMESS_LENGTH]),TRUNCATED_MESSAGE);
   int ret;
+#ifdef __APPLE__
+  dispatch_semaphore_t* sem1 = &_freeBufferSemaphore, *sem2 = &_fullBufferSemaphore;
+  *sem1 = dispatch_semaphore_create(TRACE_BUFFER_SIZE);
+  *sem2 = dispatch_semaphore_create(0);
+#else
   ret=sem_init(&_freeBufferSemaphore, 0, TRACE_BUFFER_SIZE); // all buffer free
   if (ret!=0) IMMEDIATE_ABORT(ret);
   ret=sem_init(&_fullBufferSemaphore, 0, 0);                 // 0 buffer full
   if (ret!=0) IMMEDIATE_ABORT(ret);
+#endif
   ret=pthread_mutex_init(&_incrementMutex,NULL); // default = fast mutex
   if (ret!=0) IMMEDIATE_ABORT(ret);
 
@@ -307,8 +339,13 @@ LocalTraceBufferPool::~LocalTraceBufferPool()
       delete (_myThreadTrace);
       _myThreadTrace = 0;
       int ret;
+#ifdef __APPLE__
+      dispatch_release(_freeBufferSemaphore);
+      dispatch_release(_fullBufferSemaphore);
+#else
       ret=sem_destroy(&_freeBufferSemaphore);
       ret=sem_destroy(&_fullBufferSemaphore);
+#endif
       ret=pthread_mutex_destroy(&_incrementMutex);
       DEVTRACE("LocalTraceBufferPool::~LocalTraceBufferPool()-end");
       _singleton = 0;
@@ -330,4 +367,3 @@ unsigned long LocalTraceBufferPool::lockedIncrement(unsigned long& pos)
   ret = pthread_mutex_unlock(&_incrementMutex); // release lock
   return mypos;
 }
-
index f22c58fb5c5800abfe688695557fe4dbaa266296..d90d45ee0bc7af34121c13e6331556e9ffc2c115 100644 (file)
@@ -35,6 +35,9 @@
 
 #include <pthread.h>
 #include <semaphore.h>
+#ifdef __APPLE__
+#include <dispatch/dispatch.h>
+#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;
index 8e329e5b65f639d7da6acce015053d7aef263a6e..b46d5ae53303195ccd75bb76048ca2183aa3a167 100644 (file)
 //
 // Author : Anthony GEAY (EDF R&D)
 
+#include <sstream>
 #include "SALOMESDS_BasicDataServer.hxx"
 #include "SALOMESDS_DataScopeServer.hxx"
 #include "SALOMESDS_Exception.hxx"
 
-#include <sstream>
-
 using namespace SALOMESDS;
 
 BasicDataServer::BasicDataServer(DataScopeServerBase *father, const std::string& varName):_father(father),_var_name(varName)
index 6a5ad8aaf0ff596cb77e5dbd09b602f6232086e2..183a72eeccfc5506b510dabb6290770513df8790 100644 (file)
@@ -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()) ;