From 150b18309c514bf43d5e53a1a9fefbe76aae0285 Mon Sep 17 00:00:00 2001 From: barate Date: Thu, 30 Apr 2009 13:46:37 +0000 Subject: [PATCH] Merge from V5_1_main 2009-04-30 15:16 (Paris, UTC+2) --- bin/Makefile.am | 25 +- bin/appliskel/runRemote.sh | 2 +- bin/nameserver.py | 2 +- bin/runSalome.py | 3 +- doc/salome/gui/Makefile.am | 5 + doc/salome/gui/static/footer.html | 4 +- doc/salome/tui/static/footer.html | 4 +- idl/SALOME_Component.idl | 21 ++ idl/SALOME_ContainerManager.idl | 99 +++-- idl/SALOME_MPIContainer.idl | 6 - resources/KERNELCatalog.xml.in | 3 + salome_adm/cmake_files/FindBOOST.cmake | 130 ++++++- salome_adm/cmake_files/FindCPPUNIT.cmake | 120 +++++- salome_adm/cmake_files/FindHDF5.cmake | 158 +++++++- salome_adm/cmake_files/FindLIBXML2.cmake | 148 ++++++-- salome_adm/cmake_files/FindOMNIORB.cmake | 290 ++++++++++---- salome_adm/cmake_files/FindPLATFORM.cmake | 66 ++-- salome_adm/cmake_files/FindPTHREADS.cmake | 124 +++++- salome_adm/cmake_files/FindPYTHON.cmake | 228 +++++++++-- salome_adm/cmake_files/FindSWIG.cmake | 73 +++- salome_adm/cmake_files/Makefile.am | 3 +- salome_adm/cmake_files/am2cmake.py | 342 ++++++----------- .../install_and_compile_python_file.cmake | 27 ++ salome_adm/unix/config_files/check_openmpi.m4 | 2 +- src/Batch_SWIG/Makefile.am | 7 +- src/Communication/SALOME_Communication.hxx | 2 +- src/Container/Container_i.cxx | 44 +++ src/Container/Makefile.am | 7 +- src/Container/SALOME_ContainerManager.cxx | 355 +++++++++--------- src/Container/SALOME_ContainerManager.hxx | 27 +- src/Container/SALOME_Container_i.hxx | 1 + src/Container/SALOME_FileTransfer_i.cxx | 51 ++- src/Container/SALOME_FileTransfer_i.hxx | 4 +- src/Container/Salome_file_i.hxx | 4 +- src/DF/DF_definitions.hxx | 2 +- src/DSC/DSC_Basic/DSC_Basic.hxx | 2 +- src/DSC/DSC_Python/Makefile.am | 2 + .../DSC_User/Datastream/Calcium/calciumf.c | 4 +- src/KERNEL_PY/Makefile.am | 34 +- src/Launcher/BatchTest.cxx | 2 +- src/Launcher/BatchTest.hxx | 4 +- src/Launcher/Launcher.cxx | 15 +- src/Launcher/SALOME_Launcher.cxx | 6 +- .../SALOME_FileTransferCORBA.cxx | 9 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 100 +++-- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx | 6 +- .../Test/LifeCycleCORBATest.cxx | 8 +- src/LifeCycleCORBA/TestContainerManager.cxx | 18 +- src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 9 + src/LifeCycleCORBA_SWIG/Makefile.am | 2 +- .../Test/LifeCycleCORBA_SWIGTest.py | 2 +- src/LifeCycleCORBA_SWIG/Test/Makefile.am | 9 +- .../Test/testcontainermanager.py | 56 +++ .../Test/testresourcemanager.py | 116 ++++++ .../libSALOME_LifeCycleCORBA.i | 172 ++++----- src/Logger/Makefile.am | 2 +- src/Logger/Test/Makefile.am | 2 +- src/MPIContainer/MPIContainer_i.cxx | 213 ++++++----- src/MPIContainer/MPIContainer_i.hxx | 30 +- src/MPIContainer/MPIObject_i.cxx | 97 +++-- src/MPIContainer/MPIObject_i.hxx | 16 +- src/Makefile.am | 4 +- src/ModuleCatalog/Makefile.am | 2 +- src/ModuleGenerator/Makefile.am | 7 +- src/NamingService/Makefile.am | 2 +- src/NamingService/Test/Makefile.am | 9 +- .../SALOME_ParallelComponent_i.hxx | 2 +- .../SALOME_ParallelContainer_i.hxx | 2 +- src/ResourcesManager/ResourcesManager.cxx | 133 ++++--- src/ResourcesManager/ResourcesManager.hxx | 16 +- .../SALOME_LoadRateManager.cxx | 41 +- .../SALOME_LoadRateManager.hxx | 34 +- .../SALOME_ResourcesCatalog_Handler.cxx | 57 ++- .../SALOME_ResourcesCatalog_Handler.hxx | 5 +- .../SALOME_ResourcesCatalog_Parser.cxx | 8 +- .../SALOME_ResourcesCatalog_Parser.hxx | 1 + .../SALOME_ResourcesManager.cxx | 46 ++- .../SALOME_ResourcesManager.hxx | 6 +- src/SALOMEDS/Makefile.am | 2 +- src/SALOMEDS/SALOMEDS_Defines.hxx | 2 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 27 +- src/SALOMEDS/Test/Makefile.am | 2 +- .../SALOMEDSClient_definitions.hxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 17 +- src/SALOMEDSImpl/Test/Makefile.am | 2 +- src/SALOMELocalTrace/Test/Makefile.am | 2 +- src/SALOMETraceCollector/Test/Makefile.am | 2 +- src/TOOLSDS/SALOMEDS_Tool.hxx | 2 +- src/TestContainer/Makefile.am | 2 +- src/UnitTests/Makefile.am | 2 +- src/Utils/Makefile.am | 2 +- src/Utils/Test/Makefile.am | 2 +- 93 files changed, 2581 insertions(+), 1189 deletions(-) create mode 100644 salome_adm/cmake_files/install_and_compile_python_file.cmake create mode 100644 src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py create mode 100644 src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py diff --git a/bin/Makefile.am b/bin/Makefile.am index a62a38534..000aeda4b 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -42,11 +42,20 @@ nodist_salomescript_DATA = \ # These files are executable scripts dist_salomescript_SCRIPTS = \ - addToKillList.py \ appli_clean.sh \ - appli_gen.py \ appli_install.sh \ createAppli.sh \ + runIDLparser \ + runNS.sh \ + runSalome \ + runSalome.csh \ + runSalome.ksh \ + waitNS.sh + +# These files are python files +dist_salomescript_PYTHON = \ + addToKillList.py \ + appli_gen.py \ envSalome.py \ killSalome.py \ killSalomeWithPort.py \ @@ -55,12 +64,7 @@ dist_salomescript_SCRIPTS = \ nameserver.py \ NSparam.py \ orbmodule.py \ - runIDLparser \ runNS.py \ - runNS.sh \ - runSalome \ - runSalome.csh \ - runSalome.ksh \ runSalome.py \ salomeConsole.py \ salome_session.py \ @@ -71,8 +75,7 @@ dist_salomescript_SCRIPTS = \ shutdownSalome.py \ virtual_salome.py \ waitContainers.py \ - waitNS.py \ - waitNS.sh + waitNS.py EXTRA_DIST = appliskel @@ -95,3 +98,7 @@ uninstall-local: rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \ fi; +install-data-hook: + @for f in $(dist_salomescript_PYTHON) ; do \ + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/bin/appliskel/runRemote.sh b/bin/appliskel/runRemote.sh index dd5258e4f..53034f950 100755 --- a/bin/appliskel/runRemote.sh +++ b/bin/appliskel/runRemote.sh @@ -57,7 +57,7 @@ export NSHOST NSPORT=$2 export NSPORT initref="NameService=corbaname::"$1":$2" -echo "ORBInitRef $initref" > $OMNIORB_CONFIG +echo "InitRef = $initref" > $OMNIORB_CONFIG #go to the requested working directory if any if test "x$3" == "xWORKINGDIR"; then diff --git a/bin/nameserver.py b/bin/nameserver.py index 46986f897..32fa88627 100755 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -95,7 +95,7 @@ class NamingServer(Server): #print "port=", aPort if sys.platform == "win32": #print "start omniNames -start " + aPort + " -logdir " + upath - self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"', ' -errlog', '\"' + upath+'/omniNameErrors.log' + '\"'] + self.CMD=['omniNames -start ' , aPort , ' -nohostname ', ' -logdir ' , '\"' + upath + '\"', ' -errlog', '\"' + upath+'/omniNameErrors.log' + '\"'] #os.system("start omniNames -start " + aPort + " -logdir " + upath) else: #self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &'] diff --git a/bin/runSalome.py b/bin/runSalome.py index bf9cfc5fe..f5b95927f 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -705,8 +705,7 @@ def useSalome(args, modules_list, modules_root_dir): scrname = toimport[ i ] if len(scrname) > 2 and (len(scrname) - string.rfind(scrname, ".py") == 3): print 'executing',scrname - doexec = 'execfile(\"%s\")'%scrname - exec doexec + execfile(scrname,globals()) else: print 'importing',scrname doimport = 'import ' + scrname diff --git a/doc/salome/gui/Makefile.am b/doc/salome/gui/Makefile.am index 6205e23b6..aad10ecc2 100644 --- a/doc/salome/gui/Makefile.am +++ b/doc/salome/gui/Makefile.am @@ -25,3 +25,8 @@ dist-hook: cp -Rp $(srcdir)/static $(distdir) ; \ rm -rf $(distdir)/static/CVS +# VSR: nullify these make targets to avoid 'make distcheck' failure +dvi: +pdf: +ps: + diff --git a/doc/salome/gui/static/footer.html b/doc/salome/gui/static/footer.html index 56d52a61a..6eab03cf2 100755 --- a/doc/salome/gui/static/footer.html +++ b/doc/salome/gui/static/footer.html @@ -4,7 +4,9 @@
-
Copyright © 2003-2007 CEA, EDF
+
+Copyright © 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
diff --git a/doc/salome/tui/static/footer.html b/doc/salome/tui/static/footer.html index 56d52a61a..6eab03cf2 100755 --- a/doc/salome/tui/static/footer.html +++ b/doc/salome/tui/static/footer.html @@ -4,7 +4,9 @@
-
Copyright © 2003-2007 CEA, EDF
+
+Copyright © 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index e47f886d0..616cda33c 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -179,6 +179,13 @@ module Engines */ fileTransfer getFileTransfer(); + //! Copy a file from a remote host (container) to a local file + /*! + \param contai the remote container + \param remoteFile the file on the remote host to copy + \param localFile the local file to create by copy + */ + void copyFile(in Container contai, in string remoteFile, in string localFile); }; /*! \brief Interface of the %component. @@ -430,6 +437,12 @@ module Engines File. */ long open(in string fileName); + //! Open the file transfer in write mode for file fileName + /*! + \param fileName the file to copy into with putBlock + \return the id to use with putBlock + */ + long openW(in string fileName); //! Close the file transfer /*! @@ -444,6 +457,14 @@ module Engines The last block is empty, and identifies the end of file. */ fileBlock getBlock(in long fileId); + + //! Put a file data block + /*! + \param fileId identification of the file obtained by openW + \param block a data block to copy into the file identified by fileId + */ + void putBlock(in long fileId, in fileBlock block); + }; //! A file managed by a Salome_file. diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 32b8e364e..184f341da 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -40,45 +40,79 @@ module Engines //! modules list typedef sequence ModulesList; -//! Type to describe properties of a resource. +//! Type to describe required properties of a container. struct MachineParameters { + //! container name if given else automatic string container_name; + //! host name if given else automatic string hostname; + //! if given list of components that could be loaded on the container + CompoList componentList; + //! if given restricted list of machines to search in + MachineList computerList; + //! required operating system + string OS; + //! required memory size + long mem_mb; + //! required frequency + long cpu_clock; + //! required number of proc per node + long nb_proc_per_node; + //! required number of node + long nb_node; + //! if true start a MPI container + boolean isMPI; + //! container working directory + string workingdir; + //! creation mode for GiveContainer. + /*!start creates a new container + * get try to find an existing container + * getorstart use an existing container if it exists or creates a new one + */ + string mode; + //! resource management policy : first, cycl, altcycl or best (can be extended) + string policy; + + //! PaCO specific informations + string parallelLib; + long nb_component_nodes; +}; + +//! Type to describe properties of a resource. +struct MachineDefinition +{ + //! host name + string hostname; + //! alias name string alias; + //! protocol to use to start a remote container (ssh or rsh) string protocol; + //! login name to use to start a remote container string username; + //! salome application to use to start a remote container string applipath; - ModulesList modList; + //! list of available components + CompoList componentList; + //! operating system string OS; + //! memory size long mem_mb; + //! frequency long cpu_clock; + //! number of proc per node long nb_proc_per_node; + //! number of node long nb_node; - boolean isMPI; + //! MPI implementation string mpiImpl; + //! batch system string batch; - string workingdir; - - // PaCO specific informations - string parallelLib; long nb_component_nodes; }; - //! exception thrown if a computer is not found in the catalog exception NotFound {}; -//! enumeration to set a resource management policy - enum policy { - //! first machine in the list of admissible computers - P_FIRST, - //! next machine in the list of admissible computers - P_CYCL, - //! best machine in the list of admissible computers - P_BEST}; -//! resource management policy - typedef policy ResPolicy; - //! Structure used for Salome Batch Job parameters struct BatchParameters { @@ -124,35 +158,27 @@ struct BatchParameters interface ContainerManager { //! Find an existing container satisfying the constraints given by input parameters or start a new one. - Container FindOrStartContainer( in MachineParameters params, - in MachineList possibleComputers); + Container FindOrStartContainer( in MachineParameters params); //! This operation launches a PaCO++ container. /*! - \param Description of the container resquested. \param List of computers ressources. \return Container's CORBA reference. */ - Container FindOrStartParallelContainer( in MachineParameters params, - in MachineList possibleComputers); + Container FindOrStartParallelContainer( in MachineParameters params); //! Start a new container satisfying the constraints given by input parameters. - Container StartContainer( in MachineParameters params, - in ResPolicy policy, - in CompoList componentList ); + Container StartContainer( in MachineParameters params); //! Same as StartContainer except that in batch all containers have already been launched /*! - We are in batch if environment variable SALOME_BATCH is 1. In this case, containers have been launched at the beginning of the Salome session and the container manager picks one in the pool of existing containers. */ - Container GiveContainer( in MachineParameters params, - in ResPolicy policy, - in CompoList componentList ); + Container GiveContainer( in MachineParameters params); //! Shutdown all containers that have been launched by the container manager void ShutdownContainers(); @@ -168,17 +194,18 @@ struct BatchParameters //! Find first available computer in a computers list string FindFirst(in MachineList possibleComputers); + //! Find best available computer according to policy in a computers list + string Find(in string policy, in MachineList possibleComputers); + //! Get a list of computers that are best suited to launch a container given constraints /*! - The constraints are resource constraints (params) and components constraints (componentList) */ - MachineList GetFittingResources( in MachineParameters params, - in CompoList componentList ) - raises (SALOME::SALOME_Exception); + MachineList GetFittingResources( in MachineParameters params) + raises (SALOME::SALOME_Exception); //! Get the current machine parameters of a computer - MachineParameters GetMachineParameters( in string hostname ); + MachineDefinition GetMachineParameters( in string hostname ); } ; }; diff --git a/idl/SALOME_MPIContainer.idl b/idl/SALOME_MPIContainer.idl index 2c4697543..e82c416d5 100644 --- a/idl/SALOME_MPIContainer.idl +++ b/idl/SALOME_MPIContainer.idl @@ -39,12 +39,6 @@ module Engines interface MPIContainer:Container,MPIObject { - // asynchronous version to load and remove parallel component in parallel - oneway void Asload_component_Library(in string componentName); - oneway void Ascreate_component_instance(in string componentName,in long studyId); - oneway void Asload_impl(in string nameToRegister, in string componentName); - oneway void Asremove_impl(in Component component_i); - oneway void Asfinalize_removal(); }; } ; diff --git a/resources/KERNELCatalog.xml.in b/resources/KERNELCatalog.xml.in index 1452381ff..2a475bfc0 100644 --- a/resources/KERNELCatalog.xml.in +++ b/resources/KERNELCatalog.xml.in @@ -33,6 +33,9 @@ + + + diff --git a/salome_adm/cmake_files/FindBOOST.cmake b/salome_adm/cmake_files/FindBOOST.cmake index 0c4517cf6..581560ef7 100644 --- a/salome_adm/cmake_files/FindBOOST.cmake +++ b/salome_adm/cmake_files/FindBOOST.cmake @@ -19,13 +19,123 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(BOOST_ROOT $ENV{BOOST_ROOT}) -IF(BOOST_ROOT) - FIND_PATH(BOOST_INCLUDES boost/shared_ptr.hpp ${BOOST_ROOT}) - FIND_LIBRARY(BOOST_LIB_THREAD libboost_thread-vc90-mt-gd-1_35 ${BOOST_ROOT}/lib) - FIND_LIBRARY(BOOST_LIB_DATE_TIME libboost_date_time-vc90-mt-gd-1_35 ${BOOST_ROOT}/lib) - SET(BOOST_LIBS ${BOOST_LIB_THREAD} ${BOOST_LIB_DATE_TIME}) - SET(BOOST_CPPFLAGS -I${BOOST_INCLUDES} -DBOOST_DISABLE_ASSERTS) -ELSE(BOOST_ROOT) - SET(boost_thread -lboost_thread) -ENDIF(BOOST_ROOT) +# ------ + +MESSAGE(STATUS "Check for boost ...") + +# ------ + +IF(BOOST_IS_MANDATORY STREQUAL 0) + SET(BOOST_IS_MANDATORY 0) + SET(BOOST_IS_OPTIONAL 1) +ENDIF(BOOST_IS_MANDATORY STREQUAL 0) +IF(BOOST_IS_OPTIONAL STREQUAL 0) + SET(BOOST_IS_MANDATORY 1) + SET(BOOST_IS_OPTIONAL 0) +ENDIF(BOOST_IS_OPTIONAL STREQUAL 0) +IF(NOT BOOST_IS_MANDATORY AND NOT BOOST_IS_OPTIONAL) + SET(BOOST_IS_MANDATORY 1) + SET(BOOST_IS_OPTIONAL 0) +ENDIF(NOT BOOST_IS_MANDATORY AND NOT BOOST_IS_OPTIONAL) + +# ------ + +SET(BOOST_STATUS 1) +IF(WITHOUT_BOOST OR WITH_BOOST STREQUAL 0) + SET(BOOST_STATUS 0) + MESSAGE(STATUS "boost disabled from command line.") +ENDIF(WITHOUT_BOOST OR WITH_BOOST STREQUAL 0) + +# ------ + +IF(BOOST_STATUS) + IF(WITH_BOOST) + SET(BOOST_ROOT_USER ${WITH_BOOST}) + ELSE(WITH_BOOST) + SET(BOOST_ROOT_USER $ENV{BOOST_ROOT}) + ENDIF(WITH_BOOST) +ENDIF(BOOST_STATUS) + +# ----- + +IF(BOOST_STATUS) + IF(BOOST_ROOT_USER) + SET(BOOST_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(BOOST_ROOT_USER) + SET(BOOST_FIND_PATHS_OPTION) + ENDIF(BOOST_ROOT_USER) +ENDIF(BOOST_STATUS) + +# ----- + +IF(BOOST_STATUS) + IF(BOOST_ROOT_USER) + SET(BOOST_INCLUDE_PATHS ${BOOST_ROOT_USER} ${BOOST_ROOT_USER}/include) + ELSE(BOOST_ROOT_USER) + SET(BOOST_INCLUDE_PATHS) + ENDIF(BOOST_ROOT_USER) + SET(BOOST_INCLUDE_TO_FIND boost/shared_ptr.hpp) + FIND_PATH(BOOST_INCLUDE_DIR ${BOOST_INCLUDE_TO_FIND} PATHS ${BOOST_INCLUDE_PATHS} ${BOOST_FIND_PATHS_OPTION}) + IF(BOOST_INCLUDE_DIR) + IF(BOOST_ROOT_USER) + SET(BOOST_CPPFLAGS -I${BOOST_INCLUDE_DIR}) + ENDIF(BOOST_ROOT_USER) + MESSAGE(STATUS "${BOOST_INCLUDE_TO_FIND} found in ${BOOST_INCLUDE_DIR}") + ELSE(BOOST_INCLUDE_DIR) + SET(BOOST_STATUS 0) + IF(BOOST_ROOT_USER) + MESSAGE(STATUS "${BOOST_INCLUDE_TO_FIND} not found in ${BOOST_INCLUDE_PATHS}, check your BOOST installation.") + ELSE(BOOST_ROOT_USER) + MESSAGE(STATUS "${BOOST_INCLUDE_TO_FIND} not found on system, try to use WITH_BOOST option or BOOST_ROOT environment variable.") + ENDIF(BOOST_ROOT_USER) + ENDIF(BOOST_INCLUDE_DIR) +ENDIF(BOOST_STATUS) + +# ---- + +IF(BOOST_STATUS) + IF(BOOST_ROOT_USER) + SET(BOOST_LIB_PATHS ${BOOST_ROOT_USER}/lib) + ELSE(BOOST_ROOT_USER) + SET(BOOST_LIB_PATHS) + ENDIF(BOOST_ROOT_USER) +ENDIF(BOOST_STATUS) + +IF(BOOST_STATUS) + IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Debug) + SET(EXTENSION -gd) + ELSE(CMAKE_BUILD_TYPE STREQUAL Debug) + SET(EXTENSION) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) + FIND_LIBRARY(BOOST_LIB_THREAD libboost_thread-vc90-mt${EXTENSION}-1_35 ${BOOST_LIB_PATHS}) + FIND_LIBRARY(BOOST_LIB_DATE_TIME libboost_date_time-vc90-mt${EXTENSION}-1_35 ${BOOST_LIB_PATHS}) + FIND_LIBRARY(BOOST_LIB_SIGNALS libboost_signals-vc90-mt${EXTENSION}-1_35 ${BOOST_LIB_PATHS}) + FIND_LIBRARY(BOOST_LIB_FILESYSTEM libboost_filesystem-vc90-mt${EXTENSION}-1_35 ${BOOST_LIB_PATHS}) + FIND_LIBRARY(BOOST_LIB_SYSTEM libboost_system-vc90-mt${EXTENSION}-1_35 ${BOOST_LIB_PATHS}) + ELSE(WINDOWS) + FIND_LIBRARY(BOOST_LIB_THREAD boost_thread ${BOOST_LIB_PATHS}) + ENDIF(WINDOWS) + SET(BOOST_LIBS) + SET(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_THREAD}) + SET(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_DATE_TIME}) + SET(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_SIGNALS}) + SET(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_FILESYSTEM}) + SET(BOOST_LIBS ${BOOST_LIBS} ${BOOST_LIB_SYSTEM}) +ENDIF(BOOST_STATUS) + +# ------ + +IF(BOOST_STATUS) + IF(WINDOWS) + SET(BOOST_CPPFLAGS ${BOOST_CPPFLAGS} -DBOOST_DISABLE_ASSERTS) + ENDIF(WINDOWS) +ELSE(BOOST_STATUS) + IF(BOOST_IS_MANDATORY) + MESSAGE(FATAL_ERROR "boost not found ... mandatory ... abort") + ELSE(BOOST_IS_MANDATORY) + MESSAGE(STATUS "boost not found ... optional ... disabled") + ENDIF(BOOST_IS_MANDATORY) +ENDIF(BOOST_STATUS) + +# ------ diff --git a/salome_adm/cmake_files/FindCPPUNIT.cmake b/salome_adm/cmake_files/FindCPPUNIT.cmake index 5add4eeb3..7e8263eac 100644 --- a/salome_adm/cmake_files/FindCPPUNIT.cmake +++ b/salome_adm/cmake_files/FindCPPUNIT.cmake @@ -19,7 +19,121 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FIND_LIBRARY(CPPUNIT_LIBS cppunit /usr/lib) -IF(CPPUNIT_LIBS) +# ------ + +MESSAGE(STATUS "Check for cppunit ...") + +# ------ + +IF(CPPUNIT_IS_MANDATORY STREQUAL 0) + SET(CPPUNIT_IS_MANDATORY 0) + SET(CPPUNIT_IS_OPTIONAL 1) +ENDIF(CPPUNIT_IS_MANDATORY STREQUAL 0) +IF(CPPUNIT_IS_OPTIONAL STREQUAL 0) + SET(CPPUNIT_IS_MANDATORY 1) + SET(CPPUNIT_IS_OPTIONAL 0) +ENDIF(CPPUNIT_IS_OPTIONAL STREQUAL 0) +IF(NOT CPPUNIT_IS_MANDATORY AND NOT CPPUNIT_IS_OPTIONAL) + SET(CPPUNIT_IS_MANDATORY 0) + SET(CPPUNIT_IS_OPTIONAL 1) +ENDIF(NOT CPPUNIT_IS_MANDATORY AND NOT CPPUNIT_IS_OPTIONAL) + +# ------ + +SET(CPPUNIT_STATUS 1) +IF(WITHOUT_CPPUNIT OR WITH_CPPUNIT STREQUAL 0) + SET(CPPUNIT_STATUS 0) + MESSAGE(STATUS "cppunit disabled from command line.") +ENDIF(WITHOUT_CPPUNIT OR WITH_CPPUNIT STREQUAL 0) + +# ------ + +IF(CPPUNIT_STATUS) + IF(WITH_CPPUNIT) + SET(CPPUNIT_ROOT_USER ${WITH_CPPUNIT}) + ELSE(WITH_CPPUNIT) + SET(CPPUNIT_ROOT_USER $ENV{CPPUNIT_ROOT}) + ENDIF(WITH_CPPUNIT) +ENDIF(CPPUNIT_STATUS) + +# ----- + +IF(CPPUNIT_STATUS) + IF(CPPUNIT_ROOT_USER) + SET(CPPUNIT_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(CPPUNIT_ROOT_USER) + SET(CPPUNIT_FIND_PATHS_OPTION) + ENDIF(CPPUNIT_ROOT_USER) +ENDIF(CPPUNIT_STATUS) + +# ----- + +IF(CPPUNIT_STATUS) + IF(CPPUNIT_ROOT_USER) + SET(CPPUNIT_INCLUDE_PATHS ${CPPUNIT_ROOT_USER} ${CPPUNIT_ROOT_USER}/include) + ELSE(CPPUNIT_ROOT_USER) + SET(CPPUNIT_INCLUDE_PATHS) + ENDIF(CPPUNIT_ROOT_USER) + SET(CPPUNIT_INCLUDE_TO_FIND cppunit/extensions/HelperMacros.h) + FIND_PATH(CPPUNIT_INCLUDE_DIR ${CPPUNIT_INCLUDE_TO_FIND} PATHS ${CPPUNIT_INCLUDE_PATHS} ${CPPUNIT_FIND_PATHS_OPTION}) + IF(CPPUNIT_INCLUDE_DIR) + IF(CPPUNIT_ROOT_USER) + SET(CPPUNIT_INCLUDES -I${CPPUNIT_INCLUDE_DIR}) + ENDIF(CPPUNIT_ROOT_USER) + MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} found in ${CPPUNIT_INCLUDE_DIR}") + ELSE(CPPUNIT_INCLUDE_DIR) + SET(CPPUNIT_STATUS 0) + IF(CPPUNIT_ROOT_USER) + MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found in ${CPPUNIT_INCLUDE_PATHS}, check your CPPUNIT installation.") + ELSE(CPPUNIT_ROOT_USER) + MESSAGE(STATUS "${CPPUNIT_INCLUDE_TO_FIND} not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT environment variable.") + ENDIF(CPPUNIT_ROOT_USER) + ENDIF(CPPUNIT_INCLUDE_DIR) +ENDIF(CPPUNIT_STATUS) + +# ---- + +IF(CPPUNIT_STATUS) + IF(CPPUNIT_ROOT_USER) + SET(CPPUNIT_LIB_PATHS ${CPPUNIT_ROOT_USER}/lib) + ELSE(CPPUNIT_ROOT_USER) + SET(CPPUNIT_LIB_PATHS) + ENDIF(CPPUNIT_ROOT_USER) +ENDIF(CPPUNIT_STATUS) + +IF(CPPUNIT_STATUS) + IF(WINDOWS) + FIND_LIBRARY(CPPUNIT_LIB cppunitd_dll PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION}) + ELSE(WINDOWS) + FIND_LIBRARY(CPPUNIT_LIB cppunit PATHS ${CPPUNIT_LIB_PATHS} ${CPPUNIT_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(CPPUNIT_LIBS) + IF(CPPUNIT_LIB) + SET(CPPUNIT_LIBS ${CPPUNIT_LIBS} ${CPPUNIT_LIB}) + MESSAGE(STATUS "cppunit lib found: ${CPPUNIT_LIB}") + ELSE(CPPUNIT_LIB) + SET(CPPUNIT_STATUS 0) + IF(CPPUNIT_ROOT_USER) + MESSAGE(STATUS "cppunit lib not found in ${CPPUNIT_LIB_PATHS}, check your CPPUNIT installation.") + ELSE(CPPUNIT_ROOT_USER) + MESSAGE(STATUS "cppunit lib not found on system, try to use WITH_CPPUNIT option or CPPUNIT_ROOT environment variable.") + ENDIF(CPPUNIT_ROOT_USER) + ENDIF(CPPUNIT_LIB) +ENDIF(CPPUNIT_STATUS) + +# ---- + +IF(CPPUNIT_STATUS) SET(CPPUNIT_IS_OK 1) -ENDIF(CPPUNIT_LIBS) + IF(WINDOWS) + SET(CPPUNIT_INCLUDES ${CPPUNIT_INCLUDES} -DCPPUNIT_DLL) + ENDIF(WINDOWS) +ELSE(CPPUNIT_STATUS) + IF(CPPUNIT_IS_MANDATORY) + MESSAGE(FATAL_ERROR "cppunit not found ... mandatory ... abort") + ELSE(CPPUNIT_IS_MANDATORY) + MESSAGE(STATUS "cppunit not found ... optional ... disabled") + ENDIF(CPPUNIT_IS_MANDATORY) +ENDIF(CPPUNIT_STATUS) + +# ------ diff --git a/salome_adm/cmake_files/FindHDF5.cmake b/salome_adm/cmake_files/FindHDF5.cmake index 27b784a83..fe54d590a 100644 --- a/salome_adm/cmake_files/FindHDF5.cmake +++ b/salome_adm/cmake_files/FindHDF5.cmake @@ -19,24 +19,150 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FIND_PROGRAM(HDF5_DUMP h5dump) +# ------ -SET(HDF5_ROOT ${HDF5_DUMP}) -GET_FILENAME_COMPONENT(HDF5_ROOT ${HDF5_ROOT} PATH) -GET_FILENAME_COMPONENT(HDF5_ROOT ${HDF5_ROOT} PATH) +MESSAGE(STATUS "Check for hdf5 ...") -FIND_PATH(HDF5_INCLUDES H5public.h ${HDF5_ROOT}/include) -SET(HDF5_INCLUDES -I${HDF5_INCLUDES}) +# ------ -IF(WINDOWS) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(HDF5_LIBS hdf5 ${HDF5_ROOT}/lib) - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(HDF5_LIBS hdf5d ${HDF5_ROOT}/lib) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ELSE(WINDOWS) - FIND_LIBRARY(HDF5_LIBS hdf5 ${HDF5_ROOT}/lib) -ENDIF(WINDOWS) +IF(HDF5_IS_MANDATORY STREQUAL 0) + SET(HDF5_IS_MANDATORY 0) + SET(HDF5_IS_OPTIONAL 1) +ENDIF(HDF5_IS_MANDATORY STREQUAL 0) +IF(HDF5_IS_OPTIONAL STREQUAL 0) + SET(HDF5_IS_MANDATORY 1) + SET(HDF5_IS_OPTIONAL 0) +ENDIF(HDF5_IS_OPTIONAL STREQUAL 0) +IF(NOT HDF5_IS_MANDATORY AND NOT HDF5_IS_OPTIONAL) + SET(HDF5_IS_MANDATORY 1) + SET(HDF5_IS_OPTIONAL 0) +ENDIF(NOT HDF5_IS_MANDATORY AND NOT HDF5_IS_OPTIONAL) + +# ------ + +SET(HDF5_STATUS 1) +IF(WITHOUT_HDF5 OR WITH_HDF5 STREQUAL 0) + SET(HDF5_STATUS 0) + MESSAGE(STATUS "hdf5 disabled from command line.") +ENDIF(WITHOUT_HDF5 OR WITH_HDF5 STREQUAL 0) + +# ------ + +IF(HDF5_STATUS) + IF(WITH_HDF5) + SET(HDF5_ROOT_USER ${WITH_HDF5}) + ENDIF(WITH_HDF5) + IF(NOT HDF5_ROOT_USER) + SET(HDF5_ROOT_USER $ENV{HDF5_ROOT}) + ENDIF(NOT HDF5_ROOT_USER) + IF(NOT HDF5_ROOT_USER) + SET(HDF5_ROOT_USER $ENV{HDF5HOME}) + ENDIF(NOT HDF5_ROOT_USER) +ENDIF(HDF5_STATUS) + +# ------ + +IF(HDF5_STATUS) + IF(NOT HDF5_ROOT_USER) + FIND_PROGRAM(HDF5_DUMP h5dump) + IF(HDF5_DUMP) + MESSAGE(STATUS "h5dump found: ${HDF5_DUMP}") + IF(HDF5_DUMP STREQUAL /usr/bin/h5dump) + ELSE(HDF5_DUMP STREQUAL /usr/bin/h5dump) + SET(HDF5_ROOT_USER ${HDF5_DUMP}) + GET_FILENAME_COMPONENT(HDF5_ROOT_USER ${HDF5_ROOT_USER} PATH) + GET_FILENAME_COMPONENT(HDF5_ROOT_USER ${HDF5_ROOT_USER} PATH) + ENDIF(HDF5_DUMP STREQUAL /usr/bin/h5dump) + ELSE(HDF5_DUMP) + MESSAGE(STATUS "h5dump not found, try to use WITH_HDF5 option or HDF5_ROOT (or HDF5HOME) environment variable") + SET(HDF5_STATUS 0) + ENDIF(HDF5_DUMP) + ENDIF(NOT HDF5_ROOT_USER) +ENDIF(HDF5_STATUS) + +# ------ + +IF(HDF5_STATUS) + IF(HDF5_ROOT_USER) + SET(HDF5_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(HDF5_ROOT_USER) + SET(HDF5_FIND_PATHS_OPTION) + ENDIF(HDF5_ROOT_USER) +ENDIF(HDF5_STATUS) + +# ------ + +IF(HDF5_STATUS) + IF(HDF5_ROOT_USER) + SET(HDF5_INCLUDE_PATHS ${HDF5_ROOT_USER}/include) + ELSE(HDF5_ROOT_USER) + SET(HDF5_INCLUDE_PATHS) + ENDIF(HDF5_ROOT_USER) + SET(HDF5_INCLUDE_TO_FIND H5public.h) + FIND_PATH(HDF5_INCLUDE_DIR ${HDF5_INCLUDE_TO_FIND} PATHS ${HDF5_INCLUDE_PATHS} ${HDF5_FIND_PATHS_OPTION}) + IF(HDF5_INCLUDE_DIR) + IF(HDF5_ROOT_USER) + SET(HDF5_INCLUDES -I${HDF5_INCLUDE_DIR}) + ENDIF(HDF5_ROOT_USER) + SET(HDF5_INCLUDES -D_HDF5USEDLL_ ${HDF5_INCLUDES}) + MESSAGE(STATUS "${HDF5_INCLUDE_TO_FIND} found in ${HDF5_INCLUDE_DIR}") + ELSE(HDF5_INCLUDE_DIR) + SET(HDF5_STATUS 0) + IF(HDF5_ROOT_USER) + MESSAGE(STATUS "${HDF5_INCLUDE_TO_FIND} not found in ${HDF5_INCLUDE_PATHS}, check your HDF5 installation.") + ELSE(HDF5_ROOT_USER) + MESSAGE(STATUS "${HDF5_INCLUDE_TO_FIND} not found on system, try to use WITH_HDF5 option or HDF5_ROOT (or HDF5HOME) environment variable.") + ENDIF(HDF5_ROOT_USER) + ENDIF(HDF5_INCLUDE_DIR) +ENDIF(HDF5_STATUS) + +# ---- + +IF(HDF5_STATUS) + IF(HDF5_ROOT_USER) + IF(WINDOWS) + SET(HDF5_LIB_PATHS ${HDF5_ROOT_USER}/dll) + ELSE(WINDOWS) + SET(HDF5_LIB_PATHS ${HDF5_ROOT_USER}/lib) + ENDIF(WINDOWS) + ELSE(HDF5_ROOT_USER) + SET(HDF5_LIB_PATHS) + ENDIF(HDF5_ROOT_USER) + IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(HDF5_LIB hdf5dll PATHS ${HDF5_LIB_PATHS} ${HDF5_FIND_PATHS_OPTION}) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(HDF5_LIB hdf5ddll PATHS ${HDF5_LIB_PATHS} ${HDF5_FIND_PATHS_OPTION}) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(WINDOWS) + FIND_LIBRARY(HDF5_LIB hdf5 PATHS ${HDF5_LIB_PATHS} ${HDF5_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(HDF5_LIBS) + IF(HDF5_LIB) + SET(HDF5_LIBS ${HDF5_LIBS} ${HDF5_LIB}) + MESSAGE(STATUS "hdf5 lib found: ${HDF5_LIB}") + ELSE(HDF5_LIB) + SET(HDF5_STATUS 0) + IF(HDF5_ROOT_USER) + MESSAGE(STATUS "hdf5 lib not found in ${HDF5_LIB_PATHS}, check your HDF5 installation.") + ELSE(HDF5_ROOT_USER) + MESSAGE(STATUS "hdf5 lib not found on system, try to use WITH_HDF5 option or HDF5_ROOT (or HDF5HOME) environment variable.") + ENDIF(HDF5_ROOT_USER) + ENDIF(HDF5_LIB) +ENDIF(HDF5_STATUS) + +# ---- + +IF(HDF5_STATUS) +ELSE(HDF5_STATUS) + IF(HDF5_IS_MANDATORY) + MESSAGE(FATAL_ERROR "hdf5 not found ... mandatory ... abort") + ELSE(HDF5_IS_MANDATORY) + MESSAGE(STATUS "hdf5 not found ... optional ... disabled") + ENDIF(HDF5_IS_MANDATORY) +ENDIF(HDF5_STATUS) + +# ------ #SET(ZLIB_ROOT $ENV{ZLIB_ROOT}) #STRING(LENGTH "${ZLIB_ROOT}" NB) @@ -51,3 +177,5 @@ ENDIF(WINDOWS) # FIND_LIBRARY(SZIP_LIBS szlib ${SZIP_ROOT}/lib) # SET(HDF5_LIBS ${HDF5_LIBS} ${SZIP_LIBS}) #ENDIF(${NB} GREATER 0) + +# ------ diff --git a/salome_adm/cmake_files/FindLIBXML2.cmake b/salome_adm/cmake_files/FindLIBXML2.cmake index cd0b45469..7d87abcc4 100644 --- a/salome_adm/cmake_files/FindLIBXML2.cmake +++ b/salome_adm/cmake_files/FindLIBXML2.cmake @@ -19,25 +19,129 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(LIBXML2_ROOT $ENV{LIBXML2_ROOT}) -IF(LIBXML2_ROOT) - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/parser.h ${LIBXML2_ROOT}/include) - FIND_LIBRARY(LIBXML2_LIBS libxml2 ${LIBXML2_ROOT}/lib) -ELSE(LIBXML2_ROOT) - FIND_PATH(LIBXML2_INCLUDE_DIR libxml/parser.h /usr/include/libxml2) - FIND_LIBRARY(LIBXML2_LIBS xml2 /usr/lib) -ENDIF(LIBXML2_ROOT) - -SET(LIBXML2_INCLUDES -I${LIBXML2_INCLUDE_DIR}) - -SET(ICONV_ROOT $ENV{ICONV_ROOT}) -IF(ICONV_ROOT) - FIND_PATH(ICONV_INCLUDE_DIR iconv.h ${ICONV_ROOT}/include) - FIND_LIBRARY(ICONV_LIBS iconv ${ICONV_ROOT}/lib) - SET(LIBXML2_INCLUDES ${LIBXML2_INCLUDES} -I${ICONV_INCLUDE_DIR}) - SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${ICONV_LIBS}) -ENDIF(ICONV_ROOT) - -SET(LIBXML_INCLUDES ${LIBXML2_INCLUDES}) -SET(LIBXML_CPPFLAGS ${LIBXML2_INCLUDES}) -SET(LIBXML_LIBS ${LIBXML2_LIBS}) +# ------ + +MESSAGE(STATUS "Check for libxml2 ...") + +# ------ + +IF(LIBXML2_IS_MANDATORY STREQUAL 0) + SET(LIBXML2_IS_MANDATORY 0) + SET(LIBXML2_IS_OPTIONAL 1) +ENDIF(LIBXML2_IS_MANDATORY STREQUAL 0) +IF(LIBXML2_IS_OPTIONAL STREQUAL 0) + SET(LIBXML2_IS_MANDATORY 1) + SET(LIBXML2_IS_OPTIONAL 0) +ENDIF(LIBXML2_IS_OPTIONAL STREQUAL 0) +IF(NOT LIBXML2_IS_MANDATORY AND NOT LIBXML2_IS_OPTIONAL) + SET(LIBXML2_IS_MANDATORY 1) + SET(LIBXML2_IS_OPTIONAL 0) +ENDIF(NOT LIBXML2_IS_MANDATORY AND NOT LIBXML2_IS_OPTIONAL) + +# ------ + +SET(LIBXML2_STATUS 1) +IF(WITHOUT_LIBXML2 OR WITH_LIBXML2 STREQUAL 0) + SET(LIBXML2_STATUS 0) + MESSAGE(STATUS "libxml2 disabled from command line.") +ENDIF(WITHOUT_LIBXML2 OR WITH_LIBXML2 STREQUAL 0) + +# ------ + +IF(LIBXML2_STATUS) + IF(WITH_LIBXML2) + SET(LIBXML2_ROOT_USER ${WITH_LIBXML2}) + ELSE(WITH_LIBXML2) + SET(LIBXML2_ROOT_USER $ENV{LIBXML2_ROOT}) + ENDIF(WITH_LIBXML2) +ENDIF(LIBXML2_STATUS) + +# ----- + +IF(LIBXML2_STATUS) + IF(LIBXML2_ROOT_USER) + SET(LIBXML2_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(LIBXML2_ROOT_USER) + SET(LIBXML2_FIND_PATHS_OPTION) + ENDIF(LIBXML2_ROOT_USER) +ENDIF(LIBXML2_STATUS) + +# ----- + +IF(LIBXML2_STATUS) + IF(LIBXML2_ROOT_USER) + SET(LIBXML2_INCLUDE_PATHS ${LIBXML2_ROOT_USER}/include) + ELSE(LIBXML2_ROOT_USER) + SET(LIBXML2_INCLUDE_PATHS /usr/include/libxml2) + ENDIF(LIBXML2_ROOT_USER) + SET(LIBXML2_INCLUDE_TO_FIND libxml/parser.h) + FIND_PATH(LIBXML2_INCLUDE_DIR ${LIBXML2_INCLUDE_TO_FIND} PATHS ${LIBXML2_INCLUDE_PATHS} ${LIBXML2_FIND_PATHS_OPTION}) + IF(LIBXML2_INCLUDE_DIR) + SET(LIBXML2_INCLUDES -I${LIBXML2_INCLUDE_DIR}) + MESSAGE(STATUS "${LIBXML2_INCLUDE_TO_FIND} found in ${LIBXML2_INCLUDE_DIR}") + ELSE(LIBXML2_INCLUDE_DIR) + SET(LIBXML2_STATUS 0) + IF(LIBXML2_ROOT_USER) + MESSAGE(STATUS "${LIBXML2_INCLUDE_TO_FIND} not found in ${LIBXML2_INCLUDE_PATHS}, check your LIBXML2 installation.") + ELSE(LIBXML2_ROOT_USER) + MESSAGE(STATUS "${LIBXML2_INCLUDE_TO_FIND} not found on system, try to use WITH_LIBXML2 option or LIBXML2_ROOT environment variable.") + ENDIF(LIBXML2_ROOT_USER) + ENDIF(LIBXML2_INCLUDE_DIR) +ENDIF(LIBXML2_STATUS) + +# ---- + +IF(LIBXML2_STATUS) + IF(LIBXML2_ROOT_USER) + SET(LIBXML2_LIB_PATHS ${LIBXML2_ROOT_USER}/lib) + ELSE(LIBXML2_ROOT_USER) + SET(LIBXML2_LIB_PATHS) + ENDIF(LIBXML2_ROOT_USER) +ENDIF(LIBXML2_STATUS) + +IF(LIBXML2_STATUS) + IF(WINDOWS) + FIND_LIBRARY(LIBXML2_LIB libxml2 PATHS ${LIBXML2_LIB_PATHS} ${LIBXML2_FIND_PATHS_OPTION}) + ELSE(WINDOWS) + FIND_LIBRARY(LIBXML2_LIB xml2 PATHS ${LIBXML2_LIB_PATHS} ${LIBXML2_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(LIBXML2_LIBS) + IF(LIBXML2_LIB) + SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${LIBXML2_LIB}) + MESSAGE(STATUS "libxml2 lib found: ${LIBXML2_LIB}") + ELSE(LIBXML2_LIB) + SET(LIBXML2_STATUS 0) + IF(LIBXML2_ROOT_USER) + MESSAGE(STATUS "libxml2 lib not found in ${LIBXML2_LIB_PATHS}, check your LIBXML2 installation.") + ELSE(LIBXML2_ROOT_USER) + MESSAGE(STATUS "libxml2 lib not found on system, try to use WITH_LIBXML2 option or LIBXML2_ROOT environment variable.") + ENDIF(LIBXML2_ROOT_USER) + ENDIF(LIBXML2_LIB) +ENDIF(LIBXML2_STATUS) + +# ---- + +IF(WINDOWS) + SET(ICONV_ROOT $ENV{ICONV_ROOT}) + IF(ICONV_ROOT) + FIND_PATH(ICONV_INCLUDE_DIR iconv.h ${ICONV_ROOT}/include) + FIND_LIBRARY(ICONV_LIBS iconv ${ICONV_ROOT}/lib) + SET(LIBXML2_INCLUDES ${LIBXML2_INCLUDES} -I${ICONV_INCLUDE_DIR}) + SET(LIBXML2_LIBS ${LIBXML2_LIBS} ${ICONV_LIBS}) + ENDIF(ICONV_ROOT) +ENDIF(WINDOWS) + +# ------ +IF(LIBXML2_STATUS) + SET(LIBXML_INCLUDES ${LIBXML2_INCLUDES}) + SET(LIBXML_CPPFLAGS ${LIBXML2_INCLUDES}) + SET(LIBXML_LIBS ${LIBXML2_LIBS}) +ELSE(LIBXML2_STATUS) + IF(LIBXML2_IS_MANDATORY) + MESSAGE(FATAL_ERROR "libxml2 not found ... mandatory ... abort") + ELSE(LIBXML2_IS_MANDATORY) + MESSAGE(STATUS "libxml2 not found ... optional ... disabled") + ENDIF(LIBXML2_IS_MANDATORY) +ENDIF(LIBXML2_STATUS) + +# ------ diff --git a/salome_adm/cmake_files/FindOMNIORB.cmake b/salome_adm/cmake_files/FindOMNIORB.cmake index f9cd2d618..e8a1c70fc 100644 --- a/salome_adm/cmake_files/FindOMNIORB.cmake +++ b/salome_adm/cmake_files/FindOMNIORB.cmake @@ -19,94 +19,220 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -# ----- - -FIND_PROGRAM(OMNIORB_IDL omniidl) - -# ----- - -IF(OMNIORB_IDL) - SET(CORBA_GEN 1) -ELSE(OMNIORB_IDL) - SET(CORBA_GEN 0) -ENDIF(OMNIORB_IDL) - -# ----- - -SET(OMNIORB_ROOT ${OMNIORB_IDL}) -GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) -IF(WINDOWS) - GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) -ENDIF(WINDOWS) -GET_FILENAME_COMPONENT(OMNIORB_ROOT ${OMNIORB_ROOT} PATH) - -# ---- - -FIND_PATH(OMNIORB_INC1 - NAMES omniORB4/CORBA.h - PATHS ${OMNIORB_ROOT}/include - ) -FIND_PATH(OMNIORB_INC2 - NAMES CORBA.h - PATHS ${OMNIORB_ROOT}/include/omniORB4 - ) - -SET(OMNIORB_INCLUDES -I${OMNIORB_INC1} -I${OMNIORB_INC2}) -SET(CORBA_INCLUDES ${OMNIORB_INCLUDES}) +# ------ + +MESSAGE(STATUS "Check for omniorb ...") + +# ------ + +IF(OMNIORB_IS_MANDATORY STREQUAL 0) + SET(OMNIORB_IS_MANDATORY 0) + SET(OMNIORB_IS_OPTIONAL 1) +ENDIF(OMNIORB_IS_MANDATORY STREQUAL 0) +IF(OMNIORB_IS_OPTIONAL STREQUAL 0) + SET(OMNIORB_IS_MANDATORY 1) + SET(OMNIORB_IS_OPTIONAL 0) +ENDIF(OMNIORB_IS_OPTIONAL STREQUAL 0) +IF(NOT OMNIORB_IS_MANDATORY AND NOT OMNIORB_IS_OPTIONAL) + SET(OMNIORB_IS_MANDATORY 1) + SET(OMNIORB_IS_OPTIONAL 0) +ENDIF(NOT OMNIORB_IS_MANDATORY AND NOT OMNIORB_IS_OPTIONAL) + +# ------ + +SET(OMNIORB_STATUS 1) +IF(WITHOUT_OMNIORB OR WITH_OMNIORB STREQUAL 0) + SET(OMNIORB_STATUS 0) + MESSAGE(STATUS "omniorb disabled from command line.") +ENDIF(WITHOUT_OMNIORB OR WITH_OMNIORB STREQUAL 0) + +# ------ + +IF(OMNIORB_STATUS) + IF(WITH_OMNIORB) + SET(OMNIORB_ROOT_USER ${WITH_OMNIORB}) + ENDIF(WITH_OMNIORB) + IF(NOT OMNIORB_ROOT_USER) + SET(OMNIORB_ROOT_USER $ENV{OMNIORB_ROOT}) + ENDIF(NOT OMNIORB_ROOT_USER) + IF(NOT OMNIORB_ROOT_USER) + SET(OMNIORB_ROOT_USER $ENV{OMNIORBHOME}) + ENDIF(NOT OMNIORB_ROOT_USER) +ENDIF(OMNIORB_STATUS) + +# ------ + +IF(OMNIORB_STATUS) + SET(OMNIIDL_EXECUTABLE_TO_FIND omniidl) + IF(OMNIORB_ROOT_USER) + FIND_PROGRAM(OMNIIDL_EXECUTABLE ${OMNIIDL_EXECUTABLE_TO_FIND} PATHS ${OMNIORB_ROOT_USER}/bin) + ELSE(OMNIORB_ROOT_USER) + FIND_PROGRAM(OMNIIDL_EXECUTABLE ${OMNIIDL_EXECUTABLE_TO_FIND}) + ENDIF(OMNIORB_ROOT_USER) + IF(OMNIIDL_EXECUTABLE) + MESSAGE(STATUS "${OMNIIDL_EXECUTABLE_TO_FIND} found: ${OMNIIDL_EXECUTABLE}") + IF(OMNIORB_EXECUTABLE STREQUAL /usr/bin/${OMNIIDL_EXECUTABLE_TO_FIND}) + ELSE(OMNIORB_EXECUTABLE STREQUAL /usr/bin/${OMNIIDL_EXECUTABLE_TO_FIND}) + SET(OMNIORB_ROOT_USER ${OMNIIDL_EXECUTABLE}) + GET_FILENAME_COMPONENT(OMNIORB_ROOT_USER ${OMNIORB_ROOT_USER} PATH) + IF(WINDOWS) + GET_FILENAME_COMPONENT(OMNIORB_ROOT_USER ${OMNIORB_ROOT_USER} PATH) + ENDIF(WINDOWS) + GET_FILENAME_COMPONENT(OMNIORB_ROOT_USER ${OMNIORB_ROOT_USER} PATH) + ENDIF(OMNIORB_EXECUTABLE STREQUAL /usr/bin/${OMNIIDL_EXECUTABLE_TO_FIND}) + ELSE(OMNIIDL_EXECUTABLE) + MESSAGE(STATUS "${OMNIIDL_EXECUTABLE_TO_FIND} not found, try to use WITH_OMNIORB option or OMNIORBHOME environment variable") + SET(OMNIORB_STATUS 0) + ENDIF(OMNIIDL_EXECUTABLE) +ENDIF(OMNIORB_STATUS) + +# ------ + +IF(OMNIORB_STATUS) + IF(OMNIORB_ROOT_USER) + SET(OMNIORB_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(OMNIORB_ROOT_USER) + SET(OMNIORB_FIND_PATHS_OPTION) + ENDIF(OMNIORB_ROOT_USER) +ENDIF(OMNIORB_STATUS) + +# ------ + +IF(OMNIORB_STATUS) + SET(OMNIORB_INCLUDES) +ENDIF(OMNIORB_STATUS) +IF(OMNIORB_STATUS) + IF(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_PATHS ${OMNIORB_ROOT_USER}/include) + ELSE(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_PATHS) + ENDIF(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_TO_FIND omniORB4/CORBA.h) + FIND_PATH(OMNIORB_INCLUDE_DIR1 ${OMNIORB_INCLUDE_TO_FIND} PATHS ${OMNIORB_INCLUDE_PATHS} ${OMNIORB_FIND_PATHS_OPTION}) + IF(OMNIORB_INCLUDE_DIR1) + SET(OMNIORB_INCLUDES ${OMNIORB_INCLUDES} -I${OMNIORB_INCLUDE_DIR1}) + MESSAGE(STATUS "${OMNIORB_INCLUDE_TO_FIND} found in ${OMNIORB_INCLUDE_DIR1}") + ELSE(OMNIORB_INCLUDE_DIR1) + SET(OMNIORB_STATUS 0) + IF(OMNIORB_ROOT_USER) + MESSAGE(STATUS "${OMNIORB_INCLUDE_TO_FIND} not found in ${OMNIORB_INCLUDE_PATHS}, check your OMNIORB installation.") + ELSE(OMNIORB_ROOT_USER) + MESSAGE(STATUS "${OMNIORB_INCLUDE_TO_FIND} not found on system, try to use WITH_OMNIORB option or OMNIORB_ROOT environment variable.") + ENDIF(OMNIORB_ROOT_USER) + ENDIF(OMNIORB_INCLUDE_DIR1) +ENDIF(OMNIORB_STATUS) +IF(OMNIORB_STATUS) + IF(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_PATHS ${OMNIORB_ROOT_USER}/include/omniORB4) + ELSE(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_PATHS /usr/include/omniORB4) + ENDIF(OMNIORB_ROOT_USER) + SET(OMNIORB_INCLUDE_TO_FIND CORBA.h) + FIND_PATH(OMNIORB_INCLUDE_DIR2 ${OMNIORB_INCLUDE_TO_FIND} PATHS ${OMNIORB_INCLUDE_PATHS} ${OMNIORB_FIND_PATHS_OPTION}) + IF(OMNIORB_INCLUDE_DIR2) + SET(OMNIORB_INCLUDES ${OMNIORB_INCLUDES} -I${OMNIORB_INCLUDE_DIR2}) + MESSAGE(STATUS "${OMNIORB_INCLUDE_TO_FIND} found in ${OMNIORB_INCLUDE_DIR2}") + ELSE(OMNIORB_INCLUDE_DIR2) + SET(OMNIORB_STATUS 0) + MESSAGE(STATUS "${OMNIORB_INCLUDE_TO_FIND} not found in ${OMNIORB_INCLUDE_PATHS}, check your OMNIORB installation.") + ENDIF(OMNIORB_INCLUDE_DIR2) +ENDIF(OMNIORB_STATUS) + +# ------ + +IF(OMNIORB_STATUS) + SET(OMNIORB_CXXFLAGS) + # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -DOMNIORB_VERSION=4) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__x86__) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -DCOMP_CORBA_DOUBLE) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -DCOMP_CORBA_LONG) + IF(WINDOWS) + SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__WIN32__) + # # # # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D_WIN32_WINNT=0x0400) + # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__NT__) + # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__OSVERSION__=4) + # ELSE(WINDOWS) + # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__linux__) + ENDIF(WINDOWS) + # IF(WINDOWS) + # SET(OMNIORB_LIBS ws2_32.lib mswsock.lib advapi32.lib ${OMNIORB_LIBS}) + # ENDIF(WINDOWS) +ENDIF(OMNIORB_STATUS) # ---- -SET(OMNIORB_CXXFLAGS) -SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -DOMNIORB_VERSION=4) -SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__x86__) - -IF(WINDOWS) - SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__WIN32__) - # # # SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D_WIN32_WINNT=0x0400) - SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__NT__) - SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__OSVERSION__=4) -ELSE(WINDOWS) - SET(OMNIORB_CXXFLAGS ${OMNIORB_CXXFLAGS} -D__linux__) -ENDIF(WINDOWS) - -SET(CORBA_CXXFLAGS ${OMNIORB_CXXFLAGS}) - -# ---- - -IF(WINDOWS) - FIND_LIBRARY(lib_omniORB4 omniORB4_rtd ${OMNIORB_ROOT}/lib/x86_win32) - FIND_LIBRARY(lib_omniDynamic4 omniDynamic4_rtd ${OMNIORB_ROOT}/lib/x86_win32) - FIND_LIBRARY(lib_COS4 COS4_rtd ${OMNIORB_ROOT}/lib/x86_win32) - FIND_LIBRARY(lib_COSDynamic4 COSDynamic4_rtd ${OMNIORB_ROOT}/lib/x86_win32) - FIND_LIBRARY(lib_omnithread omnithread_rtd ${OMNIORB_ROOT}/lib/x86_win32) -ELSE(WINDOWS) - FIND_LIBRARY(lib_omniORB4 omniORB4 ${OMNIORB_ROOT}/lib) - FIND_LIBRARY(lib_omniDynamic4 omniDynamic4 ${OMNIORB_ROOT}/lib) - FIND_LIBRARY(lib_COS4 COS4 ${OMNIORB_ROOT}/lib) - FIND_LIBRARY(lib_COSDynamic4 COSDynamic4 ${OMNIORB_ROOT}/lib) - FIND_LIBRARY(lib_omnithread omnithread ${OMNIORB_ROOT}/lib) -ENDIF(WINDOWS) - -SET(OMNIORB_LIBS ${lib_omniORB4} ${lib_omniDynamic4} ${lib_COS4} ${lib_COSDynamic4} ${lib_omnithread}) -IF(WINDOWS) - SET(OMNIORB_LIBS ws2_32.lib mswsock.lib advapi32.lib ${OMNIORB_LIBS}) -ENDIF(WINDOWS) - -SET(CORBA_LIBS ${OMNIORB_LIBS}) +IF(OMNIORB_STATUS) + IF(OMNIORB_ROOT_USER) + IF(WINDOWS) + SET(OMNIORB_LIB_PATHS ${OMNIORB_ROOT_USER}/lib/x86_win32) + ELSE(WINDOWS) + SET(OMNIORB_LIB_PATHS ${OMNIORB_ROOT_USER}/lib) + ENDIF(WINDOWS) + ELSE(OMNIORB_ROOT_USER) + SET(OMNIORB_LIB_PATHS) + ENDIF(OMNIORB_ROOT_USER) +ENDIF(OMNIORB_STATUS) + +IF(OMNIORB_STATUS) + IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + SET(OMNIORB_LIB_SUFFIX _rt) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + SET(OMNIORB_LIB_SUFFIX _rtd) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(WINDOWS) + SET(OMNIORB_LIB_SUFFIX) + ENDIF(WINDOWS) +ENDIF(OMNIORB_STATUS) + +SET(OMNIORB_LIBS) +FOREACH(lib omniORB4 omniDynamic4 COS4 COSDynamic4 omnithread) + IF(OMNIORB_STATUS) + FIND_LIBRARY(${lib}${OMNIORB_LIB_SUFFIX} ${lib}${OMNIORB_LIB_SUFFIX} PATHS ${OMNIORB_LIB_PATHS} ${OMNIORB_FIND_PATHS_OPTION}) + IF(${lib}${OMNIORB_LIB_SUFFIX}) + SET(OMNIORB_LIBS ${OMNIORB_LIBS} ${${lib}${OMNIORB_LIB_SUFFIX}}) + MESSAGE(STATUS "${lib}${OMNIORB_LIB_SUFFIX} lib found: ${${lib}${OMNIORB_LIB_SUFFIX}}") + ELSE(${lib}${OMNIORB_LIB_SUFFIX}) + SET(OMNIORB_STATUS 0) + IF(OMNIORB_ROOT_USER) + MESSAGE(STATUS "${lib}${OMNIORB_LIB_SUFFIX} lib not found in ${OMNIORB_LIB_PATHS}, check your OMNIORB installation.") + ELSE(OMNIORB_ROOT_USER) + MESSAGE(STATUS "${lib}${OMNIORB_LIB_SUFFIX} lib not found on system, try to use WITH_OMNIORB option or OMNIORB_ROOT environment variable.") + ENDIF(OMNIORB_ROOT_USER) + ENDIF(${lib}${OMNIORB_LIB_SUFFIX}) + ENDIF(OMNIORB_STATUS) +ENDFOREACH(lib omniORB4 omniDynamic4 COS4 COSDynamic4 omnithread) # ---------------- -SET(OMNIORB_IDL_PYTHON $ENV{OMNIIDL_PYTHON}) -IF(NOT OMNIORB_IDL_PYTHON) - SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL}) -ENDIF(NOT OMNIORB_IDL_PYTHON) +IF(OMNIORB_STATUS) + SET(OMNIORB_IDL_PYTHON $ENV{OMNIIDL_PYTHON}) + IF(NOT OMNIORB_IDL_PYTHON) + SET(OMNIORB_IDL_PYTHON ${OMNIIDL_EXECUTABLE}) + ENDIF(NOT OMNIORB_IDL_PYTHON) +ENDIF(OMNIORB_STATUS) -# ---------------- +# ---- -SET(IDL_CLN_H .hh) -SET(IDL_SRV_H .hh) +IF(OMNIORB_STATUS) + SET(CORBA_GEN 1) + SET(OMNIORB_IDL ${OMNIIDL_EXECUTABLE}) + SET(CORBA_INCLUDES ${OMNIORB_INCLUDES}) + SET(CORBA_CXXFLAGS ${OMNIORB_CXXFLAGS}) + SET(CORBA_LIBS ${OMNIORB_LIBS}) + SET(OMNIORB_IDLCXXFLAGS -Wba -nf) + SET(OMNIORB_IDLPYFLAGS -bpython) + SET(IDLCXXFLAGS ${OMNIORB_IDLCXXFLAGS}) + SET(IDLPYFLAGS ${OMNIORB_IDLPYFLAGS}) + SET(IDL_CLN_H .hh) + SET(IDL_SRV_H .hh) +ELSE(OMNIORB_STATUS) + SET(CORBA_GEN 0) + IF(OMNIORB_IS_MANDATORY) + MESSAGE(FATAL_ERROR "omniorb not found ... mandatory ... abort") + ELSE(OMNIORB_IS_MANDATORY) + MESSAGE(STATUS "omniorb not found ... optional ... disabled") + ENDIF(OMNIORB_IS_MANDATORY) +ENDIF(OMNIORB_STATUS) -# SET(OMNIORB_IDLCXXFLAGS -Wba -nf) -# SET(OMNIORB_IDLPYFLAGS -bpython) -SET(IDLCXXFLAGS -Wba -nf) -SET(IDLPYFLAGS -bpython) +# ---- diff --git a/salome_adm/cmake_files/FindPLATFORM.cmake b/salome_adm/cmake_files/FindPLATFORM.cmake index 28fd28803..a753fb63a 100644 --- a/salome_adm/cmake_files/FindPLATFORM.cmake +++ b/salome_adm/cmake_files/FindPLATFORM.cmake @@ -19,6 +19,7 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # + MARK_AS_ADVANCED(ISSUE) FIND_FILE(ISSUE issue /etc) IF(ISSUE) @@ -29,36 +30,57 @@ 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_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) + +IF(NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE $ENV{CMAKE_BUILD_TYPE}) - IF(CMAKE_BUILD_TYPE STREQUAL Release) +ENDIF(NOT CMAKE_BUILD_TYPE) + +IF(CMAKE_BUILD_TYPE) + IF(WINDOWS) 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) + SET(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE STRING "compilation types" FORCE) + ELSE(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + SET(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") + SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ENDIF(WINDOWS) +ENDIF(CMAKE_BUILD_TYPE) +SET(PLATFORM_CPPFLAGS) +SET(PLATFORM_LDFLAGS) +SET(PLATFORM_LIBADD) 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) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} /W0) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DPPRO_NT) # For medfile + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_USE_MATH_DEFINES) # At least for MEDMEM + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Ws2_32.lib) + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Userenv.lib) # At least for GEOM suit +ELSE(WINDOWS) + SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} -ldl) ENDIF(WINDOWS) -## SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_) +# SET(PLATFORM_CPPFLAGS) +# # # 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(RM /bin/rm) +#ENDIF(WINDOWS) + +### SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -D_DEBUG_) + +##SET(RCP rcp) +##SET(RSH rsh) +##SET(RCP rcp) -#SET(RCP rcp) -#SET(RSH rsh) -#SET(RCP rcp) +## MESSAGE(FATAL_ERROR "ZZZZZZZ") diff --git a/salome_adm/cmake_files/FindPTHREADS.cmake b/salome_adm/cmake_files/FindPTHREADS.cmake index 514f2ed52..68e180a0d 100644 --- a/salome_adm/cmake_files/FindPTHREADS.cmake +++ b/salome_adm/cmake_files/FindPTHREADS.cmake @@ -19,15 +19,119 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -SET(PTHREADS_ROOT $ENV{PTHREADS_ROOT}) -IF(PTHREADS_ROOT) - FIND_PATH(PTHREADS_INCLUDE_DIR pthread.h ${PTHREADS_ROOT}/include) +# ------ + +MESSAGE(STATUS "Check for pthreads ...") + +# ------ + +IF(PTHREADS_IS_MANDATORY STREQUAL 0) + SET(PTHREADS_IS_MANDATORY 0) + SET(PTHREADS_IS_OPTIONAL 1) +ENDIF(PTHREADS_IS_MANDATORY STREQUAL 0) +IF(PTHREADS_IS_OPTIONAL STREQUAL 0) + SET(PTHREADS_IS_MANDATORY 1) + SET(PTHREADS_IS_OPTIONAL 0) +ENDIF(PTHREADS_IS_OPTIONAL STREQUAL 0) +IF(NOT PTHREADS_IS_MANDATORY AND NOT PTHREADS_IS_OPTIONAL) + SET(PTHREADS_IS_MANDATORY 1) + SET(PTHREADS_IS_OPTIONAL 0) +ENDIF(NOT PTHREADS_IS_MANDATORY AND NOT PTHREADS_IS_OPTIONAL) + +# ------ + +SET(PTHREADS_STATUS 1) +IF(WITHOUT_PTHREADS OR WITH_PTHREADS STREQUAL 0) + SET(PTHREADS_STATUS 0) + MESSAGE(STATUS "pthreads disabled from command line.") +ENDIF(WITHOUT_PTHREADS OR WITH_PTHREADS STREQUAL 0) + +# ------ + +IF(PTHREADS_STATUS) + IF(WITH_PTHREADS) + SET(PTHREADS_ROOT_USER ${WITH_PTHREADS}) + ELSE(WITH_PTHREADS) + SET(PTHREADS_ROOT_USER $ENV{PTHREADS_ROOT}) + ENDIF(WITH_PTHREADS) +ENDIF(PTHREADS_STATUS) + +# ----- + +IF(PTHREADS_STATUS) + IF(PTHREADS_ROOT_USER) + SET(PTHREADS_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(PTHREADS_ROOT_USER) + SET(PTHREADS_FIND_PATHS_OPTION) + ENDIF(PTHREADS_ROOT_USER) +ENDIF(PTHREADS_STATUS) + +# ----- + +IF(PTHREADS_STATUS) + IF(PTHREADS_ROOT_USER) + SET(PTHREADS_INCLUDE_PATHS ${PTHREADS_ROOT_USER}/include) + ELSE(PTHREADS_ROOT_USER) + SET(PTHREADS_INCLUDE_PATHS) + ENDIF(PTHREADS_ROOT_USER) + SET(PTHREADS_INCLUDE_TO_FIND pthread.h) + FIND_PATH(PTHREADS_INCLUDE_DIR ${PTHREADS_INCLUDE_TO_FIND} PATHS ${PTHREADS_INCLUDE_PATHS} ${PTHREADS_FIND_PATHS_OPTION}) IF(PTHREADS_INCLUDE_DIR) - SET(PTHREADS_INCLUDES -I${PTHREADS_INCLUDE_DIR}) + IF(PTHREADS_ROOT_USER) + SET(PTHREAD_CFLAGS -I${PTHREADS_INCLUDE_DIR}) + ENDIF(PTHREADS_ROOT_USER) + MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} found in ${PTHREADS_INCLUDE_DIR}") + ELSE(PTHREADS_INCLUDE_DIR) + SET(PTHREADS_STATUS 0) + IF(PTHREADS_ROOT_USER) + MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} not found in ${PTHREADS_INCLUDE_PATHS}, check your PTHREADS installation.") + ELSE(PTHREADS_ROOT_USER) + MESSAGE(STATUS "${PTHREADS_INCLUDE_TO_FIND} not found on system, try to use WITH_PTHREADS option or PTHREADS_ROOT environment variable.") + ENDIF(PTHREADS_ROOT_USER) ENDIF(PTHREADS_INCLUDE_DIR) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(PTHREADS_LIBRARY pthreadVSE2 ${PTHREADS_ROOT}/lib) - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(PTHREADS_LIBRARY pthreadVSE2d ${PTHREADS_ROOT}/lib) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ENDIF(PTHREADS_ROOT) +ENDIF(PTHREADS_STATUS) + +# ---- + +IF(PTHREADS_STATUS) + IF(PTHREADS_ROOT_USER) + SET(PTHREADS_LIB_PATHS ${PTHREADS_ROOT_USER}/lib) + ELSE(PTHREADS_ROOT_USER) + SET(PTHREADS_LIB_PATHS) + ENDIF(PTHREADS_ROOT_USER) +ENDIF(PTHREADS_STATUS) + +IF(PTHREADS_STATUS) + IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PTHREAD_LIB pthreadVSE2 pthreadVC2 PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION}) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PTHREAD_LIB pthreadVSE2d pthreadVC2d PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION}) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(WINDOWS) + FIND_LIBRARY(PTHREAD_LIB pthread PATHS ${PTHREADS_LIB_PATHS} ${PTHREADS_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(PTHREAD_LIBS) + IF(PTHREAD_LIB) + SET(PTHREAD_LIBS ${PTHREAD_LIBS} ${PTHREAD_LIB}) + MESSAGE(STATUS "pthread lib found: ${PTHREAD_LIB}") + ELSE(PTHREAD_LIB) + SET(PTHREADS_STATUS 0) + IF(PTHREADS_ROOT_USER) + MESSAGE(STATUS "pthread lib not found in ${PTHREADS_LIB_PATHS}, check your PTHREADS installation.") + ELSE(PTHREADS_ROOT_USER) + MESSAGE(STATUS "pthread lib not found on system, try to use WITH_PTHREADS option or PTHREADS_ROOT environment variable.") + ENDIF(PTHREADS_ROOT_USER) + ENDIF(PTHREAD_LIB) +ENDIF(PTHREADS_STATUS) + +# ---- + +IF(PTHREADS_STATUS) +ELSE(PTHREADS_STATUS) + IF(PTHREADS_IS_MANDATORY) + MESSAGE(FATAL_ERROR "pthreads not found ... mandatory ... abort") + ELSE(PTHREADS_IS_MANDATORY) + MESSAGE(STATUS "pthreads not found ... optional ... disabled") + ENDIF(PTHREADS_IS_MANDATORY) +ENDIF(PTHREADS_STATUS) diff --git a/salome_adm/cmake_files/FindPYTHON.cmake b/salome_adm/cmake_files/FindPYTHON.cmake index d97820a0a..a03b563a4 100644 --- a/salome_adm/cmake_files/FindPYTHON.cmake +++ b/salome_adm/cmake_files/FindPYTHON.cmake @@ -19,44 +19,190 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -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) -ENDIF(WINDOWS) - -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}) - -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) - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION_WITHOUT_DOT}_d ${PYTHON_ROOT}/libs) - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) -ELSE(WINDOWS) - FIND_LIBRARY(PYTHON_LIBRARIES python${PYTHON_VERSION} ${PYTHON_ROOT}/lib) -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) +# ------ + +MESSAGE(STATUS "Check for python ...") + +# ------ + +IF(PYTHON_IS_MANDATORY STREQUAL 0) + SET(PYTHON_IS_MANDATORY 0) + SET(PYTHON_IS_OPTIONAL 1) +ENDIF(PYTHON_IS_MANDATORY STREQUAL 0) +IF(PYTHON_IS_OPTIONAL STREQUAL 0) + SET(PYTHON_IS_MANDATORY 1) + SET(PYTHON_IS_OPTIONAL 0) +ENDIF(PYTHON_IS_OPTIONAL STREQUAL 0) +IF(NOT PYTHON_IS_MANDATORY AND NOT PYTHON_IS_OPTIONAL) + SET(PYTHON_IS_MANDATORY 1) + SET(PYTHON_IS_OPTIONAL 0) +ENDIF(NOT PYTHON_IS_MANDATORY AND NOT PYTHON_IS_OPTIONAL) + +# ------ + +SET(PYTHON_STATUS 1) +IF(WITHOUT_PYTHON OR WITH_PYTHON STREQUAL 0) + SET(PYTHON_STATUS 0) + MESSAGE(STATUS "python disabled from command line.") +ENDIF(WITHOUT_PYTHON OR WITH_PYTHON STREQUAL 0) + +# ------ + +IF(PYTHON_STATUS) + IF(WITH_PYTHON) + SET(PYTHON_ROOT_USER ${WITH_PYTHON}) + ENDIF(WITH_PYTHON) + IF(NOT PYTHON_ROOT_USER) + SET(PYTHON_ROOT_USER $ENV{PYTHON_ROOT}) + ENDIF(NOT PYTHON_ROOT_USER) + IF(NOT PYTHON_ROOT_USER) + SET(PYTHON_ROOT_USER $ENV{PYTHONHOME}) + ENDIF(NOT PYTHON_ROOT_USER) +ENDIF(PYTHON_STATUS) + +# ------ + +IF(PYTHON_STATUS) + IF(PYTHON_ROOT_USER) + SET(PYTHON_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(PYTHON_ROOT_USER) + SET(PYTHON_FIND_PATHS_OPTION) + ENDIF(PYTHON_ROOT_USER) +ENDIF(PYTHON_STATUS) + +# ------ + +IF(PYTHON_STATUS) + IF(WINDOWS) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + SET(PYTHON_EXECUTABLE_TO_FIND python) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + SET(PYTHON_EXECUTABLE_TO_FIND python_d) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(WINDOWS) + SET(PYTHON_EXECUTABLE_TO_FIND python) + ENDIF(WINDOWS) + IF(NOT PYTHON_ROOT_USER) + SET(PYTHON_EXECUTABLE_PATHS) + ELSE(NOT PYTHON_ROOT_USER) + IF(WINDOWS) + SET(PYTHON_EXECUTABLE_PATHS ${PYTHON_ROOT_USER}) + ELSE(WINDOWS) + SET(PYTHON_EXECUTABLE_PATHS ${PYTHON_ROOT_USER}/bin) + ENDIF(WINDOWS) + ENDIF(NOT PYTHON_ROOT_USER) + FIND_PROGRAM(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE_TO_FIND} PATHS ${PYTHON_EXECUTABLE_PATHS} ${PYTHON_FIND_PATHS_OPTION}) + IF(PYTHON_EXECUTABLE) + MESSAGE(STATUS "python found: ${PYTHON_EXECUTABLE}") + IF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python) + ELSE(PYTHON_EXECUTABLE STREQUAL /usr/bin/python) + SET(PYTHON_ROOT_USER ${PYTHON_EXECUTABLE}) + GET_FILENAME_COMPONENT(PYTHON_ROOT_USER ${PYTHON_ROOT_USER} PATH) + IF(NOT WINDOWS) + GET_FILENAME_COMPONENT(PYTHON_ROOT_USER ${PYTHON_ROOT_USER} PATH) + ENDIF(NOT WINDOWS) + ENDIF(PYTHON_EXECUTABLE STREQUAL /usr/bin/python) + ELSE(PYTHON_EXECUTABLE) + IF(PYTHON_ROOT_USER) + MESSAGE(STATUS "${PYTHON_EXECUTABLE_TO_FIND} not found in ${PYTHON_EXECUTABLE_PATHS}, check your PYTHON installation.") + ELSE(PYTHON_ROOT_USER) + MESSAGE(STATUS "${PYTHON_EXECUTABLE_TO_FIND} not found on system, try to use WITH_PYTHON option or PYTHON_ROOT environment variable.") + ENDIF(PYTHON_ROOT_USER) + SET(PYTHON_STATUS 0) + ENDIF(PYTHON_EXECUTABLE) +ENDIF(PYTHON_STATUS) + +# ------ + +IF(PYTHON_STATUS) + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import sys; sys.stdout.write(sys.version[:3])" + OUTPUT_VARIABLE PYTHON_VERSION + ) +ENDIF(PYTHON_STATUS) + +# ------ + +IF(PYTHON_STATUS) + IF(PYTHON_ROOT_USER) + SET(PYTHON_FIND_PATHS_OPTION NO_DEFAULT_PATH) + ELSE(PYTHON_ROOT_USER) + SET(PYTHON_FIND_PATHS_OPTION) + ENDIF(PYTHON_ROOT_USER) +ENDIF(PYTHON_STATUS) + +# ------ + +IF(PYTHON_STATUS) + IF(PYTHON_ROOT_USER) + SET(PYTHON_INCLUDE_PATHS ${PYTHON_ROOT_USER}/include ${PYTHON_ROOT_USER}/include/python${PYTHON_VERSION}) + ELSE(PYTHON_ROOT_USER) + SET(PYTHON_INCLUDE_PATHS /usr/include/python${PYTHON_VERSION}) + ENDIF(PYTHON_ROOT_USER) + SET(PYTHON_INCLUDE_TO_FIND Python.h) + FIND_PATH(PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_TO_FIND} PATHS ${PYTHON_INCLUDE_PATHS} ${PYTHON_FIND_PATHS_OPTION}) + IF(PYTHON_INCLUDE_DIR) + SET(PYTHON_INCLUDES -I${PYTHON_INCLUDE_DIR}) + 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) + MESSAGE(STATUS "${PYTHON_INCLUDE_TO_FIND} found in ${PYTHON_INCLUDE_DIR}") + ELSE(PYTHON_INCLUDE_DIR) + SET(PYTHON_STATUS 0) + IF(PYTHON_ROOT_USER) + MESSAGE(STATUS "${PYTHON_INCLUDE_TO_FIND} not found in ${PYTHON_INCLUDE_PATHS}, check your PYTHON installation.") + ELSE(PYTHON_ROOT_USER) + MESSAGE(STATUS "${PYTHON_INCLUDE_TO_FIND} not found on system, try to use WITH_PYTHON option or PYTHON_ROOT environment variable.") + ENDIF(PYTHON_ROOT_USER) + ENDIF(PYTHON_INCLUDE_DIR) +ENDIF(PYTHON_STATUS) + +# ---- + +IF(PYTHON_STATUS) + IF(PYTHON_ROOT_USER) + IF(WINDOWS) + SET(PYTHON_LIB_PATHS ${PYTHON_ROOT_USER}/libs) + ELSE(WINDOWS) + SET(PYTHON_LIB_PATHS ${PYTHON_ROOT_USER}/lib ${PYTHON_ROOT_USER}/lib/python${PYTHON_VERSION}/config) + ENDIF(WINDOWS) + ELSE(PYTHON_ROOT_USER) + SET(PYTHON_LIB_PATHS) + ENDIF(PYTHON_ROOT_USER) + IF(WINDOWS) + STRING(REPLACE "." "" PYTHON_VERSION_WITHOUT_DOT ${PYTHON_VERSION}) + IF(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PYTHON_LIB python${PYTHON_VERSION_WITHOUT_DOT} PATHS ${PYTHON_LIB_PATHS} ${PYTHON_FIND_PATHS_OPTION}) + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + FIND_LIBRARY(PYTHON_LIB python${PYTHON_VERSION_WITHOUT_DOT}_d PATHS ${PYTHON_LIB_PATHS} ${PYTHON_FIND_PATHS_OPTION}) + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + ELSE(WINDOWS) + FIND_LIBRARY(PYTHON_LIB python${PYTHON_VERSION} PATHS ${PYTHON_LIB_PATHS} ${PYTHON_FIND_PATHS_OPTION}) + ENDIF(WINDOWS) + SET(PYTHON_LIBS) + IF(PYTHON_LIB) + SET(PYTHON_LIBS ${PYTHON_LIBS} ${PYTHON_LIB}) + MESSAGE(STATUS "python lib found: ${PYTHON_LIB}") + ELSE(PYTHON_LIB) + SET(PYTHON_STATUS 0) + IF(PYTHON_ROOT_USER) + MESSAGE(STATUS "python lib not found in ${PYTHON_LIB_PATHS}, check your PYTHON installation.") + ELSE(PYTHON_ROOT_USER) + MESSAGE(STATUS "python lib not found on system, try to use WITH_PYTHON option or PYTHON_ROOT environment variable.") + ENDIF(PYTHON_ROOT_USER) + ENDIF(PYTHON_LIB) +ENDIF(PYTHON_STATUS) + +# ---- + +IF(PYTHON_STATUS) +ELSE(PYTHON_STATUS) + IF(PYTHON_IS_MANDATORY) + MESSAGE(FATAL_ERROR "python not found ... mandatory ... abort") + ELSE(PYTHON_IS_MANDATORY) + MESSAGE(STATUS "python not found ... optional ... disabled") + ENDIF(PYTHON_IS_MANDATORY) +ENDIF(PYTHON_STATUS) diff --git a/salome_adm/cmake_files/FindSWIG.cmake b/salome_adm/cmake_files/FindSWIG.cmake index c6a9a4356..0545cfaa6 100644 --- a/salome_adm/cmake_files/FindSWIG.cmake +++ b/salome_adm/cmake_files/FindSWIG.cmake @@ -19,5 +19,74 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -FIND_PROGRAM(SWIG_EXECUTABLE swig) -SET(SWIG_FLAGS -c++ -python -shadow) +# ------ + +MESSAGE(STATUS "Check for swig ...") + +# ------ + +IF(SWIG_IS_MANDATORY STREQUAL 0) + SET(SWIG_IS_MANDATORY 0) + SET(SWIG_IS_OPTIONAL 1) +ENDIF(SWIG_IS_MANDATORY STREQUAL 0) +IF(SWIG_IS_OPTIONAL STREQUAL 0) + SET(SWIG_IS_MANDATORY 1) + SET(SWIG_IS_OPTIONAL 0) +ENDIF(SWIG_IS_OPTIONAL STREQUAL 0) +IF(NOT SWIG_IS_MANDATORY AND NOT SWIG_IS_OPTIONAL) + SET(SWIG_IS_MANDATORY 1) + SET(SWIG_IS_OPTIONAL 0) +ENDIF(NOT SWIG_IS_MANDATORY AND NOT SWIG_IS_OPTIONAL) + +# ------ + +SET(SWIG_STATUS 1) +IF(WITHOUT_SWIG OR WITH_SWIG STREQUAL 0) + SET(SWIG_STATUS 0) + MESSAGE(STATUS "swig disabled from command line.") +ENDIF(WITHOUT_SWIG OR WITH_SWIG STREQUAL 0) + +# ------ + +IF(SWIG_STATUS) + IF(WITH_SWIG) + SET(SWIG_ROOT_USER ${WITH_SWIG}) + ENDIF(WITH_SWIG) + IF(NOT SWIG_ROOT_USER) + SET(SWIG_ROOT_USER $ENV{SWIG_ROOT}) + ENDIF(NOT SWIG_ROOT_USER) + IF(NOT SWIG_ROOT_USER) + SET(SWIG_ROOT_USER $ENV{SWIGHOME}) + ENDIF(NOT SWIG_ROOT_USER) +ENDIF(SWIG_STATUS) + +# ------ + +IF(SWIG_STATUS) + SET(SWIG_EXECUTABLE_TO_FIND swig) + IF(SWIG_ROOT_USER) + FIND_PROGRAM(SWIG_EXECUTABLE ${SWIG_EXECUTABLE_TO_FIND} PATHS ${SWIG_ROOT_USER}/bin NO_DEFAULT_PATH) + ELSE(SWIG_ROOT_USER) + FIND_PROGRAM(SWIG_EXECUTABLE ${SWIG_EXECUTABLE_TO_FIND}) + ENDIF(SWIG_ROOT_USER) + IF(SWIG_EXECUTABLE) + MESSAGE(STATUS "${SWIG_EXECUTABLE_TO_FIND} found: ${SWIG_EXECUTABLE}") + ELSE(SWIG_EXECUTABLE) + MESSAGE(STATUS "${SWIG_EXECUTABLE_TO_FIND} not found, try to use WITH_SWIG option or SWIG_ROOT (or SWIGHOME) environment variable") + SET(SWIG_STATUS 0) + ENDIF(SWIG_EXECUTABLE) +ENDIF(SWIG_STATUS) + +# ---- + +IF(SWIG_STATUS) + SET(SWIG_FLAGS -c++ -python -shadow) +ELSE(SWIG_STATUS) + IF(SWIG_IS_MANDATORY) + MESSAGE(FATAL_ERROR "swig not found ... mandatory ... abort") + ELSE(SWIG_IS_MANDATORY) + MESSAGE(STATUS "swig not found ... optional ... disabled") + ENDIF(SWIG_IS_MANDATORY) +ENDIF(SWIG_STATUS) + +# ---- diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am index 6da6dc213..740e93a23 100644 --- a/salome_adm/cmake_files/Makefile.am +++ b/salome_adm/cmake_files/Makefile.am @@ -33,4 +33,5 @@ FindPLATFORM.cmake \ FindPTHREADS.cmake \ FindPYTHON.cmake \ FindSWIG.cmake \ -install_python_from_idl.cmake +install_python_from_idl.cmake \ +install_and_compile_python_file.cmake diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index 31a7fd163..b0624ab09 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -124,16 +124,6 @@ class CMakeFile(object): # -- content = p_multiline.sub(r' ', content) - # -- - content = content.replace("-no-undefined -version-info=0:0:0", "") - content = content.replace("-include SALOMEconfig.h", "") - - # -- - # Compatibility medfile - # -- - content = content.replace("-no-undefined -version-info 0:0:0", "") - content = content.replace("-no-undefined -version-info 2:5:1", "") - # -- # Compatibility netgen plugin # -- @@ -352,10 +342,6 @@ class CMakeFile(object): full_list = cas_list + kernel_list + gui_list full_list += geom_list + med_list + smesh_list # -- - full_list += [ - "boost_thread", - ] - # -- # E.A. : sort by len before substitution ... # Why ? Thing to "-lMEDWrapper" then "-lMEDWrapper_V2_1" substition # And you understand ... @@ -405,15 +391,20 @@ class CMakeFile(object): self.finalize(newlines) # -- - # Add a last CR at the end of the file + # Concatenate newlines into content # -- - newlines.append('\n') + content = '\n'.join(newlines) # -- - # Concatenate newlines into content + # Add a CR at end if necessary # -- - content = '\n'.join(newlines) - + lines = content.split('\n') + # lines = [ l.strip() for l in lines ] + if len(lines[-1]) != 0: + lines.append('') + pass + content = '\n'.join(lines) + # -- self.content = content @@ -424,7 +415,7 @@ class CMakeFile(object): if self.root == self.the_root: # -- newlines.append(""" - CMAKE_MINIMUM_REQUIRED(VERSION 2.4) + CMAKE_MINIMUM_REQUIRED(VERSION 2.4.7 FATAL_ERROR) IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) @@ -526,8 +517,8 @@ class CMakeFile(object): newlines.append(""" SET(WITH_LOCAL 1) SET(WITH_BATCH 1) - set(VERSION 4.1.3) - set(XVERSION 0x040103) + set(VERSION 5.1.2) + set(XVERSION 0x050102) """) elif self.module == "gui": newlines.append(""" @@ -540,6 +531,8 @@ class CMakeFile(object): SET(ENABLE_PYCONSOLE ON) SET(ENABLE_SUPERVGRAPHVIEWER ON) # SET(ENABLE_QXGRAPHVIEWER ON) + set(VERSION 5.1.2) + set(XVERSION 0x050102) """) pass elif self.module == "geom": @@ -583,6 +576,8 @@ class CMakeFile(object): pass # -- newlines.append(""" + SET(VERSION_INFO 0.0.0) + SET(SOVERSION_INFO 0) SET(SUBDIRS) SET(AM_CPPFLAGS) SET(AM_CXXFLAGS) @@ -627,7 +622,7 @@ class CMakeFile(object): return # -- - # A particuliar case + # A particuliar case where there are two ":" on the same line # -- if line.find('install-exec-local:') == 0: newlines.append("# " + line) @@ -640,6 +635,25 @@ class CMakeFile(object): newlines.append("# " + line) return + # -- + # -- + key = "-version-info" + if line.find(key) >= 0: + # -- + before = line.split(key)[0] + after = line[len(before)+len(key):] + sep = after[0] + after = after[1:] + version_info = after.split()[0] + line = line.replace(key+sep+version_info, "") + # -- + version_info = version_info.replace(':', '.') + soversion_info = version_info.split('.')[0] + newlines.append("SET(VERSION_INFO " + version_info + ")") + newlines.append("SET(SOVERSION_INFO " + soversion_info + ")") + # -- + pass + # -- # Replace the $(TOTO) by ${TOTO} # Replace the @TOTO@ by ${TOTO} @@ -1030,14 +1044,6 @@ class CMakeFile(object): # -- newlines.append(r''' IF(WINDOWS) - SET(libadd ${libadd} Userenv.lib Ws2_32.lib) - ELSE(WINDOWS) - SET(libadd ${libadd} -ldl -lpthread) - ENDIF(WINDOWS) - ''') - # -- - newlines.append(r''' - IF(WINDOWS) SET(targets) SET(targets ${targets} MEFISTO2D) FOREACH(target ${targets}) @@ -1052,7 +1058,10 @@ class CMakeFile(object): ''') # -- newlines.append(r''' - SET(libs ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + IF(name STREQUAL SALOMEBasics) + SET(libs ${libs} ${PTHREAD_LIBS}) + ENDIF(name STREQUAL SALOMEBasics) ''') if key == "bin_PROGRAMS": newlines.append(r''' @@ -1067,54 +1076,42 @@ class CMakeFile(object): GET_FILENAME_COMPONENT(lib ${lib} NAME_WE) STRING(REPLACE "lib" "" lib ${lib}) ENDIF(ext STREQUAL .la) + SET(vars) + SET(vars ${vars} -no-undefined) IF(WINDOWS) - SET(vars -Xlinker -export-dynamic -module -Wl,-E) - SET(vars ${vars} -lutil -lm) + SET(vars ${vars} -module) + SET(vars ${vars} -Wl,-E) + SET(vars ${vars} -Xlinker) + SET(vars ${vars} -export-dynamic) + SET(vars ${vars} -lm) + SET(vars ${vars} -lboost_thread) + SET(vars ${vars} -lboost_signals) + SET(vars ${vars} -lvtkWidgets) + ENDIF(WINDOWS) FOREACH(v ${vars}) IF(lib STREQUAL v) SET(lib) ENDIF(lib STREQUAL v) ENDFOREACH(v ${vars}) - ENDIF(WINDOWS) SET(libadd ${libadd} ${lib}) ENDFOREACH(lib ${libs}) - TARGET_LINK_LIBRARIES(${name} ${PTHREADS_LIBRARY} ${libadd}) + TARGET_LINK_LIBRARIES(${name} ${libadd}) ''') # -- newlines.append(r''' IF(WINDOWS) SET(targets) - SET(targets ${targets} SalomeHDFPersist) - SET(targets ${targets} medC) - SET(targets ${targets} medimport) - SET(targets ${targets} medimportcxx) - FOREACH(target ${targets}) - IF(name STREQUAL ${target}) - IF(CMAKE_BUILD_TYPE STREQUAL Release) - SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMT") - ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD") - ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) - ENDIF(name STREQUAL ${target}) - ENDFOREACH(target ${targets}) - SET(targets) SET(targets ${targets} MEFISTO2D) FOREACH(target ${targets}) IF(name STREQUAL ${target}) + IF(CMAKE_BUILD_TYPE STREQUAL Debug) SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:MSVCRT") + ENDIF(CMAKE_BUILD_TYPE STREQUAL Debug) ENDIF(name STREQUAL ${target}) ENDFOREACH(target ${targets}) ENDIF(WINDOWS) ''') # -- - if self.module == "med": - newlines.append(r''' - IF(WINDOWS) - SET_TARGET_PROPERTIES(${name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:LIBCMTD") - ENDIF(WINDOWS) - ''') - pass - # -- return def setCompilationFlags(self, key, newlines): @@ -1124,6 +1121,7 @@ class CMakeFile(object): SET(targets) SET(targets ${targets} SalomeIDLKernel) SET(targets ${targets} SalomeDS) + SET(targets ${targets} SALOMEDSTest) SET(targets ${targets} SALOMEDS_Client_exe) SET(targets ${targets} SalomeIDLGEOM) SET(targets ${targets} GEOMEngine) @@ -1152,12 +1150,6 @@ class CMakeFile(object): ENDIF(WINDOWS) ''') # -- - newlines.append(r''' - IF(WINDOWS) - SET(var ${var} -D_USE_MATH_DEFINES) - ENDIF(WINDOWS) - ''') - # -- if self.module in ["geom", "med"]: newlines.append(r''' SET(var ${var} -I${CMAKE_CURRENT_SOURCE_DIR}) @@ -1172,12 +1164,22 @@ class CMakeFile(object): pass newlines.append(r''' SET(var ${var} ${PLATFORM_CPPFLAGS}) - SET(var ${var} ${PTHREADS_INCLUDES}) + SET(var ${var} ${PTHREAD_CFLAGS}) SET(var ${var} ${${amname}_CPPFLAGS}) SET(var ${var} ${${amname}_CXXFLAGS}) SET(var ${var} ${${amname}_CFLAGS}) + SET(vars) + IF(WINDOWS) + SET(vars ${vars} -include SALOMEconfig.h) + SET(vars ${vars} -ftemplate-depth-32) + ENDIF(WINDOWS) SET(flags) FOREACH(f ${var}) + FOREACH(v ${vars}) + IF(f STREQUAL v) + SET(f) + ENDIF(f STREQUAL v) + ENDFOREACH(v ${vars}) SET(flags "${flags} ${f}") ENDFOREACH(f ${var}) SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}") @@ -1271,14 +1273,21 @@ class CMakeFile(object): ENDIF(ext STREQUAL .f) SET(srcs ${srcs} ${src}) ENDFOREACH(src ${${amname}_SOURCES} ${dist_${amname}_SOURCES}) + ''') + newlines.append(r''' SET(build_srcs) - FOREACH(f ${nodist_${amname}_SOURCES} ${BUILT_SOURCES}) + ''') + newlines.append(r''' + SET(l ${nodist_${amname}_SOURCES} ${BUILT_SOURCES}) + ''') + newlines.append(r''' + FOREACH(f ${l}) GET_FILENAME_COMPONENT(ext ${f} EXT) IF(ext STREQUAL .py) ELSE(ext STREQUAL .py) SET(build_srcs ${build_srcs} ${CMAKE_CURRENT_BINARY_DIR}/${f}) ENDIF(ext STREQUAL .py) - ENDFOREACH(f ${nodist_${amname}_SOURCES}) + ENDFOREACH(f ${l}) SET(srcs ${build_srcs} ${srcs}) ''') # -- @@ -1293,150 +1302,7 @@ class CMakeFile(object): self.setCompilationFlags(key, newlines) # -- newlines.append(r''' - SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION 0.0.0 SOVERSION 0) - FOREACH(lib medC med) - IF(lib STREQUAL ${name}) - SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION 1.1.5 SOVERSION 1) - ENDIF(lib STREQUAL ${name}) - ENDFOREACH(lib medC med) - ''') - # -- - from os.path import basename - upper_name = basename(self.root).upper() - # -- - if upper_name in ["2.1.X", "2.3.1"]: - upper_name = "D_" + upper_name - pass - # -- - newlines.append(r''' - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL %s_EXPORTS) - '''%(upper_name)) - # -- - newlines.append(r''' - IF(name STREQUAL SalomeLauncher) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SALOME%s_EXPORTS) - ENDIF(name STREQUAL SalomeLauncher) - '''%(upper_name)) - newlines.append(r''' - IF(name STREQUAL SalomeResourcesManager) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SALOME%s_EXPORTS) - ENDIF(name STREQUAL SalomeResourcesManager) - '''%(upper_name)) - newlines.append(r''' - IF(name STREQUAL GEOMObject) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL GEOM_%s_EXPORTS) - ENDIF(name STREQUAL GEOMObject) - '''%(upper_name)) - newlines.append(r''' - IF(name STREQUAL medC) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDC_DLL_EXPORTS) - ENDIF(name STREQUAL medC) - ''') - newlines.append(r''' - IF(name STREQUAL med) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MED_DLL_EXPORTS) - ENDIF(name STREQUAL med) - ''') - newlines.append(r''' - IF(name STREQUAL medimport) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDIMPORT_DLL_EXPORTS) - ENDIF(name STREQUAL medimport) - ''') - newlines.append(r''' - IF(name STREQUAL medimportcxx) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDIMPORTCXX_DLL_EXPORTS) - ENDIF(name STREQUAL medimportcxx) - ''') - # -- - newlines.append(r''' - IF(name STREQUAL MEDWrapperBase) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDWRAPPER_BASE_EXPORTS) - ENDIF(name STREQUAL MEDWrapperBase) - ''') - newlines.append(r''' - IF(name STREQUAL MEDWrapper_V2_1) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDWRAPPER_V2_1_EXPORTS) - ENDIF(name STREQUAL MEDWrapper_V2_1) - ''') - newlines.append(r''' - IF(name STREQUAL med_V2_1) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDWRAPPER_V2_1_CORE_EXPORTS) - ENDIF(name STREQUAL med_V2_1) - ''') - newlines.append(r''' - IF(name STREQUAL MEDWrapper_V2_2) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDWRAPPER_V2_2_EXPORTS) - ENDIF(name STREQUAL MEDWrapper_V2_2) - ''') - newlines.append(r''' - IF(name STREQUAL MEDWrapper) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDWRAPPER_FACTORY_EXPORTS) - ENDIF(name STREQUAL MEDWrapper) - ''') - newlines.append(r''' - IF(name STREQUAL interpkernelbases) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL INTERPKERNELBASES_EXPORTS) - ENDIF(name STREQUAL interpkernelbases) - IF(name STREQUAL InterpGeometric2DAlg) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL INTERPKERNELGEOMETRIC2D_EXPORTS) - ENDIF(name STREQUAL InterpGeometric2DAlg) - IF(name STREQUAL interpkernel) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL INTERPKERNEL_EXPORTS) - ENDIF(name STREQUAL interpkernel) - IF(name STREQUAL MEDClientcmodule) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEDCLIENT_EXPORTS) - ENDIF(name STREQUAL MEDClientcmodule) - ''') - # -- - newlines.append(r''' - IF(name STREQUAL SMESHControls) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SMESHCONTROLS_EXPORTS) - ENDIF(name STREQUAL SMESHControls) - ''') - newlines.append(r''' - IF(name STREQUAL MeshDriver) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MESHDRIVER_EXPORTS) - ENDIF(name STREQUAL MeshDriver) - ''') - newlines.append(r''' - IF(name STREQUAL MeshDriverMED) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MESHDRIVERMED_EXPORTS) - ENDIF(name STREQUAL MeshDriverMED) - ''') - newlines.append(r''' - IF(name STREQUAL MeshDriverDAT) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MESHDRIVERDAT_EXPORTS) - ENDIF(name STREQUAL MeshDriverDAT) - ''') - newlines.append(r''' - IF(name STREQUAL MeshDriverUNV) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MESHDRIVERUNV_EXPORTS) - ENDIF(name STREQUAL MeshDriverUNV) - ''') - newlines.append(r''' - IF(name STREQUAL MeshDriverSTL) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MESHDRIVERSTL_EXPORTS) - ENDIF(name STREQUAL MeshDriverSTL) - ''') - newlines.append(r''' - IF(name STREQUAL MEFISTO2D) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL MEFISTO2D_EXPORTS) - ENDIF(name STREQUAL MEFISTO2D) - ''') - newlines.append(r''' - IF(name STREQUAL SMESHObject) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SMESHOBJECT_EXPORTS) - ENDIF(name STREQUAL SMESHObject) - ''') - newlines.append(r''' - IF(name STREQUAL _libSMESH_Swig) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL SMESH_SWIG_EXPORTS) - ENDIF(name STREQUAL _libSMESH_Swig) - ''') - newlines.append(r''' - IF(name STREQUAL NETGENPluginGUI) - SET_TARGET_PROPERTIES(${name} PROPERTIES DEFINE_SYMBOL NETGENPLUGIN_GUI_EXPORTS) - ENDIF(name STREQUAL NETGENPluginGUI) + SET_TARGET_PROPERTIES(${name} PROPERTIES VERSION ${VERSION_INFO} SOVERSION ${SOVERSION_INFO}) ''') # -- self.setLibAdd(key, newlines) @@ -1470,10 +1336,14 @@ class CMakeFile(object): ''') pass newlines.append(r''' - IF(name STREQUAL SalomePyQt) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION ${DEST} RENAME ${name}.so) - ENDIF(name STREQUAL SalomePyQt) + # IF(name STREQUAL SalomePyQt) + # INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so DESTINATION ${DEST} RENAME ${name}.so) + # ENDIF(name STREQUAL SalomePyQt) + ''') + newlines.append(r''' ELSE(BEGIN_WITH_lib) + ''') + newlines.append(r''' IF(WINDOWS) INSTALL(TARGETS ${name} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome) IF(CMAKE_BUILD_TYPE STREQUAL Release) @@ -1488,6 +1358,8 @@ class CMakeFile(object): INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so.${soversion}) INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so) ENDIF(WINDOWS) + ''') + newlines.append(r''' ENDIF(BEGIN_WITH_lib) ''') pass @@ -1607,6 +1479,33 @@ class CMakeFile(object): ENDIF(dummy) ENDIF(test_SALOMEconfig.h.in) ''') + newlines.append(r''' + GET_FILENAME_COMPONENT(ext ${f} EXT) + IF(ext STREQUAL .py) + INSTALL(CODE "SET(PYTHON_FILE ${f})") + INSTALL(CODE "SET(CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})") + INSTALL(CODE "SET(DEST ${DEST})") + INSTALL(CODE "SET(PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE})") + ''') + if self.module == "kernel": + newlines.append(''' + IF(f STREQUAL SALOME_ContainerPy.py) + ELSE(f STREQUAL SALOME_ContainerPy.py) + IF(f STREQUAL am2cmake.py) + ELSE(f STREQUAL am2cmake.py) + INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake) + ENDIF(f STREQUAL am2cmake.py) + ENDIF(f STREQUAL SALOME_ContainerPy.py) + ''') + else: + newlines.append(''' + STRING(REPLACE "\\\\" "/" KERNEL_ROOT_DIR ${KERNEL_ROOT_DIR}) + INSTALL(SCRIPT ${KERNEL_ROOT_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake) + ''') + pass + newlines.append(r''' + ENDIF(ext STREQUAL .py) + ''') newlines.append(r"ENDFOREACH(f ${%s})"%(key)) return @@ -1651,11 +1550,18 @@ if __name__ == "__main__": # from os import walk for root, dirs, files in walk(the_root): - from os.path import basename - if basename(root) == "CVS": continue + # -- + # E.A. : Remove 'CVS' in dirs + # E.A. : It allows to not recurse in CVS dirs + # E.A. : See os module python documentation + # -- + try: + dirs.remove('CVS') + except ValueError: + pass + # -- for f in files: - from os.path import basename - if basename(f) == "Makefile.am": + if f == "Makefile.am": convertAmFile(the_root, root, dirs, files, f, module) pass pass diff --git a/salome_adm/cmake_files/install_and_compile_python_file.cmake b/salome_adm/cmake_files/install_and_compile_python_file.cmake new file mode 100644 index 000000000..396d7821b --- /dev/null +++ b/salome_adm/cmake_files/install_and_compile_python_file.cmake @@ -0,0 +1,27 @@ +# 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 +# +SET(FULLDIR ${CMAKE_INSTALL_PREFIX}/${DEST}) +MESSAGE(STATUS "py compiling ${FULLDIR}/${PYTHON_FILE}") +SET(CMD "import py_compile ; py_compile.compile('${FULLDIR}/${PYTHON_FILE}')") +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "${CMD}") +SET(CMD "import py_compile ; py_compile.compile('${FULLDIR}/${PYTHON_FILE}')") +EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -O -c "${CMD}") diff --git a/salome_adm/unix/config_files/check_openmpi.m4 b/salome_adm/unix/config_files/check_openmpi.m4 index fe5957a2c..691a6b765 100644 --- a/salome_adm/unix/config_files/check_openmpi.m4 +++ b/salome_adm/unix/config_files/check_openmpi.m4 @@ -33,7 +33,7 @@ if test "$WITHOPENMPI" = yes; then OPENMPI_HOME=$withval if test "$OPENMPI_HOME"; then - MPI_INCLUDES=`$OPENMPI_HOME/bin/mpicxx --showme:compile` + MPI_INCLUDES="-I${OPENMPI_HOME}/include" MPI_LIBS=`$OPENMPI_HOME/bin/mpicxx --showme:link` fi diff --git a/src/Batch_SWIG/Makefile.am b/src/Batch_SWIG/Makefile.am index 3f4539a2b..2d18ed2e0 100644 --- a/src/Batch_SWIG/Makefile.am +++ b/src/Batch_SWIG/Makefile.am @@ -80,7 +80,12 @@ EXTRA_DIST = $(SWIGSOURCES) # # Scripts to be installed. -dist_salomescript_SCRIPTS = Batch_test.py +dist_salomescript_PYTHON = Batch_test.py # You don't need to specify libBatch_Swig.py. It is automatically # installed by means of the swig target salomepython_PYTHON. + +install-data-hook: + @for f in $(dist_salomescript_PYTHON) ; do \ + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/src/Communication/SALOME_Communication.hxx b/src/Communication/SALOME_Communication.hxx index 42a7392b3..c0c8eba5b 100755 --- a/src/Communication/SALOME_Communication.hxx +++ b/src/Communication/SALOME_Communication.hxx @@ -27,7 +27,7 @@ #define _SALOME_COMMIUNICATION_HXX_ #ifdef WIN32 -# ifdef COMMUNICATION_EXPORTS +# if defined COMMUNICATION_EXPORTS || defined SalomeCommunication_EXPORTS # define COMMUNICATION_EXPORT __declspec( dllexport ) # else # define COMMUNICATION_EXPORT __declspec( dllimport ) diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 7558ef37e..065c5b4b5 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -1371,3 +1371,47 @@ void SigIntHandler( int what ) } } #endif + +/*! \brief copy a file from a remote host (container) to the local host + * \param container the remote container + * \param remoteFile the file to copy locally from the remote host into localFile + * \param localFile the local file + */ +void Engines_Container_i::copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile) +{ + Engines::fileTransfer_var fileTransfer = container->getFileTransfer(); + + FILE* fp; + if ((fp = fopen(localFile,"wb")) == NULL) + { + INFOS("file " << localFile << " cannot be open for writing"); + return; + } + + CORBA::Long fileId = fileTransfer->open(remoteFile); + if (fileId > 0) + { + Engines::fileBlock* aBlock; + int toFollow = 1; + int ctr=0; + while (toFollow) + { + ctr++; + SCRUTE(ctr); + aBlock = fileTransfer->getBlock(fileId); + toFollow = aBlock->length(); + SCRUTE(toFollow); + CORBA::Octet *buf = aBlock->get_buffer(); + fwrite(buf, sizeof(CORBA::Octet), toFollow, fp); + delete aBlock; + } + fclose(fp); + MESSAGE("end of transfer"); + fileTransfer->close(fileId); + } + else + { + INFOS("open reference file for copy impossible"); + } +} + diff --git a/src/Container/Makefile.am b/src/Container/Makefile.am index 5f8172cff..4ba5af6cb 100644 --- a/src/Container/Makefile.am +++ b/src/Container/Makefile.am @@ -44,7 +44,7 @@ salomeinclude_HEADERS = \ Salome_file_i.hxx # Scripts to be installed -dist_salomescript_DATA =\ +dist_salomescript_PYTHON =\ SALOME_ComponentPy.py \ SALOME_Container.py @@ -162,3 +162,8 @@ TestSalome_file_LDADD =\ $(MPI_LIBS) \ $(CORBA_LIBS) \ $(PYTHON_LIBS) + +install-data-hook: + @for f in $(dist_salomescript_PYTHON) ; do \ + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index d00618fd2..939f53bdb 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -96,8 +96,8 @@ SALOME_ContainerManager::~SALOME_ContainerManager() } //============================================================================= +//! shutdown all the containers, then the ContainerManager servant /*! CORBA method: - * shutdown all the containers, then the ContainerManager servant */ //============================================================================= @@ -108,13 +108,11 @@ void SALOME_ContainerManager::Shutdown() _NS->Destroy_Name(_ContainerManagerNameInNS); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); - //_remove_ref() has already been done at creation - //_remove_ref(); } //============================================================================= +//! Loop on all the containers listed in naming service, ask shutdown on each /*! CORBA Method: - * Loop on all the containers listed in naming service, ask shutdown on each */ //============================================================================= @@ -134,7 +132,7 @@ void SALOME_ContainerManager::ShutdownContainers() { Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)) - lstCont.push_back((*iter)); + lstCont.push_back((*iter)); } catch(const CORBA::Exception& e) { @@ -151,7 +149,7 @@ void SALOME_ContainerManager::ShutdownContainers() Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)) { - MESSAGE("ShutdownContainers: " << (*iter)); + MESSAGE("ShutdownContainers: " << (*iter)); try { cont->Shutdown(); @@ -176,101 +174,105 @@ void SALOME_ContainerManager::ShutdownContainers() } //============================================================================= -//! Find a suitable Container in a list of machines, or start one +//! Give a suitable Container given constraints /*! CORBA Method: * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start + * \return the container or nil */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::GiveContainer(const Engines::MachineParameters& params) { - Engines::Container_ptr ret = FindContainer(params,possibleComputers); - if(!CORBA::is_nil(ret)) - return ret; - MESSAGE("Container doesn't exist try to launch it ..."); + char *valenv=getenv("SALOME_BATCH"); + if(valenv) + if (strcmp(valenv,"1")==0) + { + if(_batchLaunchedContainers.empty()) + fillBatchLaunchedContainers(); - return StartContainer(params,possibleComputers,Engines::P_FIRST); + if (_batchLaunchedContainersIter == _batchLaunchedContainers.end()) + _batchLaunchedContainersIter = _batchLaunchedContainers.begin(); + Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter); + _batchLaunchedContainersIter++; + return rtn; + } + return StartContainer(params); } //============================================================================= -//! Start a suitable Container in a list of machines with constraints and a policy +//! Start a suitable Container in a list of machines with constraints /*! C++ Method: * Constraints are given by a machine parameters struct * \param params Machine Parameters required for the container * \param possibleComputers list of machines usable for start - * \param policy policy to use (first,cycl or best) * \param container_exe specific container executable (default=SALOME_Container) */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -StartContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers, - Engines::ResPolicy policy,const std::string& container_exe) +SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params, + const Engines::MachineList& possibleComputers, + const std::string& container_exe) { #ifdef WITH_PACO_PARALLEL std::string parallelLib(params.parallelLib); if (parallelLib != "") - return FindOrStartParallelContainer(params, possibleComputers); + { + Engines::MachineParameters myparams(params); + myparams.computerList=possibleComputers; + return FindOrStartParallelContainer(myparams); + } #endif string containerNameInNS; Engines::Container_ptr ret = Engines::Container::_nil(); - MESSAGE("SALOME_ContainerManager::StartContainer " << - possibleComputers.length()); + MESSAGE("SALOME_ContainerManager::StartContainer " << possibleComputers.length()); vector lm; - for(unsigned int i=0;i_non_existent()) + lm.push_back(string(possibleComputers[i])); + } + catch(CORBA::Exception&) + { + // CORBA::Exception ignored. + } + } + } + else + { + for(unsigned int i=0;iGetImpl()->FindFirst(lm); - break; - case Engines::P_CYCL: - theMachine=_ResManager->GetImpl()->FindNext(lm); - break; - case Engines::P_BEST: - theMachine=_ResManager->GetImpl()->FindBest(lm); - break; + try + { + theMachine=_ResManager->GetImpl()->Find(params.policy.in(),lm); + } + catch( const SALOME_Exception &ex ) + { + MESSAGE(ex.what()); + return Engines::Container::_nil(); } - } - catch( const SALOME_Exception &ex ){ - MESSAGE(ex.what()); - return Engines::Container::_nil(); - } //If the machine name is localhost use the real name if(theMachine == "localhost") theMachine=Kernel_Utils::GetHostname(); - MESSAGE("try to launch it on " << theMachine); - - string command; - if(theMachine==""){ - MESSAGE("SALOME_ContainerManager::StartContainer : " << - "no possible computer"); - return Engines::Container::_nil(); - } - else if(theMachine==Kernel_Utils::GetHostname()) - command = BuildCommandToLaunchLocalContainer(params,container_exe); - else - command = BuildCommandToLaunchRemoteContainer(theMachine,params,container_exe); - //check if an entry exists in Naming service - if(params.isMPI) - // A parallel container register on zero node in NS - containerNameInNS = _NS->BuildContainerNameForNS(params,GetMPIZeroNode(theMachine).c_str()); - else - containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str()); + //if params.mode == "start" or "" shutdown the existing container before launching a new one with that name + //if params.mode == "getorstart" or "get" use the existing container + containerNameInNS = _NS->BuildContainerNameForNS(params,theMachine.c_str()); SCRUTE(containerNameInNS); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); @@ -278,10 +280,14 @@ StartContainer(const Engines::MachineParameters& params, { try { - // shutdown the registered container if it exists Engines::Container_var cont=Engines::Container::_narrow(obj); - if(!CORBA::is_nil(cont)) - cont->Shutdown(); + if(!cont->_non_existent()) + { + if(std::string(params.mode.in())=="getorstart"||std::string(params.mode.in())=="get") + return cont._retn(); /* the container exists and params.mode is getorstart or get use it*/ + else + cont->Shutdown(); // shutdown the registered container if it exists + } } catch(CORBA::Exception&) { @@ -289,6 +295,19 @@ StartContainer(const Engines::MachineParameters& params, } } + //try to launch a new container + MESSAGE("try to launch it on " << theMachine); + + string command; + if(theMachine==""){ + MESSAGE("SALOME_ContainerManager::StartContainer : no possible computer"); + return Engines::Container::_nil(); + } + else if(theMachine==Kernel_Utils::GetHostname()) + command = BuildCommandToLaunchLocalContainer(params,container_exe); + else + command = BuildCommandToLaunchRemoteContainer(theMachine,params,container_exe); + //redirect stdout and stderr in a file string logFilename="/tmp/"+_NS->ContainerName(params)+"_"+ theMachine +"_"+getenv( "USER" )+".log" ; command += " > " + logFilename + " 2>&1 &"; @@ -296,16 +315,13 @@ StartContainer(const Engines::MachineParameters& params, // launch container with a system call int status=system(command.c_str()); - if (status == -1){ - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " << - "(system command status -1)"); + MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status -1)"); RmTmpFile(_TmpFileName); // command file can be removed here return Engines::Container::_nil(); } else if (status == 217){ - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed " << - "(system command status 217)"); + MESSAGE("SALOME_ContainerManager::StartContainer rsh failed (system command status 217)"); RmTmpFile(_TmpFileName); // command file can be removed here return Engines::Container::_nil(); } @@ -320,7 +336,7 @@ StartContainer(const Engines::MachineParameters& params, #endif count-- ; if ( count != 10 ) - MESSAGE( count << ". Waiting for container on " << theMachine); + MESSAGE( count << ". Waiting for container on " << theMachine); CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); ret=Engines::Container::_narrow(obj); @@ -328,7 +344,7 @@ StartContainer(const Engines::MachineParameters& params, if ( CORBA::is_nil(ret) ) { - MESSAGE("SALOME_LifeCycleCORBA::StartOrFindContainer rsh failed"); + MESSAGE("SALOME_ContainerManager::StartContainer rsh failed"); } else { @@ -344,21 +360,16 @@ StartContainer(const Engines::MachineParameters& params, } //============================================================================= -//! Start a suitable Container for a list of components with constraints and a policy +//! Start a suitable Container given constraints /*! CORBA Method: * \param params Machine Parameters required for the container - * \param policy policy to use (first,cycl or best) - * \param componentList list of component to be loaded on this container */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -StartContainer(const Engines::MachineParameters& params, - Engines::ResPolicy policy, - const Engines::CompoList& componentList) +SALOME_ContainerManager::StartContainer(const Engines::MachineParameters& params) { - Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params,componentList); + Engines::MachineList_var possibleComputers = _ResManager->GetFittingResources(params); // Look into ModulCatalog if a specific container must be launched CORBA::String_var container_exe; @@ -370,9 +381,9 @@ StartContainer(const Engines::MachineParameters& params, if (CORBA::is_nil (Catalog)) return Engines::Container::_nil(); // Loop through component list - for(unsigned int i=0;iGetComponent(compoi); if (CORBA::is_nil (compoInfo)) { @@ -403,9 +414,77 @@ StartContainer(const Engines::MachineParameters& params, } if(found) - return StartContainer(params,possibleComputers,policy,container_exe.in()); + return StartContainer(params,possibleComputers,container_exe.in()); else - return StartContainer(params,possibleComputers,policy); + return StartContainer(params,possibleComputers); +} + +//============================================================================= +//! Find or start a suitable Container given some constraints +/*! CORBA Method: + * \param params Machine Parameters required for the container + * \return the container or nil + */ +//============================================================================= + +Engines::Container_ptr +SALOME_ContainerManager::FindOrStartContainer(const Engines::MachineParameters& params) +{ + Engines::Container_ptr ret = FindContainer(params,params.computerList); + if(!CORBA::is_nil(ret)) + return ret; + MESSAGE("Container doesn't exist try to launch it ..."); + + return StartContainer(params); +} + +//============================================================================= +//! Find a container given constraints (params) on a list of machines (possibleComputers) +/*! + * + */ +//============================================================================= + +Engines::Container_ptr +SALOME_ContainerManager::FindContainer(const Engines::MachineParameters& params, + const Engines::MachineList& possibleComputers) +{ + MESSAGE("FindContainer "<BuildContainerNameForNS(params,theMachine)); + CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); + try + { + if(obj->_non_existent()) + return Engines::Container::_nil(); + else + return Engines::Container::_narrow(obj); + } + catch(const CORBA::Exception& e) + { + return Engines::Container::_nil(); + } } #ifdef WITH_PACO_PARALLEL @@ -413,15 +492,11 @@ StartContainer(const Engines::MachineParameters& params, /*! CORBA Method: * Find or Start a suitable PaCO++ Parallel Container in a list of machines. * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start - * * \return CORBA container reference. */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartParallelContainer(const Engines::MachineParameters& params_const, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::FindOrStartParallelContainer(const Engines::MachineParameters& params_const) { CORBA::Object_var obj; PaCO::InterfaceManager_var proxy; @@ -432,14 +507,14 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, // Currently not as good as could be since // we have to verified the number of nodes of the container // if a user tell that. - ret = FindContainer(params, possibleComputers); + ret = FindContainer(params, params.computerList); if(CORBA::is_nil(ret)) { // Step 2 : Starting a new parallel container INFOS("[FindOrStartParallelContainer] Starting a parallel container"); // Step 2.1 : Choose a computer - string theMachine = _ResManager->FindFirst(possibleComputers); + string theMachine = _ResManager->FindFirst(params.computerList); if(theMachine == "") { INFOS("[FindOrStartParallelContainer] !!!!!!!!!!!!!!!!!!!!!!!!!!"); INFOS("[FindOrStartParallelContainer] No possible computer found"); @@ -449,16 +524,16 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, INFOS("[FindOrStartParallelContainer] on machine : " << theMachine); string command; if(theMachine == Kernel_Utils::GetHostname()) { - // Step 3 : starting parallel container proxy - params.hostname = CORBA::string_dup(theMachine.c_str()); - Engines::MachineParameters params_proxy(params); - try { - command = BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerProxy", params_proxy, "xterm"); - } - catch(const SALOME_Exception & ex){ - MESSAGE(ex.what()); - return Engines::Container::_nil(); - } + // Step 3 : starting parallel container proxy + params.hostname = CORBA::string_dup(theMachine.c_str()); + Engines::MachineParameters params_proxy(params); + try { + command = BuildCommandToLaunchLocalParallelContainer("SALOME_ParallelContainerProxy", params_proxy, "xterm"); + } + catch(const SALOME_Exception & ex){ + MESSAGE(ex.what()); + return Engines::Container::_nil(); + } // LaunchParallelContainer uses this value to know if it launches the proxy or the nodes params_proxy.nb_component_nodes = 0; obj = LaunchParallelContainer(command, params_proxy, _NS->ContainerName(params)); @@ -536,15 +611,11 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params_const, /*! CORBA Method: * Find or Start a suitable PaCO++ Parallel Container in a list of machines. * \param params Machine Parameters required for the container - * \param possibleComputers list of machines usable for find or start - * * \return CORBA container reference. */ //============================================================================= Engines::Container_ptr -SALOME_ContainerManager:: -FindOrStartParallelContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) +SALOME_ContainerManager::FindOrStartParallelContainer(const Engines::MachineParameters& params) { Engines::Container_ptr ret = Engines::Container::_nil(); INFOS("[FindOrStartParallelContainer] is disabled !"); @@ -553,80 +624,6 @@ FindOrStartParallelContainer(const Engines::MachineParameters& params, } #endif -//============================================================================= -//! Give a suitable Container for a list of components with constraints and a policy -/*! CORBA Method: - * \param params Machine Parameters required for the container - * \param policy policy to use (first,cycl or best) - * \param componentList list of component to be loaded on this container - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -GiveContainer(const Engines::MachineParameters& params, - Engines::ResPolicy policy, - const Engines::CompoList& componentList) -{ - char *valenv=getenv("SALOME_BATCH"); - if(valenv) - if (strcmp(valenv,"1")==0) - { - if(_batchLaunchedContainers.empty()) - fillBatchLaunchedContainers(); - - if (_batchLaunchedContainersIter == _batchLaunchedContainers.end()) - _batchLaunchedContainersIter = _batchLaunchedContainers.begin(); - - Engines::Container_ptr rtn = Engines::Container::_duplicate(*_batchLaunchedContainersIter); - _batchLaunchedContainersIter++; - return rtn; - } - return StartContainer(params,policy,componentList); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -FindContainer(const Engines::MachineParameters& params, - const char *theMachine) -{ - string containerNameInNS(_NS->BuildContainerNameForNS(params,theMachine)); - CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); - if( !CORBA::is_nil(obj) ) - return Engines::Container::_narrow(obj); - else - return Engines::Container::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -Engines::Container_ptr -SALOME_ContainerManager:: -FindContainer(const Engines::MachineParameters& params, - const Engines::MachineList& possibleComputers) -{ - MESSAGE("FindContainer "< 0 if open OK. + */ +CORBA::Long fileTransfer_i::openW(const char* fileName) +{ + MESSAGE(" fileTransfer_i::openW " << fileName); + int aKey = _fileKey++; + _ctr=0; + FILE* fp; + if ((fp = fopen(fileName,"wb")) == NULL) + { + INFOS("file " << fileName << " is not writable"); + return 0; + } + _fileAccess[aKey] = fp; + return aKey; +} + +/*! \brief put a data block for copy into a file + * + * CORBA method: put a block of data into the file associated to the fileId + * given at openW. + * \param fileId got in return from openW method + * \param block an octet sequence to copy into opened file + */ +void fileTransfer_i::putBlock(CORBA::Long fileId, const Engines::fileBlock& block) +{ + MESSAGE("fileTransfer_i::putBlock"); + FILE* fp; + if (! (fp = _fileAccess[fileId]) ) + { + INFOS(" no FILE structure associated to fileId " < _fileAccess; + std::map _fileAccess; int _ctr; }; diff --git a/src/Container/Salome_file_i.hxx b/src/Container/Salome_file_i.hxx index ac72586e7..d92ab4f4c 100644 --- a/src/Container/Salome_file_i.hxx +++ b/src/Container/Salome_file_i.hxx @@ -33,12 +33,14 @@ #include CORBA_SERVER_HEADER(SALOME_Exception) #include "SALOME_Container.hxx" +#include "SALOME_FileTransfer_i.hxx" + #include #include #include class CONTAINER_EXPORT Salome_file_i: - public virtual POA_Engines::Salome_file + public virtual POA_Engines::Salome_file,public virtual fileTransfer_i { public: Salome_file_i(); diff --git a/src/DF/DF_definitions.hxx b/src/DF/DF_definitions.hxx index 12e3f6de9..de5d65e6d 100644 --- a/src/DF/DF_definitions.hxx +++ b/src/DF/DF_definitions.hxx @@ -23,7 +23,7 @@ #define DF_DEF_HXX #ifdef WIN32 -# ifdef DF_EXPORTS +# if defined DF_EXPORTS # define DF_EXPORT __declspec( dllexport ) # else # define DF_EXPORT __declspec( dllimport ) diff --git a/src/DSC/DSC_Basic/DSC_Basic.hxx b/src/DSC/DSC_Basic/DSC_Basic.hxx index 3e0b4922d..0fec8e528 100755 --- a/src/DSC/DSC_Basic/DSC_Basic.hxx +++ b/src/DSC/DSC_Basic/DSC_Basic.hxx @@ -27,7 +27,7 @@ #define _DSC_Basic_HXX_ #ifdef WIN32 -# ifdef DSC_BASIC_EXPORTS +# if defined DSC_BASIC_EXPORTS || defined SalomeDSCContainer_EXPORTS # define DSC_BASIC_EXPORT __declspec( dllexport ) # else # define DSC_BASIC_EXPORT __declspec( dllimport ) diff --git a/src/DSC/DSC_Python/Makefile.am b/src/DSC/DSC_Python/Makefile.am index 5a87b6b30..e5d9bf04a 100644 --- a/src/DSC/DSC_Python/Makefile.am +++ b/src/DSC/DSC_Python/Makefile.am @@ -30,6 +30,8 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # =============================================================== # +BUILT_SOURCES = calcium_wrap.cpp calcium.py + # This local variable defines the list of CPPFLAGS common to all target in this package. COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \ -I$(top_srcdir)/src/DSC/DSC_User/Datastream \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c index bbf7f06a7..4ebb051fb 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/calciumf.c +++ b/src/DSC/DSC_User/Datastream/Calcium/calciumf.c @@ -21,8 +21,8 @@ // #include #include -#include -#include +#include "fortoc.h" +#include "calcium.h" #include static void* COMPO=0; diff --git a/src/KERNEL_PY/Makefile.am b/src/KERNEL_PY/Makefile.am index 8ac181d98..869e2f913 100755 --- a/src/KERNEL_PY/Makefile.am +++ b/src/KERNEL_PY/Makefile.am @@ -27,21 +27,27 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # Scripts to be installed (salomepython is an automake keyword for python targets) salomepython_PYTHON = \ - Help.py \ - PyInterp.py \ - salome.py \ salome_shared_modules.py \ - batchmode_salome.py \ import_hook.py \ - salome_test.py \ - salome_kernel.py \ - salome_study.py \ - salome_iapp.py \ - salome_ComponentGUI.py \ - omnipatch.py \ - iparameters.py \ - salome_version.py \ - salome_notebook.py + omnipatch.py -sharedpkgpython_PYTHON = kernel_shared_modules.py +if CORBA_GEN + salomepython_PYTHON += \ + Help.py \ + PyInterp.py \ + salome.py \ + salome_shared_modules.py \ + batchmode_salome.py \ + import_hook.py \ + salome_test.py \ + salome_kernel.py \ + salome_study.py \ + salome_iapp.py \ + salome_ComponentGUI.py \ + omnipatch.py \ + iparameters.py \ + salome_version.py \ + salome_notebook.py +endif +sharedpkgpython_PYTHON = kernel_shared_modules.py diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index a320ecedc..727cedc5f 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -31,7 +31,7 @@ #ifdef WIN32 # include #endif -BatchTest::BatchTest(const Engines::MachineParameters& batch_descr) +BatchTest::BatchTest(const Engines::MachineDefinition& batch_descr) { _batch_descr = batch_descr; diff --git a/src/Launcher/BatchTest.hxx b/src/Launcher/BatchTest.hxx index 8ccd5a550..8fdf3736c 100644 --- a/src/Launcher/BatchTest.hxx +++ b/src/Launcher/BatchTest.hxx @@ -32,7 +32,7 @@ class SALOMELAUNCHER_EXPORT BatchTest { public: - BatchTest(const Engines::MachineParameters& batch_descr); + BatchTest(const Engines::MachineDefinition& batch_descr); virtual ~BatchTest(); bool test(); @@ -48,7 +48,7 @@ class SALOMELAUNCHER_EXPORT BatchTest std::string get_home(std::string * home); private: - Engines::MachineParameters _batch_descr; + Engines::MachineDefinition _batch_descr; std::string _test_filename; std::string _base_filename; std::string _date; diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index 6dd80e189..b6a6ea2ca 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -92,9 +92,8 @@ long Launcher_cpp::submitJob( const std::string xmlExecuteFile, // verify if cluster is in resources catalog machineParams params; params.hostname = clusterName; - vector aCompoList ; try{ - aMachineList = _ResManager->GetFittingResources(params, aCompoList); + aMachineList = _ResManager->GetFittingResources(params); } catch(const ResourcesException &ex){ throw LauncherException(ex.msg.c_str()); @@ -207,9 +206,8 @@ long Launcher_cpp::submitSalomeJob( const string fileToExecute , throw LauncherException("Batch parameters are bad (see informations above)"); // find a cluster matching the structure params - vector aCompoList ; try{ - aMachineList = _ResManager->GetFittingResources(params, aCompoList); + aMachineList = _ResManager->GetFittingResources(params); } catch(const ResourcesException &ex){ throw LauncherException(ex.msg.c_str()); @@ -298,8 +296,7 @@ string Launcher_cpp::queryJob( long id, throw LauncherException("You must set Resources Manager to Launcher!!"); // find a cluster matching params structure - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); @@ -346,8 +343,7 @@ void Launcher_cpp::deleteJob( const long id, throw LauncherException("You must set Resources Manager to Launcher!!"); // find a cluster matching params structure - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); @@ -385,8 +381,7 @@ void Launcher_cpp::getResultsJob( const string directory, if(!_ResManager) throw LauncherException("You must set Resources Manager to Launcher!!"); - vector aCompoList ; - vector aMachineList = _ResManager->GetFittingResources( params , aCompoList ) ; + vector aMachineList = _ResManager->GetFittingResources( params ) ; ParserResourcesType p = _ResManager->GetResourcesList(aMachineList[0]); string clustername(p.Alias); diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 00869eec8..9ec5bf1f9 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -92,7 +92,6 @@ void SALOME_Launcher::Shutdown() _ResManager->Shutdown(); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); - //_remove_ref(); if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } @@ -199,12 +198,11 @@ SALOME_Launcher::testBatch(const Engines::MachineParameters& params) try { // find a cluster matching the structure params - Engines::CompoList aCompoList ; - Engines::MachineList *aMachineList = _ResManager->GetFittingResources(params, aCompoList); + Engines::MachineList *aMachineList = _ResManager->GetFittingResources(params); if (aMachineList->length() == 0) throw SALOME_Exception("No resources have been found with your parameters"); - const Engines::MachineParameters* p = _ResManager->GetMachineParameters((*aMachineList)[0]); + const Engines::MachineDefinition* p = _ResManager->GetMachineParameters((*aMachineList)[0]); string clustername(p->alias); INFOS("Choose cluster" << clustername); diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx index 3f80d7453..26e08da56 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx @@ -130,12 +130,7 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile) params.container_name = _containerName.c_str(); params.hostname = _refMachine.c_str(); - Engines::CompoList clist; - Engines::MachineList_var listOfMachines = - resManager->GetFittingResources(params, clist); - - container = contManager->FindOrStartContainer(params, - listOfMachines); + container = contManager->FindOrStartContainer(params); if (CORBA::is_nil(container)) { INFOS("machine " << _refMachine << " unreachable"); @@ -145,7 +140,7 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile) _theFileRef = container->createFileRef(_origFileName.c_str()); if (CORBA::is_nil(_theFileRef)) { - INFOS("imposssible to create fileRef on " << _refMachine); + INFOS("impossible to create fileRef on " << _refMachine); return ""; } } diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index a9ab219c8..cdc04fde9 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -51,6 +51,7 @@ #include "SALOME_ContainerManager.hxx" #include "SALOME_Component_i.hxx" #include "SALOME_NamingService.hxx" +#include "SALOME_FileTransferCORBA.hxx" using namespace std; @@ -133,13 +134,12 @@ SALOME_LifeCycleCORBA::FindComponent(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params, clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; + Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms); - Engines::Component_var compo = _FindComponent(params, + Engines::Component_var compo = _FindComponent(parms, componentName, studyId, listOfMachines); @@ -167,16 +167,13 @@ SALOME_LifeCycleCORBA::LoadComponent(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params, clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; - Engines::Component_var compo = _LoadComponent(params, + Engines::Component_var compo = _LoadComponent(parms, componentName, - studyId, - listOfMachines); + studyId); return compo._retn(); } @@ -203,22 +200,20 @@ FindOrLoad_Component(const Engines::MachineParameters& params, if (! isKnownComponentClass(componentName)) return Engines::Component::_nil(); - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - Engines::MachineList_var listOfMachines = - _ResManager->GetFittingResources(params,clist); + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; + Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(parms); - Engines::Component_var compo = _FindComponent(params, + Engines::Component_var compo = _FindComponent(parms, componentName, studyId, listOfMachines); if(CORBA::is_nil(compo)) - compo = _LoadComponent(params, + compo = _LoadComponent(parms, componentName, - studyId, - listOfMachines); + studyId); return compo._retn(); } @@ -368,13 +363,17 @@ void SALOME_LifeCycleCORBA::preSet( Engines::MachineParameters& params) { params.container_name = ""; params.hostname = ""; + //param.componentList = 0; + //param.computerList = 0; params.OS = ""; params.mem_mb = 0; params.cpu_clock = 0; params.nb_proc_per_node = 0; params.nb_node = 0; params.isMPI = false; - + params.workingdir = ""; + params.mode = ""; + params.policy = ""; params.parallelLib = ""; params.nb_component_nodes = 0; } @@ -623,7 +622,6 @@ _FindComponent(const Engines::MachineParameters& params, * \param params machine parameters like type or name... * \param componentName the name of component class * \param studyId default = 0 : multistudy instance - * \param listOfMachines list of machine address * \return a CORBA reference of the component instance, or _nil if problem */ //============================================================================= @@ -632,15 +630,12 @@ Engines::Component_ptr SALOME_LifeCycleCORBA:: _LoadComponent(const Engines::MachineParameters& params, const char *componentName, - int studyId, - const Engines::MachineList& listOfMachines) + int studyId) { MESSAGE("_LoadComponent, required " << params.container_name << " " << componentName << " " << NbProc(params)); - Engines::Container_var cont = - _ContManager->FindOrStartContainer(params, - listOfMachines); + Engines::Container_var cont = _ContManager->FindOrStartContainer(params); if (CORBA::is_nil(cont)) return Engines::Component::_nil(); bool isLoadable = cont->load_component_Library(componentName); @@ -672,19 +667,12 @@ SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::MachineParameters& MESSAGE("Number of component nodes : " << params.nb_component_nodes); MESSAGE("Component Name : " << componentName);*/ - Engines::CompoList clist; - clist.length(1); - clist[0] = componentName; - MESSAGE("Building a list of machines"); - Engines::MachineList_var listOfMachines = _ResManager->GetFittingResources(params, clist); - if (listOfMachines->length() == 0) - { - INFOS("No matching machines founded !"); - return Engines::Component::_nil(); - } + Engines::MachineParameters parms(params); + parms.componentList.length(1); + parms.componentList[0] = componentName; MESSAGE("Starting Parallel Container"); - Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(params, listOfMachines); + Engines::Container_var cont = _ContManager->FindOrStartParallelContainer(parms); if (CORBA::is_nil(cont)) { INFOS("FindOrStartParallelContainer() returns a NULL container !"); return Engines::Component::_nil(); @@ -707,3 +695,33 @@ SALOME_LifeCycleCORBA::Load_ParallelComponent(const Engines::MachineParameters& return myInstance._retn(); } +/*! \brief copy a file from a source host to a destination host + * \param hostSrc the source host + * \param fileSrc the file to copy from the source host to the destination host + * \param hostDest the destination host + * \param fileDest the destination file + */ +void SALOME_LifeCycleCORBA::copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest) +{ + if(strcmp(hostDest,"localhost") == 0) + { + //if localhost use a shortcut + SALOME_FileTransferCORBA transfer(hostSrc,fileSrc); + transfer.getLocalFile(fileDest); + return; + } + + Engines::ContainerManager_var contManager = getContainerManager(); + + Engines::MachineParameters params; + preSet(params); + + params.hostname = hostDest; + Engines::Container_var containerDest = contManager->FindOrStartContainer(params); + + params.hostname = hostSrc; + Engines::Container_var containerSrc = contManager->FindOrStartContainer(params); + + containerDest->copyFile(containerSrc,fileSrc,fileDest); +} + diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx index dfbf3d7c9..4083c428b 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.hxx @@ -98,10 +98,11 @@ public: int NbProc(const Engines::MachineParameters& params); - void preSet(Engines::MachineParameters& params); + static void preSet(Engines::MachineParameters& outparams); Engines::ContainerManager_ptr getContainerManager(); Engines::ResourcesManager_ptr getResourcesManager(); + void copyFile(const char* hostSrc, const char* fileSrc, const char* hostDest, const char* fileDest); void shutdownServers(); static void killOmniNames(); @@ -122,8 +123,7 @@ protected: Engines::Component_ptr _LoadComponent(const Engines::MachineParameters& params, const char *componentName, - int studyId, - const Engines::MachineList& listOfMachines); + int studyId); SALOME_NamingService *_NS; Engines::ContainerManager_var _ContManager; diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 9629055e6..fa4fc4777 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -681,12 +681,10 @@ string LifeCycleCORBATest::GetRemoteHost() Engines::MachineParameters params; _LCC.preSet(params); // empty params to get all the machines + params.componentList.length(1); + params.componentList[0]="SalomeTestComponent"; - Engines::CompoList clist; - clist.length(1); - clist[0] = "SalomeTestComponent"; - Engines::MachineList_var hostList = - resourcesManager->GetFittingResources(params,clist); + Engines::MachineList_var hostList = resourcesManager->GetFittingResources(params); CPPUNIT_ASSERT(hostList->length() > 1); string localHost = Kernel_Utils::GetHostname(); diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index fc09b92e6..aaa52b195 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -66,10 +66,9 @@ int main (int argc, char * argv[]) Engines::ResourcesManager_var _ResManager=Engines::ResourcesManager::_narrow(obj); Engines::MachineParameters p; - Engines::CompoList clist; - clist.length(2); - clist[0] = "MED"; - clist[1] = "GEOM"; + p.componentList.length(2); + p.componentList[0] = "MED"; + p.componentList[1] = "GEOM"; p.hostname = ""; p.OS = "LINUX"; @@ -83,19 +82,22 @@ int main (int argc, char * argv[]) for(int i=0;i<10;i++){ sprintf(st,"cycl_%d",i); p.container_name = CORBA::string_dup(st); - cont = _ContManager->GiveContainer(p,Engines::P_CYCL,clist); + p.policy="cycl"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) error = true; } for(int i=0;i<10;i++){ sprintf(st,"first_%d",i); p.container_name = CORBA::string_dup(st); - cont = _ContManager->GiveContainer(p,Engines::P_FIRST,clist); + p.policy="best"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) error = true; } p.container_name = CORBA::string_dup("best"); - cont = _ContManager->GiveContainer(p,Engines::P_BEST,clist); + p.policy="best"; + cont = _ContManager->GiveContainer(p); if(CORBA::is_nil(cont)) bestImplemented = false; else bestImplemented = true; @@ -139,7 +141,7 @@ int main (int argc, char * argv[]) int nbpmax; for(std::map::iterator iter=cycle.begin();iter!=cycle.end();iter++){ if(strcmp((*iter).first.c_str(),"localhost")!=0){ - Engines::MachineParameters *p = _ResManager->GetMachineParameters((*iter).first.c_str()); + Engines::MachineDefinition *p = _ResManager->GetMachineParameters((*iter).first.c_str()); int nbproc = p->nb_node * p->nb_proc_per_node; if(cycle[(*iter).first]/nbproccmax) cmax=cycle[(*iter).first]/nbproc; diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index 2b5670b71..7946e1d54 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -37,3 +37,12 @@ class LifeCycleCORBA (SALOME_LifeCycleCORBA): return SALOME_LifeCycleCORBA.FindOrLoad_Component(self, containerName, componentName) + +class MachineParameters (Engines.MachineParameters): + def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', + mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', + mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): + Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, + mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, + mode, policy, parallelLib, nb_component_nodes) + diff --git a/src/LifeCycleCORBA_SWIG/Makefile.am b/src/LifeCycleCORBA_SWIG/Makefile.am index b0cd8a499..0b5126cbe 100644 --- a/src/LifeCycleCORBA_SWIG/Makefile.am +++ b/src/LifeCycleCORBA_SWIG/Makefile.am @@ -88,7 +88,7 @@ EXTRA_DIST = $(SWIGSOURCES) # # Scripts to be installed. -dist_salomescript_DATA =\ +dist_salomescript_PYTHON =\ LifeCycleCORBA.py \ TestLifeCycleCORBA.py diff --git a/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py b/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py index d74b61537..ba9331b2f 100644 --- a/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py +++ b/src/LifeCycleCORBA_SWIG/Test/LifeCycleCORBA_SWIGTest.py @@ -178,7 +178,7 @@ class LifeCycleCORBA_SWIGTest(unittest.TestCase): try: cp1=self.lcc.FindOrLoad_Component(containerName,"SalomeTestComponent") except RuntimeError,ex : - self.assertEqual(ex.args[0],'Salome Exception : unknown host') + self.assertEqual(ex.args[0],'unknown host') pass diff --git a/src/LifeCycleCORBA_SWIG/Test/Makefile.am b/src/LifeCycleCORBA_SWIG/Test/Makefile.am index d9614245e..4191c3d5e 100644 --- a/src/LifeCycleCORBA_SWIG/Test/Makefile.am +++ b/src/LifeCycleCORBA_SWIG/Test/Makefile.am @@ -36,8 +36,10 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= # Scripts to be installed -dist_salomescript_SCRIPTS = \ +dist_salomescript_PYTHON = \ LifeCycleCORBA_SWIGTest.py \ + testresourcemanager.py \ + testcontainermanager.py \ TestLifeCycleCORBA_SWIG.py # @@ -67,3 +69,8 @@ lib_LTLIBRARIES = # =============================================================== # bin_PROGRAMS = + +install-data-hook: + @for f in $(dist_salomescript_PYTHON) ; do \ + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py new file mode 100644 index 000000000..256d3373a --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py @@ -0,0 +1,56 @@ +import unittest +import salome +import Engines +import LifeCycleCORBA +salome.salome_init() +cm= salome.lcc.getContainerManager() +rm= salome.lcc.getResourcesManager() + +class TestContainerManager(unittest.TestCase): + """ +Test with catalog : + + + + + + + +""" + def setUp(self): + pass + + def test0(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="start", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + def test1(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="get", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + def test2(self): + """""" + p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="getorstart", + policy="best",componentList=["PYHELLO"]) + co=cm.StartContainer( p ) + print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") + co=cm.StartContainer( p ) + self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") + + +if __name__ == '__main__': + unittest.main() + diff --git a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py new file mode 100644 index 000000000..aba62953f --- /dev/null +++ b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py @@ -0,0 +1,116 @@ +import unittest +import salome +import LifeCycleCORBA +salome.salome_init() +cm= salome.lcc.getContainerManager() +rm= salome.lcc.getResourcesManager() + +class TestResourceManager(unittest.TestCase): + """ +Test with CatalogResources.xml: + + + + + + + + + + + + + + + +""" + def setUp(self): + pass + + def test0(self): + """host required""" + params=LifeCycleCORBA.MachineParameters(hostname="m3") + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, ["m3"]) + + def test1(self): + """OS required""" + params=LifeCycleCORBA.MachineParameters(OS="Linux") + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, []) + + def test2(self): + """component add required""" + params=LifeCycleCORBA.MachineParameters(componentList=["add"]) + machineList=rm.GetFittingResources(params) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test3(self): + """component tutu required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tutu"])) + self.assertEqual(machineList, ['m1', 'm2', 'm3']) + + def test4(self): + """component tata required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tata"])) + self.assertEqual(machineList, ['m1', 'm2']) + + def test5(self): + """component titi required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["titi"])) + self.assertEqual(machineList, ['m1', 'm2']) + + def test6(self): + """component toto required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["toto"])) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test7(self): + """components add and toto required""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) + + def test8(self): + """components add and toto required""" + machineDef=rm.GetMachineParameters('claui2c6') + self.assertEqual(machineDef.componentList, ['toto', 'add']) + + def test10(self): + """policy altcycl""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") + self.assertEqual(rm.Find('altcycl',machineList), "m1") + self.assertEqual(rm.Find('altcycl',machineList), "m2") + self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") + self.assertEqual(rm.Find('altcycl',machineList), "m1") + self.assertEqual(rm.Find('altcycl',machineList), "m2") + + def test11(self): + """policy cycl""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('cycl',machineList), "claui2c6") + self.assertEqual(rm.Find('cycl',machineList), "m1") + self.assertEqual(rm.Find('cycl',machineList), "m2") + self.assertEqual(rm.Find('cycl',machineList), "claui2c6") + self.assertEqual(rm.Find('cycl',machineList), "m1") + self.assertEqual(rm.Find('cycl',machineList), "m2") + + def test12(self): + """policy first""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('first',machineList), "claui2c6") + self.assertEqual(rm.Find('first',machineList), "claui2c6") + + def test13(self): + """policy best""" + machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + self.assertEqual(rm.Find('best',machineList), "claui2c6") + self.assertEqual(rm.Find('best',machineList), "m1") + self.assertEqual(rm.Find('best',machineList), "m2") + self.assertEqual(rm.Find('best',machineList), "claui2c6") + self.assertEqual(rm.Find('best',machineList), "m1") + self.assertEqual(rm.Find('best',machineList), "m2") + +if __name__ == '__main__': + unittest.main() + diff --git a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i index d2d5fe268..22da974ba 100644 --- a/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i +++ b/src/LifeCycleCORBA_SWIG/libSALOME_LifeCycleCORBA.i @@ -26,6 +26,7 @@ %feature("autodoc", "1"); %include +%include "std_string.i" // ---------------------------------------------------------------------------- @@ -43,19 +44,19 @@ typedef int Py_ssize_t; #define PY_SSIZE_T_MIN INT_MIN #endif - using namespace std; +using namespace std; //--- from omniORBpy.h (not present on Debian Sarge packages) struct omniORBpyAPI { PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj, - CORBA::Boolean hold_lock); + CORBA::Boolean hold_lock); // Convert a C++ object reference to a Python object reference. // If is true, caller holds the Python interpreter lock. CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj, - CORBA::Boolean hold_lock); + CORBA::Boolean hold_lock); // Convert a Python object reference to a C++ object reference. // Raises BAD_PARAM if the Python object is not an object reference. // If is true, caller holds the Python interpreter lock. @@ -65,7 +66,7 @@ struct omniORBpyAPI { // Constructor for the singleton. Sets up the function pointers. }; - omniORBpyAPI* api; +omniORBpyAPI* api; %} @@ -80,8 +81,7 @@ struct omniORBpyAPI { PyObject* omnipy = PyImport_ImportModule((char*)"_omnipy"); if (!omnipy) { - PyErr_SetString(PyExc_ImportError, - (char*)"Cannot import _omnipy"); + PyErr_SetString(PyExc_ImportError, (char*)"Cannot import _omnipy"); return; } PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API"); @@ -92,8 +92,11 @@ struct omniORBpyAPI { // ---------------------------------------------------------------------------- +using namespace std; -%typemap(python,out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr + +%typemap(out) Engines::Container_ptr, Engines::Component_ptr, Engines::fileRef_ptr, + Engines::ContainerManager_ptr, Engines::ResourcesManager_ptr { MESSAGE("typemap out on CORBA object ptr"); SCRUTE($1); @@ -101,7 +104,12 @@ struct omniORBpyAPI { SCRUTE($result); } -%typemap(python,in) Engines::fileRef_ptr aFileRef +%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::fileRef_ptr +{ + $1=PyObject_HasAttrString($input, "__omni_obj"); +} + +%typemap(in) Engines::fileRef_ptr aFileRef { MESSAGE("typemap in on CORBA object ptr"); try { @@ -114,114 +122,72 @@ struct omniORBpyAPI { } } - -%typemap(python,out) std::string, - string -{ - MESSAGE("typemap out on std::string"); - SCRUTE($1); - $result = PyString_FromString($1.c_str()); -} - -%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) Engines::MachineParameters const & -{ - $1 = PyDict_Check($input)? 1 : 0; -} %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) const Engines::MachineParameters & { $1 = PyDict_Check($input)? 1 : 0; } -%typemap(typecheck) std::string, - string -{ - $1 = PyString_Check($input); -} - -%typemap(python,in) std::string, - string -{ - MESSAGE("typemap in on std::string"); - std::string str; - if (PyString_Check($input) == 1) - { - char* value = PyString_AsString($input); - str = value; - $1 = str; - } - else - { - MESSAGE("Not a string"); - PyErr_SetString(PyExc_TypeError,"Must Be a Python string"); - return NULL; - } -} - - -%typemap(python,in) const Engines::MachineParameters & +%typemap(in) const Engines::MachineParameters & { //printf("typemap in on Engines::MachineParameters\n"); MESSAGE("typemap in on Engines::MachineParameters"); if (PyDict_Check($input) == 1) { Engines::MachineParameters *param = new Engines::MachineParameters ; - param->container_name = CORBA::string_dup(""); - param->hostname = CORBA::string_dup(""); - param->OS = CORBA::string_dup(""); - param->mem_mb = 0; - param->cpu_clock = 0; - param->nb_proc_per_node = 0; - param->nb_node = 0; - param->isMPI = false; - param->parallelLib = CORBA::string_dup(""); - param->nb_component_nodes = 0; + SALOME_LifeCycleCORBA::preSet(*param); + PyObject *key, *value; Py_ssize_t pos = 0; while (PyDict_Next($input, &pos, &key, &value)) - { - char* keystr = PyString_AsString(key); - printf("key: %s\n", keystr); - if (strcmp(keystr,"container_name")==0) - { - param->container_name = CORBA::string_dup(PyString_AsString(value)); - } - else if (strcmp(keystr,"hostname")==0) - { - param->hostname = CORBA::string_dup(PyString_AsString(value)); - } - else if (strcmp(keystr,"OS")==0) - { - param->OS = CORBA::string_dup(PyString_AsString(value)); - } - else if (strcmp(keystr,"mem_mb")==0) - { - param->mem_mb = PyLong_AsLong(value); - } - else if (strcmp(keystr,"cpu_clock")==0) - { - param->cpu_clock = PyLong_AsLong(value); - } - else if (strcmp(keystr,"nb_proc_per_node")==0) - { - param->nb_proc_per_node = PyLong_AsLong(value); - } - else if (strcmp(keystr,"nb_node")==0) - { - param->nb_node = PyLong_AsLong(value); - } - else if (strcmp(keystr,"isMPI")==0) - { - param->isMPI = PyLong_AsLong(value); - } - else if (strcmp(keystr,"parallelLib")==0) - { - param->parallelLib = CORBA::string_dup(PyString_AsString(value)); - } - else if (strcmp(keystr,"nb_component_nodes")==0) - { - param->nb_component_nodes = PyLong_AsLong(value); - } - } + { + char* keystr = PyString_AsString(key); + if (strcmp(keystr,"container_name")==0) + { + param->container_name = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"hostname")==0) + { + param->hostname = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"OS")==0) + { + param->OS = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"mem_mb")==0) + { + param->mem_mb = PyLong_AsLong(value); + } + else if (strcmp(keystr,"cpu_clock")==0) + { + param->cpu_clock = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_proc_per_node")==0) + { + param->nb_proc_per_node = PyLong_AsLong(value); + } + else if (strcmp(keystr,"nb_node")==0) + { + param->nb_node = PyLong_AsLong(value); + } + else if (strcmp(keystr,"isMPI")==0) + { + param->isMPI = PyLong_AsLong(value); + } + else if (strcmp(keystr,"workingdir")==0) + param->workingdir = CORBA::string_dup(PyString_AsString(value)); + else if (strcmp(keystr,"mode")==0) + param->mode = CORBA::string_dup(PyString_AsString(value)); + else if (strcmp(keystr,"policy")==0) + param->policy = CORBA::string_dup(PyString_AsString(value)); + else if (strcmp(keystr,"parallelLib")==0) + { + param->parallelLib = CORBA::string_dup(PyString_AsString(value)); + } + else if (strcmp(keystr,"nb_component_nodes")==0) + { + param->nb_component_nodes = PyLong_AsLong(value); + } + } $1 = param; } else @@ -233,7 +199,7 @@ struct omniORBpyAPI { } -%typemap(python,freearg) const Engines::MachineParameters & +%typemap(freearg) const Engines::MachineParameters & { MESSAGE("delete $1"); delete $1; diff --git a/src/Logger/Makefile.am b/src/Logger/Makefile.am index db56c6be8..e763aa4f6 100644 --- a/src/Logger/Makefile.am +++ b/src/Logger/Makefile.am @@ -68,4 +68,4 @@ libSalomeLoggerServer_la_LIBADD = \ @CORBA_LIBS@ # Scripts target -dist_salomescript_DATA = SALOME_Trace.py +dist_salomescript_PYTHON = SALOME_Trace.py diff --git a/src/Logger/Test/Makefile.am b/src/Logger/Test/Makefile.am index 074eb6039..d24a8db43 100644 --- a/src/Logger/Test/Makefile.am +++ b/src/Logger/Test/Makefile.am @@ -34,4 +34,4 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # # Executable scripts to be installed -dist_salomescript_SCRIPTS = TestKiller.py +dist_salomescript_PYTHON = TestKiller.py diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index c3fd23405..45de94d0a 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -116,18 +116,26 @@ void Engines_MPIContainer_i::Shutdown() // Load a component library bool Engines_MPIContainer_i::load_component_Library(const char* componentName) { - if( _numproc == 0 ){ - // Invocation du chargement du composant dans les autres process - for(int ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asload_component_Library(componentName); + pthread_t *th; + if(_numproc == 0){ + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++){ + thread_st *st = new thread_st; + st->ip = ip; + st->tior = _tior; + st->compoName = componentName; + pthread_create(&(th[ip]),NULL,th_loadcomponentlibrary,(void*)st); + } } - return Lload_component_Library(componentName); -} + bool ret = Lload_component_Library(componentName); -void Engines_MPIContainer_i::Asload_component_Library(const char* componentName) -{ - Lload_component_Library(componentName); + if(_numproc == 0){ + for(int ip=1;ip<_nbproc;ip++) + pthread_join(th[ip],NULL); + delete th; + } + return ret; } bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName) @@ -155,14 +163,12 @@ bool Engines_MPIContainer_i::Lload_component_Library(const char* componentName) _library_map[impl_name] = handle; _numInstanceMutex.unlock(); MESSAGE("[" << _numproc << "] Library " << impl_name << " loaded"); - MPI_Barrier(MPI_COMM_WORLD); return true; } else { MESSAGE("[" << _numproc << "] Can't load shared library : " << impl_name); MESSAGE("[" << _numproc << "] error dlopen: " << dlerror()); - MPI_Barrier(MPI_COMM_WORLD); } _numInstanceMutex.unlock(); @@ -206,19 +212,28 @@ Engines::Component_ptr Engines_MPIContainer_i::create_component_instance( const char* componentName, CORBA::Long studyId) { - if( _numproc == 0 ){ - // Invocation du chargement du composant dans les autres process - for(int ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Ascreate_component_instance(componentName,studyId); + pthread_t *th; + if(_numproc == 0){ + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++){ + thread_st *st = new thread_st; + st->ip = ip; + st->tior = _tior; + st->compoName = componentName; + st->studyId = studyId; + pthread_create(&(th[ip]),NULL,th_createcomponentinstance,(void*)st); + } } - return Lcreate_component_instance(componentName,studyId); -} + Engines::Component_ptr cptr = Lcreate_component_instance(componentName,studyId); -void Engines_MPIContainer_i::Ascreate_component_instance( const char* componentName, - CORBA::Long studyId) -{ - Lcreate_component_instance(componentName,studyId); + if(_numproc == 0){ + for(int ip=1;ip<_nbproc;ip++) + pthread_join(th[ip],NULL); + delete th; + } + + return cptr; } Engines::Component_ptr @@ -387,24 +402,31 @@ Engines_MPIContainer_i::createMPIInstance(string genericRegisterName, Engines::Component_ptr Engines_MPIContainer_i::load_impl(const char* nameToRegister, const char* componentName) { - if( _numproc == 0 ){ - // Invocation du chargement du composant dans les autres process - for(int ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asload_impl(nameToRegister, - componentName); + pthread_t *th; + if(_numproc == 0){ + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++){ + thread_st *st = new thread_st; + st->ip = ip; + st->tior = _tior; + st->nameToRegister = nameToRegister; + st->compoName = componentName; + pthread_create(&(th[ip]),NULL,th_loadimpl,(void*)st); + } } - return Lload_impl(nameToRegister,componentName); + Engines::Component_ptr cptr = Lload_impl(nameToRegister,componentName); -} + if(_numproc == 0){ + for(int ip=1;ip<_nbproc;ip++) + pthread_join(th[ip],NULL); + delete th; + } -// Load component -void Engines_MPIContainer_i::Asload_impl(const char* nameToRegister, - const char* componentName) -{ - Lload_impl(nameToRegister,componentName); + return cptr; } +// Load component Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( const char* nameToRegister, const char* componentName) @@ -492,83 +514,106 @@ Engines::Component_ptr Engines_MPIContainer_i::Lload_impl( void Engines_MPIContainer_i::remove_impl(Engines::Component_ptr component_i) { - int ip; - Engines::Component_ptr cptr; Engines::MPIObject_ptr pcptr; Engines::MPIObject_ptr spcptr; - ASSERT(! CORBA::is_nil(component_i)); - - if( _numproc == 0 ){ - // Invocation de la destruction du composant dans les autres process + pthread_t *th; + if(_numproc == 0){ pcptr = (Engines::MPIObject_ptr)component_i; - for(ip= 1;ip<_nbproc;ip++){ + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++){ + thread_st *st = new thread_st; + st->ip = ip; + st->tior = _tior; spcptr = Engines::MPIObject::_narrow((*(pcptr->tior()))[ip]); - cptr = (Engines::Component_ptr)spcptr; - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asremove_impl(cptr); + st->cptr = (Engines::Component_ptr)spcptr; + pthread_create(&(th[ip]),NULL,th_removeimpl,(void*)st); } } - Lremove_impl(component_i); -} - -void Engines_MPIContainer_i::Asremove_impl(Engines::Component_ptr component_i) -{ - Lremove_impl(component_i); -} - -void Engines_MPIContainer_i::Lremove_impl(Engines::Component_ptr component_i) -{ - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); - ASSERT(! CORBA::is_nil(component_i)); - string instanceName = component_i->instanceName() ; MESSAGE("[" << _numproc << "] unload component " << instanceName); - component_i->destroy() ; - MESSAGE("[" << _numproc << "] test key handle_map"); _numInstanceMutex.lock() ; // lock on the remove on handle_map + _listInstances_map.erase(instanceName); _numInstanceMutex.unlock() ; - MESSAGE("[" << _numproc << "] list handle_map"); + component_i->destroy() ; + if(_numproc == 0) + _NS->Destroy_Name(instanceName.c_str()); - END_OF("[" << _numproc << "] MPIContainer_i::Lremove_impl"); + if(_numproc == 0){ + for(int ip=1;ip<_nbproc;ip++) + pthread_join(th[ip],NULL); + delete th; + } } void Engines_MPIContainer_i::finalize_removal() { - int ip; + pthread_t *th; + if(_numproc == 0){ + th = new pthread_t[_nbproc]; + for(int ip=1;ip<_nbproc;ip++){ + thread_st *st = new thread_st; + st->ip = ip; + st->tior = _tior; + pthread_create(&(th[ip]),NULL,th_finalizeremoval,(void*)st); + } + } - if( _numproc == 0 ){ - // Invocation de la destruction du composant dans les autres process - for(ip= 1;ip<_nbproc;ip++) - (Engines::MPIContainer::_narrow((*_tior)[ip]))->Asfinalize_removal(); + _numInstanceMutex.lock(); // lock to be alone + // (see decInstanceCnt, load_component_Library) + map::iterator ith; + for (ith = _toRemove_map.begin(); ith != _toRemove_map.end(); ith++) + { + void *handle = (*ith).second; + string impl_name= (*ith).first; + if (handle) + { + SCRUTE(handle); + SCRUTE(impl_name); + // dlclose(handle); // SALOME unstable after ... + // _library_map.erase(impl_name); + } } + _toRemove_map.clear(); + _numInstanceMutex.unlock(); - Lfinalize_removal(); + if(_numproc == 0){ + for(int ip=1;ip<_nbproc;ip++) + pthread_join(th[ip],NULL); + delete th; + } } -void Engines_MPIContainer_i::Asfinalize_removal() +void *th_loadcomponentlibrary(void *s) { - Lfinalize_removal(); + thread_st *st = (thread_st*)s; + (Engines::MPIContainer::_narrow((*(st->tior))[st->ip]))->load_component_Library(st->compoName.c_str()); } -void Engines_MPIContainer_i::Lfinalize_removal() +void *th_createcomponentinstance(void *s) { - BEGIN_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); - -// map::iterator im ; -// // lock on the explore remove_map & dlclose -// _numInstanceMutex.lock() ; -// for (im = remove_map.begin() ; im != remove_map.end() ; im ++) -// { -// void * handle = (*im).second ; -// MESSAGE("[" << _numproc << "] dlclose " << (*im).first); -// dlclose(handle) ; -// } -// MESSAGE("[" << _numproc << "] remove_map.clear()"); -// remove_map.clear() ; -// _numInstanceMutex.unlock() ; - - END_OF("[" << _numproc << "] MPIContainer_i::Lfinalize_removal"); + thread_st *st = (thread_st*)s; + (Engines::MPIContainer::_narrow((*(st->tior))[st->ip]))->create_component_instance(st->compoName.c_str(),st->studyId); } + +void *th_loadimpl(void *s) +{ + thread_st *st = (thread_st*)s; + (Engines::MPIContainer::_narrow((*(st->tior))[st->ip]))->load_impl(st->nameToRegister.c_str(),st->compoName.c_str()); +} + +void *th_removeimpl(void *s) +{ + thread_st *st = (thread_st*)s; + (Engines::MPIContainer::_narrow((*(st->tior))[st->ip]))->remove_impl(st->cptr); +} + +void *th_finalizeremoval(void *s) +{ + thread_st *st = (thread_st*)s; + (Engines::MPIContainer::_narrow((*(st->tior))[st->ip]))->finalize_removal(); +} + diff --git a/src/MPIContainer/MPIContainer_i.hxx b/src/MPIContainer/MPIContainer_i.hxx index a65448540..58f92aa3e 100644 --- a/src/MPIContainer/MPIContainer_i.hxx +++ b/src/MPIContainer/MPIContainer_i.hxx @@ -31,6 +31,21 @@ #include "SALOME_Container_i.hxx" #include "MPIObject_i.hxx" +void * th_loadcomponentlibrary(void *st); +void * th_createcomponentinstance(void *st); +void * th_loadimpl(void *st); +void * th_removeimpl(void *st); +void * th_finalizeremoval(void *st); + +typedef struct { + int ip; + Engines::IORTab* tior; + std::string compoName; + std::string nameToRegister; + long studyId; + Engines::Component_ptr cptr; +} thread_st; + class Engines_MPIContainer_i : public POA_Engines::MPIContainer, public Engines_Container_i, public MPIObject_i @@ -53,47 +68,32 @@ class Engines_MPIContainer_i : public POA_Engines::MPIContainer, // Load a component library // synchronous version for process 0 bool load_component_Library(const char* componentName); - // asynchronous version for other process - void Asload_component_Library(const char* componentName); // Create an instance of component // synchronous version for process 0 Engines::Component_ptr create_component_instance( const char* componentName, CORBA::Long studyId); // 0 for multiStudy - // asynchronous version for other process - void Ascreate_component_instance( const char* componentName, - CORBA::Long studyId); // 0 for multiStudy // Load a component in current MPI container // synchronous version for process 0 Engines::Component_ptr load_impl(const char* nameToRegister, const char* componentName); - // asynchronous version for other process - void Asload_impl(const char* nameToRegister, const char* componentName); // Unload a component from current MPI container // synchronous version for process 0 void remove_impl(Engines::Component_ptr component_i); - // asynchronous version for other process - void Asremove_impl(Engines::Component_ptr component_i); // synchronous version for process 0 void finalize_removal(); - // asynchronous version for other process - void Asfinalize_removal(); private: - // local version to not duplicate code - // called by synchronous and asynchronous version bool Lload_component_Library(const char* componentName); Engines::Component_ptr Lcreate_component_instance( const char* componentName, CORBA::Long studyId); // 0 for multiStudy Engines::Component_ptr Lload_impl(const char* nameToRegister, const char* componentName); - void Lremove_impl(Engines::Component_ptr component_i); - void Lfinalize_removal(); Engines::Component_ptr createMPIInstance(std::string genericRegisterName, diff --git a/src/MPIContainer/MPIObject_i.cxx b/src/MPIContainer/MPIObject_i.cxx index ff45f5e5e..af78c0f2c 100644 --- a/src/MPIContainer/MPIObject_i.cxx +++ b/src/MPIContainer/MPIObject_i.cxx @@ -64,8 +64,7 @@ void MPIObject_i::tior(const Engines::IORTab& ior) (*_tior)[ip] = ior[ip]; } -void MPIObject_i::BCastIOR(CORBA::ORB_ptr orb, Engines::MPIObject_ptr pobj, - bool amiCont) throw(POException) +void MPIObject_i::BCastIOR(CORBA::ORB_ptr orb, Engines::MPIObject_ptr pobj, bool amiCont) { int err, ip, n; char *ior; @@ -125,33 +124,43 @@ void MPIObject_i::BCastIOR(CORBA::ORB_ptr orb, Engines::MPIObject_ptr pobj, } #ifdef HAVE_MPI2 -MPI_Comm MPIObject_i::remoteMPI2Connect(string service) throw(POException) +void MPIObject_i::remoteMPI2Connect(bool high, string service) { int i; - MPI_Comm gcom; + char port_name[MPI_MAX_PORT_NAME]; char port_name_clt[MPI_MAX_PORT_NAME]; - _srv = 0; - _service = service; + if( service.size() == 0 ){ + MESSAGE("[" << _numproc << "] You have to give a service name !"); + throw POException(_numproc,"You have to give a service name !"); + } + + if( _srv.find(service) != _srv.end() ){ + MESSAGE("[" << _numproc << "] service " << service << " already exist !"); + throw POException(_numproc,"service " + service + " already exist !"); + } + + _srv[service] = false; MPI_Barrier(MPI_COMM_WORLD); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); if( _numproc == 0 ){ /* rank 0 try to be a server. If service is already published, try to be a cient */ - MPI_Open_port(MPI_INFO_NULL, _port_name); - if ( MPI_Publish_name((char*)_service.c_str(), MPI_INFO_NULL, _port_name) == MPI_SUCCESS ) { - _srv = 1; - MESSAGE("[" << _numproc << "] service " << _service << " available at " << _port_name << "\n"); + MPI_Open_port(MPI_INFO_NULL, port_name); + if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS ) { + _srv[service] = true; + _port_name[service] = port_name; + MESSAGE("[" << _numproc << "] service " << service << " available at " << port_name << endl); } - else if ( MPI_Lookup_name((char*)_service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ){ - MESSAGE("[" << _numproc << "] I get the connection with " << _service << " at " << port_name_clt << "!\n"); - MPI_Close_port( _port_name ); + else if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ){ + MESSAGE("[" << _numproc << "] I get the connection with " << service << " at " << port_name_clt << endl); + MPI_Close_port( port_name ); } else{ /* Throw exception */ - MESSAGE("[" << _numproc << "] Error on connection with " << _service << " at " << port_name_clt << "!\n"); - throw POException(_numproc,"Error on connection with " + _service + " at " + port_name_clt); + MESSAGE("[" << _numproc << "] Error on connection with " << service << " at " << port_name_clt << endl); + throw POException(_numproc,"Error on connection with " + service + " at " + port_name_clt); } } else{ @@ -159,43 +168,67 @@ MPI_Comm MPIObject_i::remoteMPI2Connect(string service) throw(POException) /* Waiting rank 0 publish name and try to be a client */ while ( i != TIMEOUT ) { sleep(1); - if ( MPI_Lookup_name((char*)_service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ){ - MESSAGE("[" << _numproc << "] I get the connection with " << _service << " at " << port_name_clt << "!\n"); + if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ){ + MESSAGE("[" << _numproc << "] I get the connection with " << service << " at " << port_name_clt << endl); break; } i++; } if(i==TIMEOUT){ /* Throw exception */ - MESSAGE("[" << _numproc << "] Error on connection with " << _service << " at " << port_name_clt << "!\n"); - throw POException(_numproc,"Error on connection with " + _service + " at " + port_name_clt); + MESSAGE("[" << _numproc << "] Error on connection with " << service << " at " << port_name_clt << endl); + throw POException(_numproc,"Error on connection with " + service + " at " + port_name_clt); } } MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); /* If rank 0 is server, all processes call MPI_Comm_accept */ /* If rank 0 is not server, all processes call MPI_Comm_connect */ - MPI_Bcast(&_srv,1,MPI_INT,0,MPI_COMM_WORLD); - if ( _srv ) - MPI_Comm_accept( _port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &gcom ); + int srv = (int)_srv[service]; + MPI_Bcast(&srv,1,MPI_INT,0,MPI_COMM_WORLD); + _srv[service] = (bool)srv; + if ( _srv[service] ) + MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &(_icom[service]) ); else - MPI_Comm_connect(port_name_clt, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &gcom ); + MPI_Comm_connect(port_name_clt, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &(_icom[service]) ); - /* only rank 0 can be server for unpublish name */ - if(_numproc != 0) _srv = 0; + /* create global communicator */ + MPI_Intercomm_merge(_icom[service],high,&(_gcom[service])); - return gcom; + /* only rank 0 can be server for unpublish name */ + if(_numproc != 0) _srv[service] = false; } -void MPIObject_i::remoteMPI2Disconnect(MPI_Comm gcom) +void MPIObject_i::remoteMPI2Disconnect(std::string service) { - MPI_Comm_disconnect( &gcom ); - if ( _srv ) { - MPI_Unpublish_name((char*)_service.c_str(), MPI_INFO_NULL, _port_name); - MESSAGE("[" << _numproc << "] " << _service << ": close port " << _port_name << "\n"); - MPI_Close_port( _port_name ); + + if( service.size() == 0 ){ + MESSAGE("[" << _numproc << "] You have to give a service name !"); + throw POException(_numproc,"You have to give a service name !"); } + + if( _srv.find(service) == _srv.end() ){ + MESSAGE("[" << _numproc << "] service " << service << " don't exist !"); + throw POException(_numproc,"service " + service + " don't exist !"); + } + + MPI_Comm_disconnect( &(_gcom[service]) ); + if ( _srv[service] ) { + + char port_name[MPI_MAX_PORT_NAME]; + strcpy(port_name,_port_name[service].c_str()); + + MPI_Unpublish_name((char*)service.c_str(), MPI_INFO_NULL, port_name); + MESSAGE("[" << _numproc << "] " << service << ": close port " << _port_name[service] << endl); + MPI_Close_port( port_name ); + _port_name.erase(service); + } + + _gcom.erase(service); + _icom.erase(service); + _srv.erase(service); + } #endif diff --git a/src/MPIContainer/MPIObject_i.hxx b/src/MPIContainer/MPIObject_i.hxx index 641cb1138..66d24f58d 100644 --- a/src/MPIContainer/MPIObject_i.hxx +++ b/src/MPIContainer/MPIObject_i.hxx @@ -30,7 +30,6 @@ #include #include #include CORBA_SERVER_HEADER(SALOME_MPIObject) -#define defaultService "SERVER" class POException { @@ -58,18 +57,21 @@ class MPIObject_i: public POA_Engines::MPIObject // IOR des objets paralleles sur tous les process mpi Engines::IORTab* _tior; // Echange des IOR de l'objet entre process - void BCastIOR(CORBA::ORB_ptr orb,Engines::MPIObject_ptr pobj,bool amiCont) throw(POException); + void BCastIOR(CORBA::ORB_ptr orb,Engines::MPIObject_ptr pobj,bool amiCont); #ifdef HAVE_MPI2 // MPI2 connection - MPI_Comm remoteMPI2Connect(std::string service=defaultService) throw(POException); + void remoteMPI2Connect(bool high, std::string service); // MPI2 disconnection - void remoteMPI2Disconnect(MPI_Comm gcom); + void remoteMPI2Disconnect(std::string service); #endif +protected: + std::map _gcom; + private: - int _srv; - char _port_name[MPI_MAX_PORT_NAME]; - std::string _service; + std::map _icom; + std::map _srv; + std::map _port_name; } ; diff --git a/src/Makefile.am b/src/Makefile.am index 2d202204b..52b42f6c2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,7 +27,8 @@ SUBDIR_BASE = \ Basics \ SALOMELocalTrace \ - HDFPersist + HDFPersist\ + KERNEL_PY SUBDIR_CORBA = \ DF \ @@ -50,7 +51,6 @@ SUBDIR_CORBA = \ TOOLSDS \ SALOMEDSImpl \ SALOMEDS \ - KERNEL_PY \ ModuleGenerator \ Communication \ Communication_SWIG \ diff --git a/src/ModuleCatalog/Makefile.am b/src/ModuleCatalog/Makefile.am index 7cdd4073a..99160e72e 100644 --- a/src/ModuleCatalog/Makefile.am +++ b/src/ModuleCatalog/Makefile.am @@ -43,7 +43,7 @@ salomeinclude_HEADERS = \ SALOME_ModuleCatalog.hxx # Scripts to be installed -dist_salomescript_DATA = TestModuleCatalog.py +dist_salomescript_PYTHON = TestModuleCatalog.py # diff --git a/src/ModuleGenerator/Makefile.am b/src/ModuleGenerator/Makefile.am index 453e87b5a..2f74b5ba1 100644 --- a/src/ModuleGenerator/Makefile.am +++ b/src/ModuleGenerator/Makefile.am @@ -26,6 +26,11 @@ # include $(top_srcdir)/salome_adm/unix/make_common_starter.am -dist_salomescript_DATA = IDLparser.py +dist_salomescript_PYTHON = IDLparser.py EXTRA_DIST = tests + +install-data-hook: + @for f in $(dist_salomescript_PYTHON) ; do \ + chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ + done diff --git a/src/NamingService/Makefile.am b/src/NamingService/Makefile.am index 8b6514755..474f5f02e 100644 --- a/src/NamingService/Makefile.am +++ b/src/NamingService/Makefile.am @@ -35,7 +35,7 @@ salomeinclude_HEADERS =\ SALOME_NamingService_defs.hxx # Scripts to be exported -dist_salomescript_DATA =\ +dist_salomescript_PYTHON =\ SALOME_NamingServicePy.py diff --git a/src/NamingService/Test/Makefile.am b/src/NamingService/Test/Makefile.am index 1de5e46d5..166fd3388 100644 --- a/src/NamingService/Test/Makefile.am +++ b/src/NamingService/Test/Makefile.am @@ -36,7 +36,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= NamingServiceTest.hxx # Scripts to be installed -dist_salomescript_SCRIPTS = TestNamingService.py +dist_salomescript_PYTHON = TestNamingService.py # @@ -58,6 +58,11 @@ COMMON_CPPFLAGS=\ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ +# This local variable defines the list of dependant libraries common to all target in this package. +COMMON_LIBS =\ + @CPPUNIT_LIBS@ \ + ../libSalomeNS.la + # # =============================================================== # Libraries targets @@ -67,7 +72,7 @@ lib_LTLIBRARIES = libNamingServiceTest.la libNamingServiceTest_la_SOURCES = NamingServiceTest.cxx libNamingServiceTest_la_CPPFLAGS = $(COMMON_CPPFLAGS) libNamingServiceTest_la_LDFLAGS = -no-undefined -version-info=0:0:0 -libNamingServiceTest_la_LIBADD = @CPPUNIT_LIBS@ +libNamingServiceTest_la_LIBADD = $(COMMON_LIBS) # diff --git a/src/ParallelContainer/SALOME_ParallelComponent_i.hxx b/src/ParallelContainer/SALOME_ParallelComponent_i.hxx index 3a72a55cc..8f1f37e45 100644 --- a/src/ParallelContainer/SALOME_ParallelComponent_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelComponent_i.hxx @@ -47,7 +47,7 @@ class Engines_Parallel_Container_i; #ifdef WIN32 -# ifdef CONTAINER_EXPORTS +# if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS # define CONTAINER_EXPORT __declspec( dllexport ) # else # define CONTAINER_EXPORT __declspec( dllimport ) diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx index 1c09296f0..c76f18a11 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.hxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.hxx @@ -45,7 +45,7 @@ class SALOME_NamingService; #ifdef WIN32 -# ifdef CONTAINER_EXPORTS +# if defined CONTAINER_EXPORTS || defined SalomeParallelContainer_EXPORTS # define CONTAINER_EXPORT __declspec( dllexport ) # else # define CONTAINER_EXPORT __declspec( dllimport ) diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index 5bcf6d843..381be2fd2 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -38,6 +39,9 @@ using namespace std; +static LoadRateManagerFirst first; +static LoadRateManagerCycl cycl; +static LoadRateManagerAltCycl altcycl; //============================================================================= /*! * just for test @@ -51,6 +55,11 @@ ResourcesManager_cpp(const char *xmlFilePath) : #if defined(_DEBUG_) || defined(_DEBUG) cerr << "ResourcesManager_cpp constructor" << endl; #endif + _resourceManagerMap["first"]=&first; + _resourceManagerMap["cycl"]=&cycl; + _resourceManagerMap["altcycl"]=&altcycl; + _resourceManagerMap["best"]=&altcycl; + _resourceManagerMap[""]=&altcycl; } //============================================================================= @@ -69,6 +78,12 @@ ResourcesManager_cpp::ResourcesManager_cpp() throw(ResourcesException) #if defined(_DEBUG_) || defined(_DEBUG) cerr << "ResourcesManager_cpp constructor" << endl; #endif + _resourceManagerMap["first"]=&first; + _resourceManagerMap["cycl"]=&cycl; + _resourceManagerMap["altcycl"]=&altcycl; + _resourceManagerMap["best"]=&altcycl; + _resourceManagerMap[""]=&altcycl; + _isAppliSalomeDefined = (getenv("APPLI") != 0); if(!getenv("KERNEL_ROOT_DIR")) throw ResourcesException("you must define KERNEL_ROOT_DIR environment variable!!"); @@ -107,22 +122,21 @@ ResourcesManager_cpp::~ResourcesManager_cpp() } //============================================================================= +//! get the list of resource names fitting constraints given by params /*! - * get the list of name of ressources fitting for the specified module. - * If hostname specified, check it is local or known in resources catalog. + * If hostname is specified, check if it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the module is known + * - then select the sublist of machines on which the component is known * (if the result is empty, that probably means that the inventory of - * modules is probably not done, so give complete list from previous step) + * components is probably not done, so give complete list from previous step) */ //============================================================================= std::vector -ResourcesManager_cpp::GetFittingResources(const machineParams& params, - const std::vector& componentList) throw(ResourcesException) +ResourcesManager_cpp::GetFittingResources(const machineParams& params) throw(ResourcesException) { vector vec; @@ -183,10 +197,13 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, else{ // --- Search for available resources sorted by priority + vec=params.computerList; + SelectOnlyResourcesWithOS(vec, params.OS.c_str()); - KeepOnlyResourcesWithModule(vec, componentList); - + KeepOnlyResourcesWithComponent(vec, params.componentList); + + //if hosts list (vec) is empty, ignore componentList constraint and use only OS constraint if (vec.size() == 0) SelectOnlyResourcesWithOS(vec, params.OS.c_str()); @@ -225,25 +242,25 @@ ResourcesManager_cpp::GetFittingResources(const machineParams& params, //============================================================================= /*! * add an entry in the ressources catalog xml file. - * Return 0 if OK (KERNEL found in new resources modules) else throw exception + * Return 0 if OK (KERNEL found in new resources components) else throw exception */ //============================================================================= int ResourcesManager_cpp:: AddResourceInCatalog(const machineParams& paramsOfNewResources, - const vector& modulesOnNewResources, + const vector& componentsOnNewResources, const char *alias, const char *userName, AccessModeType mode, AccessProtocolType prot) throw(ResourcesException) { - vector::const_iterator iter = find(modulesOnNewResources.begin(), - modulesOnNewResources.end(), + vector::const_iterator iter = find(componentsOnNewResources.begin(), + componentsOnNewResources.end(), "KERNEL"); - if (iter != modulesOnNewResources.end()) + if (iter != componentsOnNewResources.end()) { ParserResourcesType newElt; newElt.DataForSort._hostName = paramsOfNewResources.hostname; @@ -251,7 +268,7 @@ throw(ResourcesException) newElt.Protocol = prot; newElt.Mode = mode; newElt.UserName = userName; - newElt.ModulesList = modulesOnNewResources; + newElt.ComponentsList = componentsOnNewResources; newElt.OS = paramsOfNewResources.OS; newElt.DataForSort._memInMB = paramsOfNewResources.mem_mb; newElt.DataForSort._CPUFreqMHz = paramsOfNewResources.cpu_clock; @@ -330,6 +347,15 @@ void ResourcesManager_cpp::WriteInXmlFile() const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() { + //Parse file only if its modification time is greater than lasttime (last registered modification time) + static time_t lasttime=0; + struct stat statinfo; + int result = stat(_path_resources.c_str(), &statinfo); + if (result < 0) return _resourcesList; + if(statinfo.st_mtime <= lasttime) + return _resourcesList; + lasttime=statinfo.st_mtime; + SALOME_ResourcesCatalog_Handler* handler = new SALOME_ResourcesCatalog_Handler(_resourcesList, _resourcesBatchList); @@ -369,41 +395,15 @@ const MapOfParserResourcesType& ResourcesManager_cpp::ParseXmlFile() //============================================================================= const MapOfParserResourcesType& ResourcesManager_cpp::GetList() const - { - return _resourcesList; - } - - -//============================================================================= -/*! - * dynamically obtains the first machines - */ -//============================================================================= - -string ResourcesManager_cpp::FindFirst(const std::vector& listOfMachines) { - return _dynamicResourcesSelecter.FindFirst(listOfMachines); -} - -//============================================================================= -/*! - * dynamically obtains the best machines - */ -//============================================================================= - -string ResourcesManager_cpp::FindNext(const std::vector& listOfMachines) -{ - return _dynamicResourcesSelecter.FindNext(listOfMachines,_resourcesList); + return _resourcesList; } -//============================================================================= -/*! - * dynamically obtains the best machines - */ -//============================================================================= -string ResourcesManager_cpp::FindBest(const std::vector& listOfMachines) +string ResourcesManager_cpp::Find(const std::string& policy, const std::vector& listOfMachines) { - return _dynamicResourcesSelecter.FindBest(listOfMachines); + if(_resourceManagerMap.count(policy)==0) + return _resourceManagerMap[""]->Find(listOfMachines,_resourcesList); + return _resourceManagerMap[policy]->Find(listOfMachines,_resourcesList); } //============================================================================= @@ -419,41 +419,56 @@ throw(ResourcesException) { string base(OS); - for (map::const_iterator iter = - _resourcesList.begin(); - iter != _resourcesList.end(); - iter++) + if(hosts.size()==0) + { + //No constraint on computer list : take all known resources with OS + map::const_iterator iter; + for (iter = _resourcesList.begin(); iter != _resourcesList.end(); iter++) + { + if ( (*iter).second.OS == base || base.size() == 0) + hosts.push_back((*iter).first); + } + } + else { - if ( (*iter).second.OS == base || base.size() == 0) - hosts.push_back((*iter).first); + //a computer list is given : take only resources with OS on those computers + vector vec=hosts; + hosts.clear(); + vector::iterator iter; + for (iter = vec.begin(); iter != vec.end(); iter++) + { + MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); + if(it != _resourcesList.end()) + if ( (*it).second.OS == base || base.size() == 0 ) + hosts.push_back(*iter); + } } } //============================================================================= /*! - * Gives a sublist of machines on which the module is known. + * Gives a sublist of machines on which the component is known. */ //============================================================================= //Warning need an updated parsed list : _resourcesList -void ResourcesManager_cpp::KeepOnlyResourcesWithModule( vector& hosts, const vector& componentList) const +void ResourcesManager_cpp::KeepOnlyResourcesWithComponent( vector& hosts, const vector& componentList) const throw(ResourcesException) { for (vector::iterator iter = hosts.begin(); iter != hosts.end();) { MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); - const vector& mapOfModulesOfCurrentHost = (((*it).second).ModulesList); + const vector& mapOfComponentsOfCurrentHost = (((*it).second).ComponentsList); bool erasedHost = false; - if( mapOfModulesOfCurrentHost.size() > 0 ){ + if( mapOfComponentsOfCurrentHost.size() > 0 ){ for(unsigned int i=0;i::const_iterator itt = find(mapOfModulesOfCurrentHost.begin(), - mapOfModulesOfCurrentHost.end(), + vector::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(), + mapOfComponentsOfCurrentHost.end(), compoi); -// componentList[i]); - if (itt == mapOfModulesOfCurrentHost.end()){ + if (itt == mapOfComponentsOfCurrentHost.end()){ erasedHost = true; break; } diff --git a/src/ResourcesManager/ResourcesManager.hxx b/src/ResourcesManager/ResourcesManager.hxx index cc065929c..c343a73e0 100644 --- a/src/ResourcesManager/ResourcesManager.hxx +++ b/src/ResourcesManager/ResourcesManager.hxx @@ -44,6 +44,8 @@ struct machineParams{ unsigned int nb_proc_per_node; unsigned int cpu_clock; unsigned int mem_mb; + std::vector componentList; + std::vector computerList; }; class RESOURCESMANAGER_EXPORT ResourcesException @@ -65,16 +67,13 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp ~ResourcesManager_cpp(); std::vector - GetFittingResources(const machineParams& params, - const std::vector& componentList) throw(ResourcesException); + GetFittingResources(const machineParams& params) throw(ResourcesException); - std::string FindFirst(const std::vector& listOfMachines); - std::string FindNext(const std::vector& listOfMachines); - std::string FindBest(const std::vector& listOfMachines); + std::string Find(const std::string& policy, const std::vector& listOfMachines); int AddResourceInCatalog (const machineParams& paramsOfNewResources, - const std::vector& modulesOnNewResources, + const std::vector& componentsOnNewResources, const char *alias, const char *userName, AccessModeType mode, @@ -96,7 +95,7 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp const char *OS) const throw(ResourcesException); - void KeepOnlyResourcesWithModule(std::vector& hosts, + void KeepOnlyResourcesWithComponent(std::vector& hosts, const std::vector& componentList) const throw(ResourcesException); @@ -109,7 +108,8 @@ class RESOURCESMANAGER_EXPORT ResourcesManager_cpp //! will contain the informations on the data type catalog(after parsing) MapOfParserResourcesType _resourcesBatchList; - SALOME_LoadRateManager _dynamicResourcesSelecter; + //! a map that contains all the available load rate managers (the key is the name) + std::map _resourceManagerMap; //! different behaviour if $APPLI exists (SALOME Application) bool _isAppliSalomeDefined; diff --git a/src/ResourcesManager/SALOME_LoadRateManager.cxx b/src/ResourcesManager/SALOME_LoadRateManager.cxx index 5865483a6..c422a3fd0 100644 --- a/src/ResourcesManager/SALOME_LoadRateManager.cxx +++ b/src/ResourcesManager/SALOME_LoadRateManager.cxx @@ -25,7 +25,8 @@ using namespace std; -string SALOME_LoadRateManager::FindFirst(const vector& hosts) +string LoadRateManagerFirst::Find(const vector& hosts, + MapOfParserResourcesType& resList) { if (hosts.size() == 0) return string(""); @@ -33,7 +34,8 @@ string SALOME_LoadRateManager::FindFirst(const vector& hosts) return string(hosts[0]); } -string SALOME_LoadRateManager::FindNext(const vector& hosts,MapOfParserResourcesType& resList) +string LoadRateManagerCycl::Find(const vector& hosts, + MapOfParserResourcesType& resList) { static int imachine = 0; static int iproc = 0; @@ -52,15 +54,40 @@ string SALOME_LoadRateManager::FindNext(const vector& hosts,MapOfParserR else{ iproc = 1; imachine++; - if(imachine == hosts.size()) - imachine = 0; + if(imachine >= hosts.size()) + imachine = 0; return string(hosts[imachine]); } } } -string SALOME_LoadRateManager::FindBest(const vector& hosts) +string LoadRateManagerAltCycl::Find(const vector& hosts, + MapOfParserResourcesType& resList) { - // for the moment then "maui" will be used for dynamic selection ... - return FindFirst(hosts); + if (hosts.size() == 0) + return string(""); + + std::string selected=hosts[0]; + int uses=0; + if(_numberOfUses.count(selected) != 0) + uses=_numberOfUses[selected]; + else + uses=0; + + for (std::vector::const_iterator iter = hosts.begin(); iter != hosts.end(); iter++) + { + std::string machine=*iter; + if(_numberOfUses.count(machine) == 0) + _numberOfUses[machine]=0; + if(_numberOfUses[machine] < uses) + { + selected=machine; + uses=_numberOfUses[machine]; + } + } + + _numberOfUses[selected]=_numberOfUses[selected]+1; + std::cerr << "selected: " << selected << " " << _numberOfUses[selected] << std::endl; + return selected; } + diff --git a/src/ResourcesManager/SALOME_LoadRateManager.hxx b/src/ResourcesManager/SALOME_LoadRateManager.hxx index 4a43bd7e3..af167bef8 100644 --- a/src/ResourcesManager/SALOME_LoadRateManager.hxx +++ b/src/ResourcesManager/SALOME_LoadRateManager.hxx @@ -24,15 +24,37 @@ #include "ResourcesManager_Defs.hxx" #include +#include #include "SALOME_ResourcesCatalog_Parser.hxx" -class RESOURCESMANAGER_EXPORT SALOME_LoadRateManager - { +class RESOURCESMANAGER_EXPORT LoadRateManager +{ + public: + virtual std::string Find(const std::vector& hosts, + MapOfParserResourcesType& resList){return "";}; +}; + +class RESOURCESMANAGER_EXPORT LoadRateManagerFirst:public LoadRateManager +{ + public: + virtual std::string Find(const std::vector& hosts, + MapOfParserResourcesType& resList); +}; + +class RESOURCESMANAGER_EXPORT LoadRateManagerCycl :public LoadRateManager +{ + public: + virtual std::string Find(const std::vector& hosts, + MapOfParserResourcesType& resList); +}; +class RESOURCESMANAGER_EXPORT LoadRateManagerAltCycl :public LoadRateManager +{ public: - std::string FindFirst(const std::vector& hosts); - std::string FindNext(const std::vector& hosts,MapOfParserResourcesType& resList); - std::string FindBest(const std::vector& hosts); - }; + virtual std::string Find(const std::vector& hosts, + MapOfParserResourcesType& resList); + protected: + std::map _numberOfUses; +}; #endif diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index a80bc83bf..e990944c0 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -59,6 +59,8 @@ SALOME_ResourcesCatalog_Handler(MapOfParserResourcesType& resources_list, test_appli_path = "appliPath"; test_modules = "modules"; test_module_name = "moduleName"; + test_components = "component"; + test_component_name = "name"; test_os = "OS"; test_mem_in_mb = "memInMB"; test_cpu_freq_mhz = "CPUFreqMHz"; @@ -277,18 +279,42 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) xmlFree(nb_of_proc_per_node); } - // Process modules + // Process components xmlNodePtr aCurSubNode = aCurNode->xmlChildrenNode; while(aCurSubNode != NULL) { - if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_components) ) { + //If a component is given, it is in a module with the same name + //except if the module name is given + if (xmlHasProp(aCurSubNode, (const xmlChar*)test_component_name)) + { + xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_component_name); + std::string aComponentName = (const char*)component_name; + _resource.ComponentsList.push_back(aComponentName); + if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) + { + xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aModuleName = (const char*)module_name; + _resource.ModulesList.push_back(aModuleName); + xmlFree(module_name); + } + else + _resource.ModulesList.push_back(aComponentName); + xmlFree(component_name); + } + } + else if ( !xmlStrcmp(aCurSubNode->name, (const xmlChar*)test_modules) ) + { + // If a module is given, we create an entry in componentsList and modulesList + // with the same name (module == component) if (xmlHasProp(aCurSubNode, (const xmlChar*)test_module_name)) { - xmlChar* module_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); - std::string aModuleName = (const char*)module_name; - _resource.ModulesList.push_back(aModuleName); - xmlFree(module_name); + xmlChar* component_name = xmlGetProp(aCurSubNode, (const xmlChar*)test_module_name); + std::string aComponentName = (const char*)component_name; + _resource.ComponentsList.push_back(aComponentName); + _resource.ModulesList.push_back(aComponentName); + xmlFree(component_name); } } aCurSubNode = aCurSubNode->next; @@ -315,13 +341,14 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) } else { - _resources_list[_resource.HostName] = _resource; if(_resource.HostName == "localhost") { _resource.HostName = Kernel_Utils::GetHostname(); _resource.DataForSort._hostName = Kernel_Utils::GetHostname(); _resources_list[Kernel_Utils::GetHostname()] = _resource; } + else + _resources_list[_resource.HostName] = _resource; } } else @@ -443,12 +470,12 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); for (vector::const_iterator iter2 = - (*iter).second.ModulesList.begin(); - iter2 != (*iter).second.ModulesList.end(); + (*iter).second.ComponentsList.begin(); + iter2 != (*iter).second.ComponentsList.end(); iter2++) { - node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); - xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str()); + node1 = xmlNewChild(node, NULL, BAD_CAST test_components, NULL); + xmlNewProp(node1, BAD_CAST test_component_name, BAD_CAST (*iter2).c_str()); } xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); @@ -532,12 +559,12 @@ void SALOME_ResourcesCatalog_Handler::PrepareDocToXmlFile(xmlDocPtr theDoc) xmlNewProp(node, BAD_CAST test_user_name, BAD_CAST (*iter).second.UserName.c_str()); for (vector::const_iterator iter2 = - (*iter).second.ModulesList.begin(); - iter2 != (*iter).second.ModulesList.end(); + (*iter).second.ComponentsList.begin(); + iter2 != (*iter).second.ComponentsList.end(); iter2++) { - node1 = xmlNewChild(node, NULL, BAD_CAST test_modules, NULL); - xmlNewProp(node1, BAD_CAST test_module_name, BAD_CAST (*iter2).c_str()); + node1 = xmlNewChild(node, NULL, BAD_CAST test_components, NULL); + xmlNewProp(node1, BAD_CAST test_component_name, BAD_CAST (*iter2).c_str()); } xmlNewProp(node, BAD_CAST test_os, BAD_CAST (*iter).second.OS.c_str()); diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx index 35cd21296..a48dded3c 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.hxx @@ -54,7 +54,7 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler void PrepareDocToXmlFile(xmlDocPtr theDoc); private : - std::string previous_module_name; + std::string previous_component_name; ParserResourcesType _resource; MapOfParserResourcesType& _resources_list; @@ -71,8 +71,11 @@ class RESOURCESMANAGER_EXPORT SALOME_ResourcesCatalog_Handler const char *test_mpi; const char *test_user_name; const char *test_appli_path; + // for compatibility const char *test_modules; const char *test_module_name; + const char *test_components; + const char *test_component_name; const char *test_os; const char *test_mem_in_mb; const char *test_cpu_freq_mhz; diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx index fff95034a..510a00437 100644 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Parser.cxx @@ -133,10 +133,10 @@ void ParserResourcesType::Print() const "OS : " << OS << endl << "batchQueue : " << batchQueue << endl << "userCommands : " << userCommands << endl << - "Modules : " << endl; + "Components : " << endl; - for(int i=0;i ComponentsList; std::vector ModulesList; std::string OS; std::string batchQueue; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.cxx b/src/ResourcesManager/SALOME_ResourcesManager.cxx index 408c2250a..3531bc30b 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.cxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.cxx @@ -66,9 +66,7 @@ SALOME_ResourcesManager(CORBA::ORB_ptr orb, _poa = PortableServer::POA::_duplicate(poa) ; PortableServer::ObjectId_var id = _poa->activate_object(this); CORBA::Object_var obj = _poa->id_to_reference(id); - Engines::SalomeLauncher_var refContMan = - Engines::SalomeLauncher::_narrow(obj); - + Engines::ResourcesManager_var refContMan = Engines::ResourcesManager::_narrow(obj); _NS->Register(refContMan,_ResourcesManagerNameInNS); MESSAGE("SALOME_ResourcesManager constructor end"); } @@ -124,26 +122,24 @@ void SALOME_ResourcesManager::Shutdown() _NS->Destroy_Name(_ResourcesManagerNameInNS); PortableServer::ObjectId_var oid = _poa->servant_to_id(this); _poa->deactivate_object(oid); - //_remove_ref(); } //============================================================================= +//! get the name of resources fitting the specified constraints (params) /*! - * get the list of name of ressources fitting for the specified module. * If hostname specified, check it is local or known in resources catalog. * * Else * - select first machines with corresponding OS (all machines if * parameter OS empty), - * - then select the sublist of machines on witch the module is known + * - then select the sublist of machines on which the component is known * (if the result is empty, that probably means that the inventory of - * modules is probably not done, so give complete list from previous step) + * components is probably not done, so give complete list from previous step) */ //============================================================================= Engines::MachineList * -SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params, - const Engines::CompoList& componentList) +SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& params) { // MESSAGE("ResourcesManager::GetFittingResources"); machineParams p; @@ -154,13 +150,15 @@ SALOME_ResourcesManager::GetFittingResources(const Engines::MachineParameters& p p.cpu_clock = params.cpu_clock; p.mem_mb = params.mem_mb; - vector cl; - for(unsigned int i=0;i vec = _rm.GetFittingResources(p,cl); + vector vec = _rm.GetFittingResources(p); ret->length(vec.size()); for(unsigned int i=0;i ml; + for(unsigned int i=0;icontainer_name = CORBA::string_dup(""); + Engines::MachineDefinition *p_ptr = new Engines::MachineDefinition; p_ptr->hostname = CORBA::string_dup(resource.HostName.c_str()); p_ptr->alias = CORBA::string_dup(resource.Alias.c_str()); if( resource.Protocol == rsh ) @@ -202,9 +208,9 @@ Engines::MachineParameters* SALOME_ResourcesManager::GetMachineParameters(const p_ptr->protocol = "ssh"; p_ptr->username = CORBA::string_dup(resource.UserName.c_str()); p_ptr->applipath = CORBA::string_dup(resource.AppliPath.c_str()); - p_ptr->modList.length(resource.ModulesList.size()); - for(unsigned int i=0;imodList[i] = CORBA::string_dup(resource.ModulesList[i].c_str()); + p_ptr->componentList.length(resource.ComponentsList.size()); + for(unsigned int i=0;icomponentList[i] = CORBA::string_dup(resource.ComponentsList[i].c_str()); p_ptr->OS = CORBA::string_dup(resource.OS.c_str()); p_ptr->mem_mb = resource.DataForSort._memInMB; p_ptr->cpu_clock = resource.DataForSort._CPUFreqMHz; diff --git a/src/ResourcesManager/SALOME_ResourcesManager.hxx b/src/ResourcesManager/SALOME_ResourcesManager.hxx index 9fcf8a1c6..c8ec2a911 100644 --- a/src/ResourcesManager/SALOME_ResourcesManager.hxx +++ b/src/ResourcesManager/SALOME_ResourcesManager.hxx @@ -64,12 +64,12 @@ class SALOMERESOURCESMANAGER_EXPORT SALOME_ResourcesManager: ~SALOME_ResourcesManager(); Engines::MachineList * - GetFittingResources(const Engines::MachineParameters& params, - const Engines::CompoList& componentList); + GetFittingResources(const Engines::MachineParameters& params); char* FindFirst(const Engines::MachineList& listOfMachines); + char* Find(const char *policy, const Engines::MachineList& listOfMachines); - Engines::MachineParameters* GetMachineParameters(const char *hostname); + Engines::MachineDefinition* GetMachineParameters(const char *hostname); void Shutdown(); diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index c56b74553..73c36db8d 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -47,7 +47,7 @@ salomeinclude_HEADERS= \ SALOMEDS_Defines.hxx # Scripts to be installed -dist_salomescript_DATA = SALOME_DriverPy.py +dist_salomescript_PYTHON = SALOME_DriverPy.py # # =============================================================== diff --git a/src/SALOMEDS/SALOMEDS_Defines.hxx b/src/SALOMEDS/SALOMEDS_Defines.hxx index 1c4475e4c..45d2c7dd3 100755 --- a/src/SALOMEDS/SALOMEDS_Defines.hxx +++ b/src/SALOMEDS/SALOMEDS_Defines.hxx @@ -27,7 +27,7 @@ #define _SALOMEDS_Defines_HXX_ #ifdef WIN32 -# ifdef SALOMEDS_EXPORTS +# if defined SALOMEDS_EXPORTS || defined SalomeDS_EXPORTS # define SALOMEDS_EXPORT __declspec( dllexport ) # else # define SALOMEDS_EXPORT __declspec( dllimport ) diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 43ce2d59b..3ec35db2b 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -667,16 +667,23 @@ void SALOMEDS_Study_i::Close() if (sco->ComponentIOR(IOREngine)) { // we have found the associated engine to write the data MESSAGE ( "We have found an engine for data type :"<< sco->ComponentDataType()); - CORBA::Object_var obj = _orb->string_to_object(IOREngine); - if (!CORBA::is_nil(obj)) { - SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; - - if (!anEngine->_is_nil()) { - SALOMEDS::unlock(); - anEngine->Close(sco); - SALOMEDS::lock(); - } - } + //_narrow can throw a corba exception + try + { + CORBA::Object_var obj = _orb->string_to_object(IOREngine); + if (!CORBA::is_nil(obj)) + { + SALOMEDS::Driver_var anEngine = SALOMEDS::Driver::_narrow(obj) ; + if (!anEngine->_is_nil()) + { + SALOMEDS::unlock(); + anEngine->Close(sco); + SALOMEDS::lock(); + } + } + } + catch (CORBA::Exception&) + {/*pass*/ } } } diff --git a/src/SALOMEDS/Test/Makefile.am b/src/SALOMEDS/Test/Makefile.am index c052e3b70..f1c357707 100644 --- a/src/SALOMEDS/Test/Makefile.am +++ b/src/SALOMEDS/Test/Makefile.am @@ -35,7 +35,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= SALOMEDSTest.hxx # Scripts to be installed -dist_salomescript_SCRIPTS = TestSALOMEDS.py +dist_salomescript_PYTHON = TestSALOMEDS.py # # =============================================================== diff --git a/src/SALOMEDSClient/SALOMEDSClient_definitions.hxx b/src/SALOMEDSClient/SALOMEDSClient_definitions.hxx index b9942098a..2d63937ba 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_definitions.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_definitions.hxx @@ -23,7 +23,7 @@ #define SALOMEDSCLIENT_DEF_HXX #ifdef WIN32 -# ifdef SALOMEDSCLIENT_EXPORTS +# if defined SALOMEDSCLIENT_EXPORTS || defined SalomeDSClient_EXPORTS # define SALOMEDSCLIENT_EXPORT __declspec( dllexport ) # else # define SALOMEDSCLIENT_EXPORT __declspec( dllimport ) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx index 5b6ee955d..65905c915 100755 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Defines.hxx @@ -27,7 +27,7 @@ #define _SALOMEDSImpl_Defines_HXX_ #ifdef WIN32 -# if defined SALOMEDSIMPL_EXPORTS +# if defined SALOMEDSIMPL_EXPORTS || defined SalomeDSImpl_EXPORTS # define SALOMEDSIMPL_EXPORT __declspec( dllexport ) # else # define SALOMEDSIMPL_EXPORT __declspec( dllimport ) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 063562ae3..2fa36c294 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -1210,13 +1210,24 @@ bool SALOMEDSImpl_Study::DumpStudy(const string& thePath, //set sys.path and add a creation of the study. fp << GetDumpStudyComment() << endl << endl; fp << "import sys" << endl; + fp << "import os.path" << endl; fp << "import " << aBatchModeScript << endl << endl; fp << aBatchModeScript << ".salome_init()" << endl << endl; - fp << _GetNoteBookAccess(); - - fp << "sys.path.insert( 0, \'" << thePath << "\')" << endl << endl; + fp << _GetNoteBookAccess() << endl; + + // IPAL21005 (Dump/load python script works only with absolute path) + // try to use '__file__' to get an absolute path to the generated scripts + // or use the path passed to this method (case of using execfile() command) + fp << "#Get absolute path to generated scripts:" << endl; + fp << "try:" << endl; + fp << " absPath = os.path.dirname(__file__)" << endl; + fp << "except NameError:" << endl; + fp << " absPath = \'" << thePath << "\'" << endl; + fp << " pass" << endl; + fp << "sys.path.insert( 0, absPath )" << endl << endl; + //fp << "sys.path.insert( 0, \'" << thePath << "\')" << endl << endl; //Dump NoteBook Variables fp << _GetStudyVariablesScript(); diff --git a/src/SALOMEDSImpl/Test/Makefile.am b/src/SALOMEDSImpl/Test/Makefile.am index 3b02fb3c4..3ac0c73a5 100644 --- a/src/SALOMEDSImpl/Test/Makefile.am +++ b/src/SALOMEDSImpl/Test/Makefile.am @@ -35,7 +35,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= SALOMEDSImplTest.hxx # Scripts to be installed -dist_salomescript_SCRIPTS = TestSALOMEDSImpl.py +dist_salomescript_PYTHON = TestSALOMEDSImpl.py # # =============================================================== diff --git a/src/SALOMELocalTrace/Test/Makefile.am b/src/SALOMELocalTrace/Test/Makefile.am index e97bbb260..e5a8fd956 100644 --- a/src/SALOMELocalTrace/Test/Makefile.am +++ b/src/SALOMELocalTrace/Test/Makefile.am @@ -39,7 +39,7 @@ SRCROOT=$(srcdir)/../.. salomeinclude_HEADERS = SALOMELocalTraceTest.hxx # Executable scripts to be installed -dist_salomescript_SCRIPTS = TestSALOMELocalTrace.py +dist_salomescript_PYTHON = TestSALOMELocalTrace.py # # =============================================================== diff --git a/src/SALOMETraceCollector/Test/Makefile.am b/src/SALOMETraceCollector/Test/Makefile.am index 9ef92294d..fbe2bd53d 100644 --- a/src/SALOMETraceCollector/Test/Makefile.am +++ b/src/SALOMETraceCollector/Test/Makefile.am @@ -38,7 +38,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= SALOMETraceCollectorTest.hxx # Scripts to be installed -dist_salomescript_SCRIPTS = TestSALOMETraceCollector.py +dist_salomescript_PYTHON = TestSALOMETraceCollector.py # diff --git a/src/TOOLSDS/SALOMEDS_Tool.hxx b/src/TOOLSDS/SALOMEDS_Tool.hxx index 2184143e9..427762d6d 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.hxx +++ b/src/TOOLSDS/SALOMEDS_Tool.hxx @@ -37,7 +37,7 @@ #include CORBA_SERVER_HEADER(SALOMEDS) #ifdef WIN32 -# ifdef TOOLSDS_EXPORTS +# if defined TOOLSDS_EXPORTS # define TOOLSDS_EXPORT __declspec( dllexport ) # else # define TOOLSDS_EXPORT __declspec( dllimport ) diff --git a/src/TestContainer/Makefile.am b/src/TestContainer/Makefile.am index 144cbe389..f69747c1c 100644 --- a/src/TestContainer/Makefile.am +++ b/src/TestContainer/Makefile.am @@ -34,7 +34,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # # header files # Scripts to be installed -dist_salomescript_DATA = \ +dist_salomescript_PYTHON = \ SALOME_TestComponentPy.py \ TestComponentPy.py \ TestLogger.py diff --git a/src/UnitTests/Makefile.am b/src/UnitTests/Makefile.am index 3e64bf565..5a9efeced 100644 --- a/src/UnitTests/Makefile.am +++ b/src/UnitTests/Makefile.am @@ -33,7 +33,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # # Executable scripts to be installed -dist_salomescript_SCRIPTS = UnitTests.py +dist_salomescript_PYTHON = UnitTests.py # # =============================================================== diff --git a/src/Utils/Makefile.am b/src/Utils/Makefile.am index 7ef2a59e2..7b73b1066 100644 --- a/src/Utils/Makefile.am +++ b/src/Utils/Makefile.am @@ -43,7 +43,7 @@ salomeinclude_HEADERS =\ SALOME_Utils.hxx # Scripts to be exported -dist_salomescript_DATA =\ +dist_salomescript_PYTHON =\ Utils_Identity.py \ SALOME_utilities.py diff --git a/src/Utils/Test/Makefile.am b/src/Utils/Test/Makefile.am index befa572ae..fe50c0501 100644 --- a/src/Utils/Test/Makefile.am +++ b/src/Utils/Test/Makefile.am @@ -37,7 +37,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am salomeinclude_HEADERS= UtilsTest.hxx # Scripts to be installed -dist_salomescript_SCRIPTS = TestUtils.py +dist_salomescript_PYTHON = TestUtils.py # -- 2.39.2