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']
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
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":
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)
#
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
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")
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;
}
#ifndef WIN32
#define LIB "lib"
+#ifdef __APPLE__
+#define ENGINESO "Engine.dylib"
+#else
#define ENGINESO "Engine.so"
+#endif
#else
#define LIB ""
#define ENGINESO "Engine.dll"
{
//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";
# ---- create hypotheses
-if sys.platform == "win32":
- stdMeshersEngine = "StdMeshersEngine"
-else:
- stdMeshersEngine = "libStdMeshersEngine.so"
+stdMeshersEngine = "StdMeshersEngine"
print
print "--- Create hypotheses ..."
{
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();
{
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();
// --- 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))
//--- 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];
#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";
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
// 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
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
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
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
#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"
#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;
// 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);
// 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
}
// ============================================================================
// 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);
// 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
}
// ============================================================================
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);
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;
ret = pthread_mutex_unlock(&_incrementMutex); // release lock
return mypos;
}
-
#include <pthread.h>
#include <semaphore.h>
+#ifdef __APPLE__
+#include <dispatch/dispatch.h>
+#endif
#include "BaseTraceCollector.hxx"
#include "BasicsGenericDestructor.hxx"
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;
//
// 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)
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()) ;