From eada90a2ace824b692dca60b4d2633d5932d2462 Mon Sep 17 00:00:00 2001 From: rnv Date: Wed, 29 Aug 2018 14:24:36 +0300 Subject: [PATCH] SALOME 9.1.0 Windows version --- src/Basics/Basics_Utils.hxx | 8 +-- src/Communication_SWIG/CMakeLists.txt | 7 ++- src/DSC/DSC_Python/CMakeLists.txt | 7 ++- src/Launcher/Launcher_Job.cxx | 5 ++ src/Launcher/Launcher_Job_Command.cxx | 5 ++ src/Launcher/Launcher_Job_SALOME.cxx | 5 ++ src/LifeCycleCORBA_SWIG/CMakeLists.txt | 7 ++- src/NOTIFICATION_SWIG/CMakeLists.txt | 10 +++- src/Notification/NOTIFICATION.cxx | 7 ++- src/SALOMEDS/SALOMEDS_Study.cxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx | 4 ++ src/SALOMELocalTrace/utilities.h | 2 + .../TraceCollector_WaitForServerReadiness.cxx | 3 +- src/Utils/Utils_ExceptHandlers.cxx | 53 +++++++++++++++++-- 14 files changed, 109 insertions(+), 16 deletions(-) diff --git a/src/Basics/Basics_Utils.hxx b/src/Basics/Basics_Utils.hxx index 3468d205e..f4a90c69e 100644 --- a/src/Basics/Basics_Utils.hxx +++ b/src/Basics/Basics_Utils.hxx @@ -56,10 +56,10 @@ namespace Kernel_Utils ObjectdID //!< Global usage object identifier ID }; - const wchar_t* decode(const char* encoded); - const wchar_t* decode_s(std::string encoded); - const char* encode(const wchar_t* decoded); - std::string encode_s(const wchar_t* decoded); + BASICS_EXPORT const wchar_t* decode(const char* encoded); + BASICS_EXPORT const wchar_t* decode_s(std::string encoded); + BASICS_EXPORT const char* encode(const wchar_t* decoded); + BASICS_EXPORT std::string encode_s(const wchar_t* decoded); //! Get predefined GUID BASICS_EXPORT std::string GetGUID( GUIDtype ); diff --git a/src/Communication_SWIG/CMakeLists.txt b/src/Communication_SWIG/CMakeLists.txt index 9396baf81..745048574 100755 --- a/src/Communication_SWIG/CMakeLists.txt +++ b/src/Communication_SWIG/CMakeLists.txt @@ -49,8 +49,11 @@ IF(SALOME_USE_MPI) ${MPI_CXX_LIBRARIES} ) ENDIF(SALOME_USE_MPI) - -SWIG_ADD_MODULE(libSALOME_Comm python libSALOME_Comm.i) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(libSALOME_Comm python libSALOME_Comm.i) +ELSE() + SWIG_ADD_LIBRARY(libSALOME_Comm LANGUAGE python SOURCES libSALOME_Comm.i) +ENDIF() SWIG_LINK_LIBRARIES(libSALOME_Comm ${_libSALOME_Comm_LIBS}) IF(${MACHINE} STREQUAL WINDOWS) diff --git a/src/DSC/DSC_Python/CMakeLists.txt b/src/DSC/DSC_Python/CMakeLists.txt index eb5369a43..5a10adea1 100755 --- a/src/DSC/DSC_Python/CMakeLists.txt +++ b/src/DSC/DSC_Python/CMakeLists.txt @@ -59,7 +59,12 @@ SET(_calcium_LIBS ${OMNIORB_LIBRARIES} ) -SWIG_ADD_MODULE(calcium python calcium.i) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(calcium python calcium.i) +ELSE() + SWIG_ADD_LIBRARY(calcium LANGUAGE python SOURCES calcium.i) +ENDIF() + SWIG_LINK_LIBRARIES(calcium ${_calcium_LIBS}) INSTALL(TARGETS _calcium DESTINATION ${SALOME_INSTALL_PYTHON}) diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index cbe54ef97..ac015eb7f 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -31,6 +31,7 @@ #include #ifdef WIN32 static const char SEPARATOR = '\\'; +#include #else static const char SEPARATOR = '/'; #endif @@ -631,7 +632,11 @@ Launcher::Job::common_job_params() { std::string date_dir = std::string("/job_") + date; std::ostringstream str_pid; +#ifdef WIN32 + str_pid << _getpid(); +#else str_pid << ::getpid(); +#endif std::string job_dir = date_dir + "-" + str_pid.str(); _work_directory = _resource_definition.working_directory + job_dir; diff --git a/src/Launcher/Launcher_Job_Command.cxx b/src/Launcher/Launcher_Job_Command.cxx index b71d73735..88da9cd6b 100644 --- a/src/Launcher/Launcher_Job_Command.cxx +++ b/src/Launcher/Launcher_Job_Command.cxx @@ -29,6 +29,7 @@ #ifdef WIN32 #include #define _chmod chmod +#include #endif #include @@ -62,7 +63,11 @@ Launcher::Job_Command::buildCommandScript(Batch::Parametre params, std::string l // File name std::string launch_date_port_file = launch_date; std::ostringstream str_pid; +#ifdef WIN32 + str_pid << _getpid(); +#else str_pid << ::getpid(); +#endif std::string launch_script = Kernel_Utils::GetTmpDir() + "runCommand_" + _job_file_name + "_" + launch_date + "-" + str_pid.str(); diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 17e7e1766..4bcb39772 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -29,6 +29,7 @@ #ifdef WIN32 #include #define _chmod chmod +#include #endif #include @@ -66,7 +67,11 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) // parameters std::string work_directory = params[Batch::WORKDIR].str(); std::ostringstream str_pid; +#ifdef WIN32 + str_pid << _getpid(); +#else str_pid << ::getpid(); +#endif std::string launch_script = Kernel_Utils::GetTmpDir() + "runSalome_" + _job_file_name + "_" + _launch_date + "-" + str_pid.str() + ".sh"; std::ofstream launch_script_stream; launch_script_stream.open(launch_script.c_str(), diff --git a/src/LifeCycleCORBA_SWIG/CMakeLists.txt b/src/LifeCycleCORBA_SWIG/CMakeLists.txt index 4a8decb55..96233ea18 100755 --- a/src/LifeCycleCORBA_SWIG/CMakeLists.txt +++ b/src/LifeCycleCORBA_SWIG/CMakeLists.txt @@ -39,7 +39,12 @@ INCLUDE_DIRECTORIES( ${PROJECT_BINARY_DIR}/idl ) -SWIG_ADD_MODULE(libSALOME_LifeCycleCORBA python libSALOME_LifeCycleCORBA.i) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(libSALOME_LifeCycleCORBA python libSALOME_LifeCycleCORBA.i) +ELSE() + SWIG_ADD_LIBRARY(libSALOME_LifeCycleCORBA LANGUAGE python SOURCES libSALOME_LifeCycleCORBA.i) +ENDIF() + SWIG_LINK_LIBRARIES(libSALOME_LifeCycleCORBA ${PYTHON_LIBRARIES} SalomeLifeCycleCORBA) TARGET_LINK_LIBRARIES(_libSALOME_LifeCycleCORBA ${PLATFORM_LIBS}) diff --git a/src/NOTIFICATION_SWIG/CMakeLists.txt b/src/NOTIFICATION_SWIG/CMakeLists.txt index d041a89a6..209d8a702 100755 --- a/src/NOTIFICATION_SWIG/CMakeLists.txt +++ b/src/NOTIFICATION_SWIG/CMakeLists.txt @@ -24,7 +24,7 @@ SET_SOURCE_FILES_PROPERTIES(NOTIFICATION.i PROPERTIES SWIG_FLAGS "-py3") SET_SOURCE_FILES_PROPERTIES(NOTIFICATIONPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS} -DHAVE_CONFIG_H") INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} + ${PYTHON_INCLUDE_DIRS} ${PTHREAD_INCLUDE_DIR} ${OMNIORB_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} @@ -37,7 +37,13 @@ INCLUDE_DIRECTORIES( # SWIG module name differs from file name - avoid unnecessary rebuild: SET_SOURCE_FILES_PROPERTIES(NOTIFICATION.i PROPERTIES SWIG_MODULE_NAME libNOTIFICATION) -SWIG_ADD_MODULE(libNOTIFICATION python NOTIFICATION.i NOTIFICATION_Swig.cxx) +IF(${CMAKE_VERSION} VERSION_LESS "3.8.0") + SWIG_ADD_MODULE(libNOTIFICATION python NOTIFICATION.i NOTIFICATION_Swig.cxx) +ELSE() + SWIG_ADD_LIBRARY(libNOTIFICATION LANGUAGE python SOURCES NOTIFICATION.i NOTIFICATION_Swig.cxx) +ENDIF() + + SWIG_LINK_LIBRARIES(libNOTIFICATION ${PYTHON_LIBRARIES} SalomeNotification) ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) diff --git a/src/Notification/NOTIFICATION.cxx b/src/Notification/NOTIFICATION.cxx index 00ce49298..5a50f9acf 100644 --- a/src/Notification/NOTIFICATION.cxx +++ b/src/Notification/NOTIFICATION.cxx @@ -88,11 +88,16 @@ static char Mois[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug static char NOTIFICATION_DATE[50]; char* NOTIFICATION_date() { +#ifndef WIN32 time_t aTime; time(&aTime); struct tm* temps = localtime(&aTime); sprintf(NOTIFICATION_DATE, "%4d %3d %3s %2d %3s %02d:%02d:%02d", 1900+temps->tm_year, temps->tm_mon+1, Mois[temps->tm_mon], temps->tm_mday, JourSemaine[temps->tm_wday], temps->tm_hour, temps->tm_min, temps->tm_sec); - +#else + SYSTEMTIME st; + GetLocalTime(&st); + sprintf(NOTIFICATION_DATE, "%4d %3d %3s %2d %3s %02d:%02d:%02d", st.wYear, st.wMonth, Mois[st.wMonth-1], st.wDay, JourSemaine[st.wDay], st.wHour, st.wMinute, st.wSecond); +#endif return(NOTIFICATION_DATE); } diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index f7ea3dc15..337fe6c51 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -86,7 +86,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) pthread_mutex_init( &SALOMEDS_StudyBuilder::_remoteBuilderMutex, 0 ); - long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); + CORBA::LongLong addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal); if(_isLocal) { _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::Study::_duplicate(theStudy); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx index 16cbbaf57..9a5812849 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx @@ -35,6 +35,10 @@ #include #include "DF_Label.hxx" +#ifdef WIN32 +# undef GetUserName +#endif + class SALOMEDSIMPL_EXPORT SALOMEDSImpl_Tool { diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index e2d34fd4f..221034e6f 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -90,6 +90,8 @@ #define COMPILER "pgCC" #elif defined ( __alpha ) #define COMPILER "cxx" +#elif defined ( _MSC_VER ) +#define COMPILER "cl.exe" #else #define COMPILER "undefined" #endif diff --git a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx index d1aa74dee..a3261bc83 100644 --- a/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx +++ b/src/SALOMETraceCollector/TraceCollector_WaitForServerReadiness.cxx @@ -29,7 +29,8 @@ #include #include -#ifdef WIN32 + +#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1900 #include #endif diff --git a/src/Utils/Utils_ExceptHandlers.cxx b/src/Utils/Utils_ExceptHandlers.cxx index 1e96fd0fe..34d29e13c 100644 --- a/src/Utils/Utils_ExceptHandlers.cxx +++ b/src/Utils/Utils_ExceptHandlers.cxx @@ -30,15 +30,52 @@ #include "Utils_SALOME_Exception.hxx" #include +#ifdef WIN32 +#include "DbgHelp.h" +#include +#pragma comment(lib, "Dbghelp.lib") +#else #include #include #include +#endif #include #include CORBA_SERVER_HEADER(SALOME_Exception) //#define NBLINES_BACKTRACE 64 +#ifdef WIN32 +void printBacktrace(std::stringstream& txt) +{ + typedef USHORT(WINAPI *CaptureStackBackTraceType)(__in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG); + CaptureStackBackTraceType func = (CaptureStackBackTraceType)(GetProcAddress(LoadLibrary("kernel32.dll"), "RtlCaptureStackBackTrace")); + + if (func == NULL) + return; + const int kMaxCallers = 128; + + void * callers_stack[kMaxCallers]; + unsigned short frames; + SYMBOL_INFO * symbol; + HANDLE process; + process = GetCurrentProcess(); + SymInitialize(process, NULL, TRUE); + frames = (func)(0, kMaxCallers, callers_stack, NULL); + symbol = (SYMBOL_INFO *)calloc(sizeof(SYMBOL_INFO) + 256 * sizeof(char), 1); + symbol->MaxNameLen = 255; + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + const unsigned short MAX_CALLERS_SHOWN = 64; + frames = frames < MAX_CALLERS_SHOWN ? frames : MAX_CALLERS_SHOWN; + for (unsigned int i = 0; i < frames; i++) + { + SymFromAddr(process, (DWORD64)(callers_stack[i]), 0, symbol); + txt << "*** " << i << ": " << callers_stack[i] << " " << symbol->Name << " - 0x" << symbol->Address << std::endl; + } + + free(symbol); +} +#else void printBacktrace(void **stacklines, int nbLines, std::stringstream& txt) { char **stackSymbols = backtrace_symbols(stacklines, nbLines); @@ -74,26 +111,36 @@ void printBacktrace(void **stacklines, int nbLines, std::stringstream& txt) } free(stackSymbols); } +#endif void SalomeException () { + std::stringstream txt; + txt << "Salome Exception" << std::endl; +#ifdef WIN32 + printBacktrace(txt); +#else void *stacklines[64]; size_t nbLines; nbLines = backtrace(stacklines, 64); - std::stringstream txt; - txt << "Salome Exception" << std::endl; printBacktrace(stacklines, nbLines, txt); +#endif throw SALOME_Exception(txt.str().c_str()); } void SALOME_SalomeException() { + std::stringstream txt; +#ifdef WIN32 + txt << "INTERNAL_ERROR, backtrace stack:" << std::endl; + printBacktrace(txt); +#else void *stacklines[64]; size_t nbLines; nbLines = backtrace(stacklines, 64); - std::stringstream txt; txt << "INTERNAL_ERROR, backtrace stack:" << nbLines << std::endl; printBacktrace(stacklines, nbLines, txt); +#endif THROW_SALOME_CORBA_EXCEPTION(txt.str().c_str(), SALOME::INTERNAL_ERROR); } -- 2.39.2