From: barate Date: Fri, 24 Apr 2009 13:41:03 +0000 (+0000) Subject: Fixed errors in CMake FindXXX modules. Fixed Windows compilation errors. X-Git-Tag: V_1_0_0_RC2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fefa8959782a9110475f391d4ced86554a78a508;p=tools%2Flibbatch.git Fixed errors in CMake FindXXX modules. Fixed Windows compilation errors. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fa11d8..25f4908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,6 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules/) ENABLE_TESTING() -find_package (PLATFORM) find_package (Threads) IF (NOT CMAKE_USE_PTHREADS_INIT) MESSAGE(FATAL_ERROR "Mandatory library pthread not found") diff --git a/CMakeModules/FindLSF.cmake b/CMakeModules/FindLSF.cmake index 1c673f4..b303c69 100644 --- a/CMakeModules/FindLSF.cmake +++ b/CMakeModules/FindLSF.cmake @@ -28,7 +28,9 @@ FIND_PATH(LSF_INCLUDE_DIR lsf/lsbatch.h) FIND_LIBRARY(LSF_LIBRARY lsf) FIND_LIBRARY(LSF_BAT_LIBRARY bat) -SET(LSF_FOUND ${LSF_INCLUDE_DIR} AND ${LSF_LIBRARY} AND ${LSF_BAT_LIBRARY}) +IF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) + SET(LSF_FOUND True) +ENDIF (LSF_INCLUDE_DIR AND LSF_LIBRARY AND LSF_BAT_LIBRARY) IF (LSF_FOUND) diff --git a/CMakeModules/FindPBS.cmake b/CMakeModules/FindPBS.cmake index 9fc9455..e5a7cf8 100644 --- a/CMakeModules/FindPBS.cmake +++ b/CMakeModules/FindPBS.cmake @@ -20,9 +20,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -INCLUDE (CheckIncludeFile) -INCLUDE (CheckLibraryExists) - IF (NOT PBS_FIND_QUIETLY) MESSAGE(STATUS "Looking for PBS...") ENDIF (NOT PBS_FIND_QUIETLY) @@ -30,7 +27,9 @@ ENDIF (NOT PBS_FIND_QUIETLY) FIND_PATH(PBS_INCLUDE_DIR pbs_ifl.h) FIND_LIBRARY(PBS_LIBRARY pbs) -SET(PBS_FOUND ${PBS_INCLUDE_DIR} AND ${PBS_LIBRARY}) +IF (PBS_INCLUDE_DIR AND PBS_LIBRARY) + SET(PBS_FOUND True) +ENDIF (PBS_INCLUDE_DIR AND PBS_LIBRARY) IF (PBS_FOUND) diff --git a/CMakeModules/FindPLATFORM.cmake b/CMakeModules/FindPLATFORM.cmake deleted file mode 100644 index 28fd288..0000000 --- a/CMakeModules/FindPLATFORM.cmake +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -MARK_AS_ADVANCED(ISSUE) -FIND_FILE(ISSUE issue /etc) -IF(ISSUE) - SET(WINDOWS 0) -ELSE() - SET(WINDOWS 1) -ENDIF(ISSUE) - -IF(WINDOWS) - SET(MACHINE WINDOWS) - SET(PLATFORM_CPPFLAGS) - SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT) - SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DPPRO_NT) - SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} /W0) - # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT -D_CRT_SECURE_NO_WARNINGS) - # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_WIN32_WINNT=0x0500) - # SET(RM del) -ELSE(WINDOWS) - SET(MACHINE PCLINUX) - SET(PLATFORM_CPPFLAGS) - # SET(RM /bin/rm) -ENDIF(WINDOWS) - -IF(WINDOWS) - SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - MARK_AS_ADVANCED(CLEAR CMAKE_CONFIGURATION_TYPES) - SET(CMAKE_CONFIGURATION_TYPES Release CACHE STRING "compilation types" FORCE) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ENDIF(WINDOWS) - -IF(WINDOWS) - SET(CMAKE_INSTALL_PREFIX_ENV $ENV{CMAKE_INSTALL_PREFIX}) - IF(CMAKE_INSTALL_PREFIX_ENV) - SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX_ENV} CACHE PATH "installation prefix" FORCE) - ENDIF(CMAKE_INSTALL_PREFIX_ENV) -ENDIF(WINDOWS) - -## SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_) - -#SET(RCP rcp) -#SET(RSH rsh) -#SET(RCP rcp) diff --git a/CMakeModules/FindPython.cmake b/CMakeModules/FindPython.cmake index 94eb648..78996b1 100644 --- a/CMakeModules/FindPython.cmake +++ b/CMakeModules/FindPython.cmake @@ -27,51 +27,53 @@ IF (NOT Python_FIND_QUIETLY) MESSAGE(STATUS "Looking for Python...") ENDIF (NOT Python_FIND_QUIETLY) -IF(WINDOWS) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_PROGRAM(PYTHON_EXECUTABLE python) - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_PROGRAM(PYTHON_EXECUTABLE python_d) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ELSE(WINDOWS) - FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter") -ENDIF(WINDOWS) - -EXECUTE_PROCESS( - COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" - OUTPUT_VARIABLE PYTHON_VERSION +IF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release) + FIND_PROGRAM(PYTHON_DEBUG python_d) + mark_as_advanced(PYTHON_DEBUG) +ENDIF(WIN32 AND NOT CMAKE_BUILD_TYPE STREQUAL Release) + +IF (PYTHON_DEBUG) + SET(PYTHON_EXECUTABLE ${PYTHON_DEBUG} CACHE STRING "Python interpreter") +ELSE (PYTHON_DEBUG) + FIND_PROGRAM(PYTHON_EXECUTABLE python DOC "Python interpreter") +ENDIF (PYTHON_DEBUG) + +IF (PYTHON_EXECUTABLE) + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" + OUTPUT_VARIABLE PYTHON_VERSION ) -SET(PYTHON_ROOT ${PYTHON_EXECUTABLE}) -GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) -GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) - -FIND_PATH(PYTHON_INCLUDE_PATH Python.h - PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python${PYTHON_VERSION} - DOC "Python include path") - -IF(WINDOWS) - STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION}) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT} ${PYTHON_ROOT}/libs DOC "Python libraries") - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs DOC "Python libraries") - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ELSE(WINDOWS) - FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib DOC "Python libraries") -ENDIF(WINDOWS) - -SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH}) -SET(PYTHON_LIBS ${PYTHON_LIBRARIES}) - -IF(WINDOWS) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ENDIF(WINDOWS) - -SET(Python_FOUND ${PYTHON_EXECUTABLE} AND ${PYTHON_LIBRARIES} AND ${PYTHON_INCLUDE_PATH}) + SET(PYTHON_ROOT ${PYTHON_EXECUTABLE}) + GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) + GET_FILENAME_COMPONENT(PYTHON_ROOT ${PYTHON_ROOT} PATH) + + FIND_PATH(PYTHON_INCLUDE_PATH Python.h + PATHS ${PYTHON_ROOT}/include ${PYTHON_ROOT}/include/python${PYTHON_VERSION} + DOC "Python include path") + + IF(WIN32) + STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION}) + IF(PYTHON_DEBUG) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs DOC "Python libraries") + ELSE(PYTHON_DEBUG) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT} ${PYTHON_ROOT}/libs DOC "Python libraries") + ENDIF(PYTHON_DEBUG) + ELSE(WIN32) + FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib DOC "Python libraries") + ENDIF(WIN32) + + SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_PATH}) + SET(PYTHON_LIBS ${PYTHON_LIBRARIES}) + + IF(PYTHON_DEBUG) + SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -DHAVE_DEBUG_PYTHON) + ENDIF(PYTHON_DEBUG) +ENDIF (PYTHON_EXECUTABLE) + +IF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH) + SET(Python_FOUND True) +ENDIF(PYTHON_EXECUTABLE AND PYTHON_LIBRARIES AND PYTHON_INCLUDE_PATH) IF (Python_FOUND) diff --git a/CMakeModules/Summary.cmake b/CMakeModules/Summary.cmake index ed5e764..bf71bc5 100644 --- a/CMakeModules/Summary.cmake +++ b/CMakeModules/Summary.cmake @@ -20,51 +20,51 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -MESSAGE("") -MESSAGE("**************** Summary ****************") -MESSAGE("") +MESSAGE(STATUS "") +MESSAGE(STATUS "**************** Summary ****************") +MESSAGE(STATUS "") IF (BUILD_LSF_INTERFACE) IF (LSF_FOUND) - MESSAGE("LSF ................................. Yes") + MESSAGE(STATUS "LSF ................................. Yes") ELSE (LSF_FOUND) - MESSAGE("LSF ........................... Not found") + MESSAGE(STATUS "LSF ........................... Not found") ENDIF (LSF_FOUND) ELSE (BUILD_LSF_INTERFACE) - MESSAGE("LSF ....................... Not requested") + MESSAGE(STATUS "LSF ....................... Not requested") ENDIF (BUILD_LSF_INTERFACE) IF (BUILD_PBS_INTERFACE) IF (PBS_FOUND) - MESSAGE("PBS ................................. Yes") + MESSAGE(STATUS "PBS ................................. Yes") ELSE (PBS_FOUND) - MESSAGE("PBS ........................... Not found") + MESSAGE(STATUS "PBS ........................... Not found") ENDIF (PBS_FOUND) ELSE (BUILD_PBS_INTERFACE) - MESSAGE("PBS ....................... Not requested") + MESSAGE(STATUS "PBS ....................... Not requested") ENDIF (BUILD_PBS_INTERFACE) IF (BUILD_LOCAL_SUBMISSION) - MESSAGE("Local submission .................... Yes") + MESSAGE(STATUS "Local submission .................... Yes") ELSE (BUILD_LOCAL_SUBMISSION) - MESSAGE("Local submission .......... Not requested") + MESSAGE(STATUS "Local submission .......... Not requested") ENDIF (BUILD_LOCAL_SUBMISSION) IF (BUILD_PYTHON_WRAPPING) - IF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) - MESSAGE("Python wrapping ..................... Yes") - ELSE (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) - MESSAGE("Python wrapping ............... Not found") - ENDIF (PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) + IF (Python_FOUND AND SWIG_FOUND) + MESSAGE(STATUS "Python wrapping ..................... Yes") + ELSE (Python_FOUND AND SWIG_FOUND) + MESSAGE(STATUS "Python wrapping ............... Not found") + ENDIF (Python_FOUND AND SWIG_FOUND) ELSE (BUILD_PYTHON_WRAPPING) - MESSAGE("Python wrapping ........... Not requested") + MESSAGE(STATUS "Python wrapping ........... Not requested") ENDIF (BUILD_PYTHON_WRAPPING) IF (Makeinfo_FOUND) - MESSAGE("Makeinfo ............................ Yes") + MESSAGE(STATUS "Makeinfo ............................ Yes") ELSE (Makeinfo_FOUND) - MESSAGE("Makeinfo ...................... Not found") + MESSAGE(STATUS "Makeinfo ...................... Not found") ENDIF (Makeinfo_FOUND) -MESSAGE("") -MESSAGE("************** End Summary **************") -MESSAGE("") +MESSAGE(STATUS "") +MESSAGE(STATUS "************** End Summary **************") +MESSAGE(STATUS "") diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 5a5e3ab..880821d 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -23,7 +23,7 @@ SET (TEXI_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Batch.texi) ADD_CUSTOM_TARGET(doc ALL - ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE} + ${MAKEINFO_EXECUTABLE} --html ${TEXI_FILE} -I ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${TEXI_FILE} ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b91a7e8..fae507a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -58,7 +58,6 @@ SET(HDR_FILES ${HDR_FILES_BUILD} CACHE INTERNAL "") SET(HDR_FILES_BUILD CACHE INTERNAL "") - add_library (Batch SHARED ${SRC_FILES}) include_directories(${CMAKE_BINARY_DIR}) @@ -66,6 +65,10 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Core) target_link_libraries(Batch ${CMAKE_THREAD_LIBS_INIT}) +IF (WIN32) + target_link_libraries(Batch ws2_32) +ENDIF (WIN32) + # If necessary, activate all warnings (useful for debugging and code cleaning) # add_definitions(-Wall -Werror -ansi -pedantic) @@ -82,6 +85,6 @@ ENDIF (BUILD_PBS_INTERFACE AND PBS_FOUND) INSTALL(TARGETS Batch DESTINATION lib) INSTALL(FILES ${HDR_FILES} DESTINATION include/Batch) -IF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) +IF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND) add_subdirectory (Python) -ENDIF (BUILD_PYTHON_WRAPPING AND PYTHON_INCLUDE_PATH AND PYTHON_LIBRARIES AND SWIG_FOUND) +ENDIF (BUILD_PYTHON_WRAPPING AND Python_FOUND AND SWIG_FOUND) diff --git a/src/Core/Batch_BatchManager.cxx b/src/Core/Batch_BatchManager.cxx index d4744af..a7e6d61 100644 --- a/src/Core/Batch_BatchManager.cxx +++ b/src/Core/Batch_BatchManager.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * BatchManager.cxx : + * BatchManager.cxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Date : Septembre 2003 @@ -61,8 +61,19 @@ namespace Batch { // } BatchManager::BatchManager(const FactBatchManager * parent, const char * host) throw(InvalidArgumentException) : _hostname(host), jobid_map(), _parent(parent) { +#ifdef WIN32 + WSADATA wsaData; + WSAStartup(MAKEWORD(2, 2), &wsaData); // Initialize Winsock +#endif + // On verifie que le hostname est correct - if (!gethostbyname(_hostname.c_str())) { // hostname unknown from network + struct hostent* res = gethostbyname(_hostname.c_str()); + +#ifdef WIN32 + WSACleanup(); // Finalize Winsock +#endif + + if (!res) { // hostname unknown from network string msg = "hostname \""; msg += _hostname; msg += "\" unknown from the network"; @@ -109,7 +120,7 @@ namespace Batch { // { // // Nothing to do // } - + // // Methode pour le controle des jobs : suspend un job en file d'attente // void BatchManager::holdJob(const JobId & jobid) // { diff --git a/src/Core/Batch_BatchManagerCatalog.hxx b/src/Core/Batch_BatchManagerCatalog.hxx index f171419..baa92ce 100644 --- a/src/Core/Batch_BatchManagerCatalog.hxx +++ b/src/Core/Batch_BatchManagerCatalog.hxx @@ -66,7 +66,7 @@ namespace Batch { // Forbid the use of copy constructor and assignment operator BatchManagerCatalog(const BatchManagerCatalog & orig) {} - BatchManagerCatalog& operator=(const BatchManagerCatalog & orig) {} + BatchManagerCatalog& operator=(const BatchManagerCatalog & orig) { return *this; } }; diff --git a/src/Core/Batch_Couple.hxx b/src/Core/Batch_Couple.hxx index a6ce2d9..ee38dff 100644 --- a/src/Core/Batch_Couple.hxx +++ b/src/Core/Batch_Couple.hxx @@ -51,7 +51,7 @@ namespace Batch { virtual ~Couple() {} // Operateur pour l'affichage sur un stream - friend std::ostream & operator << (std::ostream & os, const Couple & cp); + BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Couple & cp); // Operateur d'affectation virtual Couple & operator =(const Couple &); diff --git a/src/Core/Batch_Defines.hxx b/src/Core/Batch_Defines.hxx index 84548ad..ab2a237 100644 --- a/src/Core/Batch_Defines.hxx +++ b/src/Core/Batch_Defines.hxx @@ -27,14 +27,11 @@ #define _BATCH_Defines_HXX_ #ifdef WIN32 -# if defined BATCH_EXPORTS || defined SalomeBatch_EXPORTS +# if defined Batch_EXPORTS # define BATCH_EXPORT __declspec( dllexport ) # else # define BATCH_EXPORT __declspec( dllimport ) # endif -# define RM "rm" -# define RCP "rpc" -# define RSH "rsh" #else # define BATCH_EXPORT #endif diff --git a/src/Core/Batch_GenericException.cxx b/src/Core/Batch_GenericException.cxx index 4303e1c..622c8e3 100644 --- a/src/Core/Batch_GenericException.cxx +++ b/src/Core/Batch_GenericException.cxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * GenericException.cxx : + * GenericException.cxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Mail : mailto:ivan.dutka-malen@der.edf.fr @@ -29,9 +29,17 @@ * */ +#include #include "Batch_GenericException.hxx" + using namespace std; namespace Batch { +// Operator for writing on a stream +ostream & operator <<(ostream & os, const GenericException & e) +{ + return os << e.type << ": " << e.message; +} + } diff --git a/src/Core/Batch_GenericException.hxx b/src/Core/Batch_GenericException.hxx index 7961c5c..e3bf0aa 100644 --- a/src/Core/Batch_GenericException.hxx +++ b/src/Core/Batch_GenericException.hxx @@ -50,6 +50,9 @@ namespace Batch { const std::string & ch = "undefined") : type(tp), message(ch) {} }; + // Operator for writing on a stream + BATCH_EXPORT std::ostream & operator <<(std::ostream & os, const GenericException & e); + } #endif diff --git a/src/Core/Batch_GenericType.hxx b/src/Core/Batch_GenericType.hxx index 613d1f5..ab8c649 100644 --- a/src/Core/Batch_GenericType.hxx +++ b/src/Core/Batch_GenericType.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * GenericType.hxx : + * GenericType.hxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Date : Septembre 2003 @@ -47,7 +47,7 @@ namespace Batch { virtual ~GenericType() { _nb--; } // Operateur pour l'affichage sur un stream - friend std::ostream & operator << (std::ostream & os, const GenericType & obj); + BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const GenericType & obj); // Conversion en chaine virtual std::string affiche() const; @@ -63,7 +63,7 @@ namespace Batch { private: static int _nb; // nombre total d'objets GenericType et al. - + }; } diff --git a/src/Core/Batch_Job.hxx b/src/Core/Batch_Job.hxx index 264fb8e..fc47216 100644 --- a/src/Core/Batch_Job.hxx +++ b/src/Core/Batch_Job.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * Job.hxx : + * Job.hxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Date : Septembre 2003 @@ -48,18 +48,18 @@ namespace Batch { Job(Batch::Environnement env); Job(Batch::Parametre param, Batch::Environnement env); virtual ~Job() {} - + // Operateur pour l'affichage sur un stream - friend std::ostream & operator <<(std::ostream & os, const Job & job); + BATCH_EXPORT friend std::ostream & operator <<(std::ostream & os, const Job & job); // Accesseurs Batch::Parametre getParametre() const; void setParametre(const Batch::Parametre &); - + // Accesseurs Batch::Environnement getEnvironnement() const; void setEnvironnement(const Batch::Environnement &); - + // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG std::string __str__() const; // SWIG : affichage en Python diff --git a/src/Core/Batch_JobInfo.hxx b/src/Core/Batch_JobInfo.hxx index f4b54f1..3f19954 100644 --- a/src/Core/Batch_JobInfo.hxx +++ b/src/Core/Batch_JobInfo.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * JobInfo.hxx : + * JobInfo.hxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Mail : mailto:ivan.dutka-malen@der.edf.fr @@ -52,13 +52,13 @@ namespace Batch { JobInfo(const JobInfo & jinfo) : _param(jinfo._param), _env(jinfo._env) {}; // Operateur pour l'affichage sur un stream - friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji); + BATCH_EXPORT friend std::ostream & operator <<(std::ostream & os, const JobInfo & ji); // Accesseurs // _CS_gbo Ajout explicite du namespace pour les besoins de swig (mauvaise gestion // des namespace par swig. virtual Batch::Parametre getParametre() const; - virtual Batch::Environnement getEnvironnement() const; + virtual Batch::Environnement getEnvironnement() const; // Methodes pour l'interfacage avec Python (SWIG) // TODO : supprimer ces methodes et transferer leur definitions dans SWIG diff --git a/src/Core/Batch_Parametre.cxx b/src/Core/Batch_Parametre.cxx index c8e13e6..bc17513 100644 --- a/src/Core/Batch_Parametre.cxx +++ b/src/Core/Batch_Parametre.cxx @@ -266,7 +266,7 @@ namespace Batch { } // Constructeur par recopie - Parametre::Parametre(const Parametre & PM) + Parametre::Parametre(const Parametre & PM) : map< string, Versatile >() { // inutile car l'objet est vierge : il vient d'etre cree // On efface toute la map diff --git a/src/Core/Batch_Versatile.hxx b/src/Core/Batch_Versatile.hxx index ec42d18..6a3a945 100644 --- a/src/Core/Batch_Versatile.hxx +++ b/src/Core/Batch_Versatile.hxx @@ -91,7 +91,7 @@ namespace Batch { std::string str() const throw(TypeMismatchException); // Operateur pour l'affichage sur un stream - friend std::ostream & operator << (std::ostream & os, const Versatile & ); + BATCH_EXPORT friend std::ostream & operator << (std::ostream & os, const Versatile & ); // Positionnement et recuperation du type de l'element interne void setType(DiscriminatorType) throw(TypeMismatchException); diff --git a/src/Local/Test/Test_Local_RSH.cxx b/src/Local/Test/Test_Local_RSH.cxx index 24c926b..5bd5c05 100644 --- a/src/Local/Test/Test_Local_RSH.cxx +++ b/src/Local/Test/Test_Local_RSH.cxx @@ -49,44 +49,56 @@ int main(int argc, char** argv) // eventually remove any previous result remove("result.txt"); - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p["EXECUTABLE"] = "./copied-test-script.sh"; - p["NAME"] = "Test_Local_RSH"; - p["WORKDIR"] = TEST_LOCAL_RSH_WORK_DIR; - p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); - p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); - p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); - p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); - p["EXECUTIONHOST"] = TEST_LOCAL_RSH_EXECUTION_HOST; - job.setParametre(p); - // ... and its environment - Environnement e; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type Local_RSH on localhost - FactBatchManager * fbm = c("RSH"); - BatchManager * bm = (*fbm)("localhost"); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = "Unknown"; - while (state != "Done") { - usleep(10000); - JobInfo jinfo = jobid.queryJob(); - state = jinfo.getParametre()["STATE"].str(); - } + try { + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_RSH"; + p["WORKDIR"] = TEST_LOCAL_RSH_WORK_DIR; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + p["EXECUTIONHOST"] = TEST_LOCAL_RSH_EXECUTION_HOST; + job.setParametre(p); + // ... and its environment + Environnement e; + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_RSH on localhost + FactBatchManager * fbm = c("RSH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + for (int i=0 ; i<100 && state != "Done" ; i++) { + usleep(100000); + Versatile paramState = jobid.queryJob().getParametre()["STATE"]; + state = (paramState.size() > 0) ? paramState.str() : "Unknown"; + cout << "Job state is: " << state << endl; + } - cout << "Job " << jobid.__repr__() << " is done" << endl; + if (state != "Done") { + cerr << "Error: Job not finished after timeout" << endl; + return 1; + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + } catch (GenericException e) { + cerr << "Error: " << e << endl; + return 1; + } // wait for 5 more seconds for the copy of output files and the cleanup // (there's no cleaner way to do that yet) diff --git a/src/Local/Test/Test_Local_SH.cxx b/src/Local/Test/Test_Local_SH.cxx index d11ea60..1df7923 100644 --- a/src/Local/Test/Test_Local_SH.cxx +++ b/src/Local/Test/Test_Local_SH.cxx @@ -49,43 +49,55 @@ int main(int argc, char** argv) // eventually remove any previous result remove("result.txt"); - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p["EXECUTABLE"] = "./copied-test-script.sh"; - p["NAME"] = "Test_Local_SH"; - p["WORKDIR"] = "/tmp"; - p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); - p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); - p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); - p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); - job.setParametre(p); - // ... and its environment - Environnement e; - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type Local_SH on localhost - FactBatchManager * fbm = c("SH"); - BatchManager * bm = (*fbm)("localhost"); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = "Unknown"; - while (state != "Done") { - usleep(10000); - JobInfo jinfo = jobid.queryJob(); - state = jinfo.getParametre()["STATE"].str(); - } + try { + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_SH"; + p["WORKDIR"] = "/tmp"; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + job.setParametre(p); + // ... and its environment + Environnement e; + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_SH on localhost + FactBatchManager * fbm = c("SH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + for (int i=0 ; i<10 && state != "Done" ; i++) { + usleep(100000); + Versatile paramState = jobid.queryJob().getParametre()["STATE"]; + state = (paramState.size() > 0) ? paramState.str() : "Unknown"; + cout << "Job state is: " << state << endl; + } - cout << "Job " << jobid.__repr__() << " is done" << endl; + if (state != "Done") { + cerr << "Error: Job not finished after timeout" << endl; + return 1; + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + } catch (GenericException e) { + cerr << "Error: " << e << endl; + return 1; + } // wait for 2 more seconds for the copy of output files and the cleanup // (there's no cleaner way to do that yet) diff --git a/src/Local/Test/Test_Local_SSH.cxx b/src/Local/Test/Test_Local_SSH.cxx index f946b43..0284204 100644 --- a/src/Local/Test/Test_Local_SSH.cxx +++ b/src/Local/Test/Test_Local_SSH.cxx @@ -49,45 +49,58 @@ int main(int argc, char** argv) // eventually remove any previous result remove("result.txt"); - // Define the job... - Job job; - // ... and its parameters ... - Parametre p; - p["EXECUTABLE"] = "./copied-test-script.sh"; - p["NAME"] = "Test_Local_SSH"; - p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR; - p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); - p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); - p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); - p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); - p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST; - job.setParametre(p); - // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) - Environnement e; - e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK"); - job.setEnvironnement(e); - cout << job << endl; - - // Get the catalog - BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); - - // Create a BatchManager of type Local_SSH on localhost - FactBatchManager * fbm = c("SSH"); - BatchManager * bm = (*fbm)("localhost"); - - // Submit the job to the BatchManager - JobId jobid = bm->submitJob(job); - cout << jobid.__repr__() << endl; - - // Wait for the end of the job - string state = "Unknown"; - while (state != "Done") { - usleep(10000); - JobInfo jinfo = jobid.queryJob(); - state = jinfo.getParametre()["STATE"].str(); - } + try { + // Define the job... + Job job; + // ... and its parameters ... + Parametre p; + p["EXECUTABLE"] = "./copied-test-script.sh"; + p["NAME"] = "Test_Local_SSH"; + p["WORKDIR"] = TEST_LOCAL_SSH_WORK_DIR; + p["INFILE"] = Couple("seta.sh", "copied-seta.sh"); + p["INFILE"] += Couple("setb.sh", "copied-setb.sh"); + p["INFILE"] += Couple("test-script.sh", "copied-test-script.sh"); + p["OUTFILE"] = Couple("result.txt", "orig-result.txt"); + p["EXECUTIONHOST"] = TEST_LOCAL_SSH_EXECUTION_HOST; + job.setParametre(p); + // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) + Environnement e; + const char * sshAuthSock = getenv("SSH_AUTH_SOCK"); + if (sshAuthSock != NULL) e["SSH_AUTH_SOCK"] = sshAuthSock; + job.setEnvironnement(e); + cout << job << endl; + + // Get the catalog + BatchManagerCatalog& c = BatchManagerCatalog::getInstance(); + + // Create a BatchManager of type Local_SSH on localhost + FactBatchManager * fbm = c("SSH"); + BatchManager * bm = (*fbm)("localhost"); + + // Submit the job to the BatchManager + JobId jobid = bm->submitJob(job); + cout << jobid.__repr__() << endl; + + // Wait for the end of the job + string state = "Unknown"; + for (int i=0 ; i<100 && state != "Done" ; i++) { + usleep(100000); + Versatile paramState = jobid.queryJob().getParametre()["STATE"]; + state = (paramState.size() > 0) ? paramState.str() : "Unknown"; + cout << "Job state is: " << state << endl; + } - cout << "Job " << jobid.__repr__() << " is done" << endl; + if (state != "Done") { + cerr << "Error: Job not finished after timeout" << endl; + return 1; + } + + cout << "Job " << jobid.__repr__() << " is done" << endl; + + } catch (GenericException e) { + cerr << "Error: " << e << endl; + return 1; + } // wait for 5 more seconds for the copy of output files and the cleanup // (there's no cleaner way to do that yet) diff --git a/src/Local/Test/Test_Local_config.h.in b/src/Local/Test/Test_Local_config.h.in index c8eefa6..33da7f8 100644 --- a/src/Local/Test/Test_Local_config.h.in +++ b/src/Local/Test/Test_Local_config.h.in @@ -25,3 +25,8 @@ #define TEST_LOCAL_SSH_EXECUTION_HOST "${TEST_LOCAL_SSH_EXECUTION_HOST}" #define TEST_LOCAL_SSH_WORK_DIR "${TEST_LOCAL_SSH_WORK_DIR}" + +#ifdef WIN32 +#define sleep(seconds) Sleep((seconds)*1000) +#define usleep(useconds) Sleep((useconds)/1000) +#endif diff --git a/src/PBS/Batch_BatchManager_ePBS.cxx b/src/PBS/Batch_BatchManager_ePBS.cxx index 261c9b8..9588971 100644 --- a/src/PBS/Batch_BatchManager_ePBS.cxx +++ b/src/PBS/Batch_BatchManager_ePBS.cxx @@ -64,6 +64,9 @@ namespace Batch { // Methode pour le controle des jobs : soumet un job au gestionnaire const JobId BatchManager_ePBS::submitJob(const Job & job) { +#ifdef WIN32 + throw NotYetImplementedException("PBS emulation not supported on Windows platform yet"); +#else int status; Parametre params = job.getParametre(); const std::string dirForTmpFiles = params[TMPDIR]; @@ -130,6 +133,7 @@ namespace Batch { JobId id(this, strjob); return id; +#endif //WIN32 } // Methode pour le controle des jobs : retire un job du gestionnaire diff --git a/src/PBS/Test/Test_PBS_config.h.in b/src/PBS/Test/Test_PBS_config.h.in index 9534b79..faf5a50 100644 --- a/src/PBS/Test/Test_PBS_config.h.in +++ b/src/PBS/Test/Test_PBS_config.h.in @@ -24,3 +24,8 @@ #define TEST_PBS_USER "${TEST_PBS_USER}" #define TEST_PBS_HOMEDIR "${TEST_PBS_HOMEDIR}" #define TEST_PBS_QUEUE "${TEST_PBS_QUEUE}" + +#ifdef WIN32 +#define sleep(seconds) Sleep((seconds)*1000) +#define usleep(useconds) Sleep((useconds)/1000) +#endif diff --git a/src/PBS/Test/Test_ePBS.cxx b/src/PBS/Test/Test_ePBS.cxx index a5bf92c..75d6d5f 100644 --- a/src/PBS/Test/Test_ePBS.cxx +++ b/src/PBS/Test/Test_ePBS.cxx @@ -74,7 +74,8 @@ int main(int argc, char** argv) job.setParametre(p); // ... and its environment (SSH_AUTH_SOCK env var is important for ssh agent authentication) Environnement e; - e["SSH_AUTH_SOCK"] = getenv("SSH_AUTH_SOCK"); + const char * sshAuthSock = getenv("SSH_AUTH_SOCK"); + if (sshAuthSock != NULL) e["SSH_AUTH_SOCK"] = sshAuthSock; job.setEnvironnement(e); cout << job << endl; @@ -107,7 +108,8 @@ int main(int argc, char** argv) } } catch (GenericException e) { - cerr << "Batch library exception of type " << e.type << ": " << e.message << endl; + cerr << "Error: " << e << endl; + return 1; } // test the result file diff --git a/src/Python/Batch_PyVersatile.hxx b/src/Python/Batch_PyVersatile.hxx index 41439fc..0fbbde9 100644 --- a/src/Python/Batch_PyVersatile.hxx +++ b/src/Python/Batch_PyVersatile.hxx @@ -20,7 +20,7 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // /* - * PyVersatile.hxx : + * PyVersatile.hxx : * * Auteur : Ivan DUTKA-MALEN - EDF R&D * Mail : mailto:ivan.dutka-malen@der.edf.fr @@ -41,9 +41,19 @@ #include "Batch_ListIsFullException.hxx" #include "Batch_InvalidArgumentException.hxx" +#ifdef WIN32 +# if defined _libBatch_Swig_EXPORTS +# define BATCH_SWIG_EXPORT __declspec( dllexport ) +# else +# define BATCH_SWIG_EXPORT __declspec( dllimport ) +# endif +#else +# define BATCH_SWIG_EXPORT +#endif + namespace Batch { - class BATCH_EXPORT PyVersatile : public Versatile + class BATCH_SWIG_EXPORT PyVersatile : public Versatile { public: // Constructeur a partir d'un objet Versatile diff --git a/src/Python/Test/Test_Python_Local_SH.py b/src/Python/Test/Test_Python_Local_SH.py index 34f44d1..fddae1d 100644 --- a/src/Python/Test/Test_Python_Local_SH.py +++ b/src/Python/Test/Test_Python_Local_SH.py @@ -69,13 +69,20 @@ def work(): # Wait for the end of the job state = 'Unknown' - while state != 'Done': + i=0 + while state != 'Done' and i<10: time.sleep(0.1) + i+=1 jinfo = jobid.queryJob() try: state = jinfo.getParametre()['STATE'] except KeyError: pass + print "State is", state + + if state != "Done": + print "Error: Job not finished after timeout" + return 1; print "Job", jobid, "is done"