From: vsr Date: Mon, 10 Feb 2014 14:35:14 +0000 (+0400) Subject: Improve build procedure X-Git-Tag: V1_0_0~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=53a807bd760c6a1fa717fa1a45193509d4705b3a;p=tools%2Fsimanio.git Improve build procedure --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 58f7a66..cfb8da2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,98 @@ -project(SimanIO) -cmake_minimum_required(VERSION 2.4) -add_subdirectory(src lib) +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) +PROJECT(SimanIO C CXX) +# Versioning +# =========== +# Project name, upper case +STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) + +SET(${PROJECT_NAME_UC}_MAJOR_VERSION 0) +SET(${PROJECT_NAME_UC}_MINOR_VERSION 1) +SET(${PROJECT_NAME_UC}_PATCH_VERSION 0) +SET(${PROJECT_NAME_UC}_VERSION + ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION}) + +# Our own set of macros: +LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) +INCLUDE(SimanIOMacros) + +# User options +# ============ +IF(WIN32 AND NOT CYGWIN) + SET(INSTALL_CMAKE_CONFIG_DIR cmake) +ELSE() + SET(INSTALL_CMAKE_CONFIG_DIR share/cmake/simanio) +ENDIF() +SET(INSTALL_INCLUDE_DIR include) + +# Prerequisites detection: +# ======================== +FIND_PACKAGE(SimanIOWSO2 REQUIRED) + +# Configure +# ========= +CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/SimanIO_Version.hxx.in ${CMAKE_CURRENT_BINARY_DIR}/src/SimanIO_Version.hxx @ONLY) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/SimanIO_Version.hxx DESTINATION include) + +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(scripts) + +# Export logic +# ============ +INCLUDE(CMakePackageConfigHelpers) + +# Add all targets to the build-tree export set +EXPORT(TARGETS SimanIO FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake) + +# Create the configuration files: +# - in the build tree: + +# Ensure the variables are always defined for the configure: +SET(WSO2_ROOT_DIR "${WSO2_ROOT_DIR}") + +SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include") +CONFIGURE_PACKAGE_CONFIG_FILE(misc/${PROJECT_NAME}Config.cmake.in + ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}" + PATH_VARS CONF_INCLUDE_DIRS INSTALL_CMAKE_CONFIG_DIR CMAKE_INSTALL_PREFIX WSO2_ROOT_DIR) + +# - in the install tree: +# Get the relative path of the include directory so +# we can register it in the generated configuration files: +SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}") +CONFIGURE_PACKAGE_CONFIG_FILE(misc/${PROJECT_NAME}Config.cmake.in + ${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}" + PATH_VARS CONF_INCLUDE_DIRS INSTALL_CMAKE_CONFIG_DIR CMAKE_INSTALL_PREFIX WSO2_ROOT_DIR) + +WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${${PROJECT_NAME_UC}_VERSION} + COMPATIBILITY AnyNewerVersion) + +# Install the CMake configuration files: +INSTALL(FILES + "${PROJECT_BINARY_DIR}/to_install/${PROJECT_NAME}Config.cmake" + "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}") + +# Install the export set for use with the install-tree +INSTALL(EXPORT ${PROJECT_NAME}Targets DESTINATION "${INSTALL_CMAKE_CONFIG_DIR}") diff --git a/CMakeModules/FindSimanIOWSO2.cmake b/CMakeModules/FindSimanIOWSO2.cmake new file mode 100644 index 0000000..2a30aaa --- /dev/null +++ b/CMakeModules/FindSimanIOWSO2.cmake @@ -0,0 +1,25 @@ +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +# WSO2 WSF/C++ cpp detection for SimanIO +# +# !! Please read the generic detection procedure in SimanIOMacros.cmake !! +# +SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(WSO2 WSO2_INCLUDE_DIR 1) +MARK_AS_ADVANCED(WSO2_LIBRARIES WSO2_INCLUDES WSO2_INCLUDE_DIR) diff --git a/CMakeModules/FindWSO2.cmake b/CMakeModules/FindWSO2.cmake new file mode 100644 index 0000000..7ebffd6 --- /dev/null +++ b/CMakeModules/FindWSO2.cmake @@ -0,0 +1,60 @@ +# - Find WSO2 WSF/C++ +# This module finds an installed WSO2 WSF/C++ using the variable WSO2_ROOT_DIR +# as a lookup path. +# It sets the following variables: +# WSO2_FOUND - set to true if WSO2 WSF/C++ is found +# WSO2_INCLUDE_DIR - the directories where the main include files are located +# WSO2_INCLUDES - the list of directories for headers search path +# WSO2_LIBRARIES - WSO2 WSF/C++ libraries to be linked against + +############################################################# +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# +############################################################# + +IF (NOT WSO2_FIND_QUIETLY) + MESSAGE(STATUS "Looking for WSO2 WSF/C++...") +ENDIF () + +SET(WSO2_ROOT_DIR $ENV{WSO2_ROOT_DIR}) + +IF(WSO2_ROOT_DIR) + LIST(APPEND CMAKE_PREFIX_PATH "${WSO2_ROOT_DIR}") +ENDIF(WSO2_ROOT_DIR) + +FIND_PATH(WSO2_INCLUDE_DIR WSFDefines.h PATH_SUFFIXES include) +# TODO: detect axis includes automatically, without below hardcoded search path +FIND_PATH(WSO2_INCLUDE_DIR_axis2 axutil_version.h PATH_SUFFIXES include include/axis2-1.6.0) + +SET(WSO2_INCLUDES ${WSO2_INCLUDE_DIR}) +IF(WSO2_INCLUDE_DIR_axis2) + LIST(APPEND WSO2_INCLUDES ${WSO2_INCLUDE_DIR_axis2} ${WSO2_INCLUDE_DIR_axis2}/platforms) +ENDIF() + +FIND_LIBRARY(WSO2_LIBRARY_axis2_axiom NAMES axis2_axiom) +FIND_LIBRARY(WSO2_LIBRARY_axis2_engine NAMES axis2_engine) +FIND_LIBRARY(WSO2_LIBRARY_wso2_wsf NAMES wso2_wsf) + +SET(WSO2_LIBRARIES) +SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_axiom}) +SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_axis2_engine}) +SET(WSO2_LIBRARIES ${WSO2_LIBRARIES} ${WSO2_LIBRARY_wso2_wsf}) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(WSO2 REQUIRED_VARS WSO2_INCLUDE_DIR WSO2_INCLUDES WSO2_LIBRARIES) diff --git a/CMakeModules/SimanIOMacros.cmake b/CMakeModules/SimanIOMacros.cmake new file mode 100644 index 0000000..78fde01 --- /dev/null +++ b/CMakeModules/SimanIOMacros.cmake @@ -0,0 +1,302 @@ +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +### +# SALOME_CHECK_EQUAL_PATHS(result path1 path2) +# Check if two paths are identical, resolving links. If the paths do not exist a simple +# text comparison is performed. +# result is a boolean. +### +MACRO(SALOME_CHECK_EQUAL_PATHS varRes path1 path2) + SET("${varRes}" OFF) + IF(EXISTS "${path1}") + GET_FILENAME_COMPONENT(_tmp1 "${path1}" REALPATH) + ELSE() + SET(_tmp1 "${path1}") + ENDIF() + + IF(EXISTS "${path2}") + GET_FILENAME_COMPONENT(_tmp2 "${path2}" REALPATH) + ELSE() + SET(_tmp2 "${path2}") + ENDIF() + + IF("${_tmp1}" STREQUAL "${_tmp2}") + SET("${varRes}" ON) + ENDIF() +# MESSAGE(${${varRes}}) +ENDMACRO() + +#### +# SALOME_FIND_PACKAGE(englobingPackageName standardPackageName modus [onlyTryQuietly]) +# +# example: SALOME_FIND_PACKAGE(SalomeVTK VTK CONFIG) +# +# Encapsulate the call to the standard FIND_PACKAGE(standardPackageName) passing all the options +# given when calling the command FIND_PACKAGE(SimanIOXyz). Those options are stored implicitly in +# CMake variables: Xyz_FIND_QUIETLY, Xyz_FIND_REQUIRED, etc ... +# +# If a list of components was specified when invoking the initial FIND_PACKAGE(SimanIOXyz ...) this is +# also handled properly. +# +# Modus is either MODULE or CONFIG (cf standard FIND_PACKAGE() documentation). +# The last argument is optional and if set to TRUE will force the search to be OPTIONAL and QUIET. +# If the package is looked for in CONFIG mode, the standard system paths are skipped. If you still want a +# system installation to be found in this mode, you have to set the ROOT_DIR variable explicitly to /usr (for +# example). +# +# This macro is to be called from within the FindSimanIOXyz.cmake files (where Xyz is some package to be detected). +# +#### +MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode) + SET(_OPT_ARG ${ARGV3}) + # Only bother if the package was not already found: + # Some old packages use the lower case version - standard should be to always use + # upper case: + STRING(TOUPPER ${stdPkg} stdPkgUC) + IF(NOT (${stdPkg}_FOUND OR ${stdPkgUC}_FOUND)) + IF(${englobPkg}_FIND_QUIETLY OR _OPT_ARG) + SET(_tmp_quiet "QUIET") + ELSE() + SET(_tmp_quiet) + ENDIF() + IF(${englobPkg}_FIND_REQUIRED AND NOT _OPT_ARG) + SET(_tmp_req "REQUIRED") + ELSE() + SET(_tmp_req) + ENDIF() + IF(${englobPkg}_FIND_VERSION_EXACT) + SET(_tmp_exact "EXACT") + ELSE() + SET(_tmp_exact) + ENDIF() + + # Call the CMake FIND_PACKAGE() command: + STRING(TOLOWER ${stdPkg} _pkg_lc) + IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG")) + # Hope to find direclty a CMake config file, indicating the SALOME CMake file + # paths (the command already looks in places like "share/cmake", etc ... by default) + # Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows) + # looking into a previous CMake build done via a GUI, or into the Win registry. + # NO_CMAKE_SYSTEM_PATH and NO_SYSTEM_ENVIRONMENT_PATH ensure any _system_ files like 'xyz-config.cmake' + # don't get loaded (typically Boost). To force their loading, set the XYZ_ROOT_DIR variable to '/usr'. + # See documentation of FIND_PACKAGE() for full details. + + # Do we need to call the signature using components? + IF(${englobPkg}_FIND_COMPONENTS) + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS} + NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH + NO_SYSTEM_ENVIRONMENT_PATH) + ELSE() + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + NO_MODULE ${_tmp_quiet} ${_tmp_req} + NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PATH + NO_SYSTEM_ENVIRONMENT_PATH) + ENDIF() + MARK_AS_ADVANCED(${stdPkg}_DIR) + + ELSEIF("${mode}" STREQUAL "MODULE") + + # Do we need to call the signature using components? + IF(${englobPkg}_FIND_COMPONENTS) + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}) + ELSE() + FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} + MODULE ${_tmp_quiet} ${_tmp_req}) + ENDIF() + + ELSE() + + MESSAGE(FATAL_ERROR "Invalid mode argument in the call to the macro SALOME_FIND_PACKAGE. Should be CONFIG or MODULE.") + + ENDIF() + + ENDIF() +ENDMACRO() + + +#################################################################### +# SALOME_FIND_PACKAGE_DETECT_CONFLICTS(pkg referenceVariable upCount) +# pkg : name of the system package to be detected +# referenceVariable: variable containing a path that can be browsed up to +# retrieve the package root directory (xxx_ROOT_DIR) +# upCount : number of times we have to go up from the path +# to obtain the package root directory. +# +# For example: SALOME_FIND_PACKAGE_DETECT_CONFLICTS(SWIG SWIG_EXECUTABLE 2) +# +# Generic detection (and conflict check) procedure for package XYZ: +# 1. Load a potential env variable XYZ_ROOT_DIR as a default choice for the cache entry XYZ_ROOT_DIR +# If empty, load a potential XYZ_ROOT_DIR_EXP as default value (path exposed by another package depending +# directly on XYZ) +# 2. Invoke FIND_PACKAGE() in this order: +# * in CONFIG mode first (if possible): priority is given to a potential +# "XYZ-config.cmake" file +# * then switch to the standard MODULE mode, appending on CMAKE_PREFIX_PATH +# the above XYZ_ROOT_DIR variable +# 3. Extract the path actually found into a temp variable _XYZ_TMP_DIR +# 4. Warn if XYZ_ROOT_DIR is set and doesn't match what was found (e.g. when CMake found the system installation +# instead of what is pointed to by XYZ_ROOT_DIR - happens when a typo in the content of XYZ_ROOT_DIR). +# 5. Conflict detection: +# * check the temp variable against a potentially existing XYZ_ROOT_DIR_EXP +# 6. Finally expose what was *actually* found in XYZ_ROOT_DIR. +# 7. Specific stuff: for example exposing a prerequisite of XYZ to the rest of the world for future +# conflict detection. This is added after the call to the macro by the callee. +# +MACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS pkg referenceVariable upCount) + ## + ## 0. Initialization + ## + + # Package name, upper case + STRING(TOUPPER ${pkg} pkg_UC) + + ## + ## 1. Load environment or any previously detected root dir for the package + ## + IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) + FILE(TO_CMAKE_PATH "$ENV{${pkg_UC}_ROOT_DIR}" _${pkg_UC}_ROOT_DIR_ENV) + SET(_dflt_value "${_${pkg_UC}_ROOT_DIR_ENV}") + ELSE() + # will be blank if no package was previously loaded: + SET(_dflt_value "${${pkg_UC}_ROOT_DIR_EXP}") + ENDIF() + + # Detect if the variable has been set on the command line or elsewhere: + IF(DEFINED ${pkg_UC}_ROOT_DIR) + SET(_var_already_there TRUE) + ELSE() + SET(_var_already_there FALSE) + ENDIF() + # Make cache entry + SET(${pkg_UC}_ROOT_DIR "${_dflt_value}" CACHE PATH "Path to ${pkg_UC} directory") + + ## + ## 2. Find package - try CONFIG mode first (i.e. looking for XYZ-config.cmake) + ## + + # Override the variable - don't append to it, as it would give precedence + # to what was stored there before! + SET(CMAKE_PREFIX_PATH "${${pkg_UC}_ROOT_DIR}") + + # Try find_package in config mode. This has the priority, but is + # performed QUIET and not REQUIRED: + SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} NO_MODULE TRUE) + + IF (${pkg_UC}_FOUND OR ${pkg}_FOUND) + MESSAGE(STATUS "Found ${pkg} in CONFIG mode!") + ENDIF() + + # Otherwise try the standard way (module mode, with the standard CMake Find*** macro): + # We do it quietly to produce our own error message, except if we are in debug mode: + IF(SALOME_CMAKE_DEBUG) + SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE FALSE) + ELSE() + SALOME_FIND_PACKAGE("Salome${pkg}" ${pkg} MODULE TRUE) + ENDIF() + + # Set the "FOUND" variable for the SALOME wrapper: + IF(${pkg_UC}_FOUND OR ${pkg}_FOUND) + SET(SALOME${pkg_UC}_FOUND TRUE) + ELSE() + SET(SALOME${pkg_UC}_FOUND FALSE) + IF(NOT Salome${pkg}_FIND_QUIETLY) + IF(Salome${pkg}_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " + "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} " + "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") + ELSE() + MESSAGE(WARNING "Package ${pkg} couldn't be found - did you set the corresponing root dir correctly? " + "It currently contains ${pkg_UC}_ROOT_DIR=${${pkg_UC}_ROOT_DIR} " + "Append -DSALOME_CMAKE_DEBUG=ON on the command line if you want to see the original CMake error.") + ENDIF() + ENDIF() + ENDIF() + + IF (${pkg_UC}_FOUND OR ${pkg}_FOUND) + ## 3. Set the root dir which was finally retained by going up "upDir" times + ## from the given reference path. The variable "referenceVariable" may be a list. + ## In this case we take its first element. + + # First test if the variable exists, warn otherwise: + IF(NOT DEFINED ${referenceVariable}) + MESSAGE(WARNING "${pkg}: the reference variable '${referenceVariable}' used when calling the macro " + "SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() is not defined.") + ENDIF() + + LIST(LENGTH ${referenceVariable} _tmp_len) + IF(_tmp_len) + LIST(GET ${referenceVariable} 0 _tmp_ROOT_DIR) + ELSE() + # Note the double de-reference of "referenceVariable": + SET(_tmp_ROOT_DIR "${${referenceVariable}}") + ENDIF() + IF(${upCount}) + FOREACH(_unused RANGE 1 ${upCount}) + GET_FILENAME_COMPONENT(_tmp_ROOT_DIR "${_tmp_ROOT_DIR}" PATH) + ENDFOREACH() + ENDIF() + + ## + ## 4. Warn if CMake found something not located under ENV(XYZ_ROOT_DIR) + ## + IF(DEFINED ENV{${pkg_UC}_ROOT_DIR}) + SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${_${pkg_UC}_ROOT_DIR_ENV}") + IF(NOT _res) + MESSAGE(WARNING "${pkg} was found, but not at the path given by the " + "environment ${pkg_UC}_ROOT_DIR! Is the variable correctly set? " + "The two paths are: ${_tmp_ROOT_DIR} and: ${_${pkg_UC}_ROOT_DIR_ENV}") + + ELSE() + MESSAGE(STATUS "${pkg} found directory matches what was specified in the ${pkg_UC}_ROOT_DIR variable, all good!") + ENDIF() + ELSE() + IF(NOT _var_already_there) + MESSAGE(STATUS "Variable ${pkg_UC}_ROOT_DIR was not explicitly defined. " + "An installation was found anyway: ${_tmp_ROOT_DIR}") + ENDIF() + ENDIF() + + ## + ## 5. Conflict detection + ## From another prerequisite using the package: + ## + IF(${pkg_UC}_ROOT_DIR_EXP) + SALOME_CHECK_EQUAL_PATHS(_res "${_tmp_ROOT_DIR}" "${${pkg_UC}_ROOT_DIR_EXP}") + IF(NOT _res) + MESSAGE(WARNING "Warning: ${pkg}: detected version conflicts with a previously found ${pkg}!" + " The two paths are " ${_tmp_ROOT_DIR} " vs " ${${pkg_UC}_ROOT_DIR_EXP}) + ELSE() + MESSAGE(STATUS "${pkg} directory matches what was previously exposed by another prereq, all good!") + ENDIF() + ENDIF() + + ## + ## 6. Save the detected installation + ## + SET(${pkg_UC}_ROOT_DIR "${_tmp_ROOT_DIR}") + + ELSE() + MESSAGE(STATUS "${pkg} was not found.") + ENDIF() + + SET(Salome${pkg}_FOUND "${pkg}_FOUND") +ENDMACRO(SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS) diff --git a/misc/SimanIOConfig.cmake.in b/misc/SimanIOConfig.cmake.in new file mode 100644 index 0000000..f066615 --- /dev/null +++ b/misc/SimanIOConfig.cmake.in @@ -0,0 +1,52 @@ +# - Config file for the @PROJECT_NAME@ package +# It defines the following variables. +# Specific to the package @PROJECT_NAME@ itself: +# @PROJECT_NAME_UC@_INCLUDE_DIRS - include directories +# @PROJECT_NAME_UC@_LIBRARIES - libraries to link against +# @PROJECT_NAME_UC@_ROOT_DIR_EXP - the root path of the installation providing this CMake file +# +############################################################### +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +############################################################### + +### Initialisation performed by CONFIGURE_PACKAGE_CONFIG_FILE: +@PACKAGE_INIT@ + +### First the generic stuff for a standard module: +SET(SIMANIO_INCLUDE_DIRS "@PACKAGE_CONF_INCLUDE_DIRS@") + +# Load the dependencies for the libraries of @PROJECT_NAME@ +# (contains definitions for IMPORTED targets). This is only +# imported if we are not built as a subproject (in this case targets are already there) +IF(NOT SimanIO AND NOT @PROJECT_NAME@_BINARY_DIR) + INCLUDE("@PACKAGE_INSTALL_CMAKE_CONFIG_DIR@/@PROJECT_NAME@Targets.cmake") +ENDIF() + +# These are IMPORTED targets created by @PROJECT_NAME@Targets.cmake +SET(SIMANIO_LIBRARIES SimanIO) + +# Package root dir: +SET_AND_CHECK(SIMANIO_ROOT_DIR_EXP "@PACKAGE_CMAKE_INSTALL_PREFIX@") + +#### Now the specificities + +# Options exported by the package: + +SET_AND_CHECK(WSO2_ROOT_DIR_EXP "@PACKAGE_WSO2_ROOT_DIR@") diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt new file mode 100644 index 0000000..4ad82fa --- /dev/null +++ b/scripts/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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 +# + +# [ files to be installed ] +FILE(GLOB _install_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.sh") + +LIST(APPEND _install_FILES INSTALL_Applications.txt README) +INSTALL(FILES ${_install_FILES} DESTINATION share/simanio/misc) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7c2b65a..173f5df 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,19 +1,73 @@ -project(SimanSrc CXX) +# Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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(SimanSrc_SRCS SimanIO_Activity.cxx SimanIO_Configuration.cxx SimanIO_Document.cxx SimanIO_Link.cxx CheckIn.cpp CheckInResponse.cpp CreateConfigFile.cpp CreateConfigFileResponse.cpp GetFile.cpp GetFileResponse.cpp PutFile.cpp PutFileResponse.cpp SimanSalomeServiceStub.cpp) -set(SimanSrc_HEADERS SimanIO_Activity.hxx SimanIO_Configuration.hxx SimanIO_Document.hxx SimanIO_Link.hxx CheckIn.h CheckInResponse.h CreateConfigFile.h CreateConfigFileResponse.h GetFile.h GetFileResponse.h ISimanSalomeServiceCallback.h PutFile.h PutFileResponse.h SimanSalomeServiceStub.h) -include_directories($(PROJECT_SOURCE_DIR) $ENV{WSFCPP_HOME}/include $ENV{WSFCPP_HOME}/include/axis2-1.6.0 $ENV{WSFCPP_HOME}/include/axis2-1.6.0/platforms) +# [ additional include dirs ] +INCLUDE_DIRECTORIES( + ${WSO2_INCLUDES} + ${CMAKE_CURRENT_SOURCE_DIR} +) -add_library(SimanIO SHARED ${SimanSrc_SRCS} ${SimanSrc_HEADERS} $ENV{WSFCPP_HOME}/lib) -target_link_libraries(SimanIO $ENV{WSFCPP_HOME}/lib $ENV{WSFCPP_HOME}/lib/libaxis2_axiom.so $ENV{WSFCPP_HOME}/lib/libaxis2_engine.so $ENV{WSFCPP_HOME}/lib/libwso2_wsf.so) +# [ headers to be installed ] +SET(SimanIO_HEADERS + SimanIO_Activity.hxx + SimanIO_Configuration.hxx + SimanIO_Document.hxx + SimanIO_Link.hxx +) -install(TARGETS SimanIO DESTINATION ${CMAKE_INSTALL_PREFIX}/lib) -install(FILES ${SimanSrc_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include) - -# add_executable(TestCreateConfigFile TestCreateConfigFile.cpp) -# target_link_libraries(TestCreateConfigFile ${CMAKE_INSTALL_PREFIX}/lib/libSimanIO.so $ENV{WSFCPP_HOME}/lib/libaxis2_axiom.so $ENV{WSFCPP_HOME}/lib/libaxis2_engine.so $ENV{WSFCPP_HOME}/lib/libwso2_wsf.so) -# install(TARGETS TestCreateConfigFile DESTINATION bin) +# [ generated sources ] +# TODO: add procedure of automatic generation of the sources from the skeleton +# TODO: this will raise dependency of SimanIO on SIMAN (where skeleton file is) +# and Apache Axis2/Java (which is used to generate wrappings) +SET(_generated_SOURCES + CheckIn.cpp + CheckInResponse.cpp + CreateConfigFile.cpp + CreateConfigFileResponse.cpp + GetFile.cpp + GetFileResponse.cpp + PutFile.cpp + PutFileResponse.cpp + SimanSalomeServiceStub.cpp +) +# [ static sources ] +SET(_other_SOURCES + SimanIO_Activity.cxx + SimanIO_Configuration.cxx + SimanIO_Document.cxx + SimanIO_Link.cxx +) +# [ all sources to be compiled ] +SET(SimanIO_SOURCES + ${_generated_SOURCES} + ${_other_SOURCES} +) +# [ target: library ] +ADD_LIBRARY(SimanIO SHARED ${SimanIO_SOURCES}) +TARGET_LINK_LIBRARIES(SimanIO ${PLATFORM_LIBS} ${WSO2_LIBRARIES}) +INSTALL(TARGETS SimanIO EXPORT ${PROJECT_NAME}Targets DESTINATION lib) +INSTALL(FILES ${SimanIO_HEADERS} DESTINATION include) +# [ target: test ] +ADD_EXECUTABLE(TestCreateConfigFile TestCreateConfigFile.cpp) +TARGET_LINK_LIBRARIES(TestCreateConfigFile SimanIO) +INSTALL(TARGETS TestCreateConfigFile DESTINATION bin) diff --git a/src/SimanIO_Activity.cxx b/src/SimanIO_Activity.cxx index 870a58d..ad6e421 100644 --- a/src/SimanIO_Activity.cxx +++ b/src/SimanIO_Activity.cxx @@ -1,6 +1,23 @@ -#include +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// -using namespace std; +#include "SimanIO_Activity.hxx" SimanIO_Activity::SimanIO_Activity() { diff --git a/src/SimanIO_Activity.hxx b/src/SimanIO_Activity.hxx index 6fada14..828da48 100644 --- a/src/SimanIO_Activity.hxx +++ b/src/SimanIO_Activity.hxx @@ -1,8 +1,28 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #ifndef SIMANIO_ACTIVITY_H #define SIMANIO_ACTIVITY_H -#include +#include "SimanIO_Document.hxx" +#include #include /** diff --git a/src/SimanIO_Configuration.cxx b/src/SimanIO_Configuration.cxx index 22aedb9..2843627 100644 --- a/src/SimanIO_Configuration.cxx +++ b/src/SimanIO_Configuration.cxx @@ -1,4 +1,23 @@ -#include +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + +#include "SimanIO_Configuration.hxx" #include diff --git a/src/SimanIO_Configuration.hxx b/src/SimanIO_Configuration.hxx index 9c08fe1..3821d61 100644 --- a/src/SimanIO_Configuration.hxx +++ b/src/SimanIO_Configuration.hxx @@ -1,7 +1,27 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #ifndef SIMANIO_CONFIGURATION_H #define SIMANIO_CONFIGURATION_H -#include +#include "SimanIO_Activity.hxx" + #include #include diff --git a/src/SimanIO_Document.cxx b/src/SimanIO_Document.cxx index 9053d9a..88a5a2a 100644 --- a/src/SimanIO_Document.cxx +++ b/src/SimanIO_Document.cxx @@ -1,6 +1,23 @@ -#include +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// -using namespace std; +#include "SimanIO_Document.hxx" SimanIO_Document::SimanIO_Document() { diff --git a/src/SimanIO_Document.hxx b/src/SimanIO_Document.hxx index d002986..1d0d8df 100644 --- a/src/SimanIO_Document.hxx +++ b/src/SimanIO_Document.hxx @@ -1,3 +1,22 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #ifndef SIMANIO_DOCUMENT_H #define SIMANIO_DOCUMENT_H diff --git a/src/SimanIO_Link.cxx b/src/SimanIO_Link.cxx index 6542279..8987a93 100644 --- a/src/SimanIO_Link.cxx +++ b/src/SimanIO_Link.cxx @@ -1,3 +1,22 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #include "CreateConfigFile.h" #include "CreateConfigFileResponse.h" #include "GetFile.h" @@ -6,18 +25,16 @@ #include "PutFileResponse.h" #include "SimanSalomeServiceStub.h" +#include "SimanIO_Link.hxx" + #include +#include + #include #include #include -#include -#include - - #include - -using namespace std; using namespace org_splat_ws_server_service_salome; using namespace wso2wsf; @@ -34,7 +51,7 @@ bool SimanIO_Link::IsConnected() } // unification of the error handling in the RetrieveConf and StoreConf methods -#define CONFIGURSION_ERROR(message) {cerr<getServiceClient(); @@ -82,16 +99,15 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() aCreateConfigFileRequest->setArgs1(atoll(myScenario.c_str())); aCreateConfigFileRequest->setArgs2(atoll(myUser.c_str())); - //cout<<"StudyId = " << atoll(myStudy.c_str()) << "\n"; - //cout<<"ScenarioId = " << atoll(myScenario.c_str()) << "\n"; - //cout<<"UserId = " << atoll(myUser.c_str()) << "\n"; + //std::cout<<"StudyId = " << atoll(myStudy.c_str()) << "\n"; + //std::cout<<"ScenarioId = " << atoll(myScenario.c_str()) << "\n"; + //std::cout<<"UserId = " << atoll(myUser.c_str()) << "\n"; CreateConfigFileResponse* aCreateConfigFileResponse = new CreateConfigFileResponse(); aCreateConfigFileResponse = aStub->createConfigFile(aCreateConfigFileRequest); + std::string aResponseFilePath = aCreateConfigFileResponse->get_return(); - string aResponseFilePath = aCreateConfigFileResponse->get_return(); - - string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1); + std::string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1); //Get the created config file to client @@ -104,18 +120,18 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() aGetFileResponse = aStub->getFile(aGetFileRequest); //Parse the response and get the filename - string aTmpDir = "/tmp"; - string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/"; - //string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/"; - string aClientFilePath = aClientFileDir + aResponseFileName; + std::string aTmpDir = "/tmp"; + std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/"; + //std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/"; + std::string aClientFilePath = aClientFileDir + aResponseFileName; //Create the directories system(("mkdir -p " + aClientFileDir).c_str()); system(("chmod -Rf g+w " + aTmpDir + "/SimanSalome/").c_str()); //Download the siman-salome.conf file - ofstream outputStream; - outputStream.open(aClientFilePath.c_str(), ofstream::binary); + std::ofstream outputStream; + outputStream.open(aClientFilePath.c_str(), std::ofstream::binary); int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv()); int* aBufSize = new int[aBufferSize]; unsigned char* aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize); @@ -135,13 +151,13 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() /*const*/ SimanIO_Document& aDoc = aDocIter.Document(); SimanIO_Document::FilesIterator aFileIter(aDoc); for(; aFileIter.More(); aFileIter.Next()) { - string aURL = aFileIter.URL(); - string aFileName = aURL.substr(aURL.find_last_of("/\\")+1); + std::string aURL = aFileIter.URL(); + std::string aFileName = aURL.substr(aURL.find_last_of("/\\")+1); int startUnderlineIndex = aFileName.find_first_of("_") + 1; - string aSourceFileName = aFileName.substr(startUnderlineIndex); + std::string aSourceFileName = aFileName.substr(startUnderlineIndex); - //cout << "aURL = " << aURL << "\n"; - string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault/"; + //std::cout << "aURL = " << aURL << "\n"; + std::string aPathToVault = aResponseFilePath.substr(0, aResponseFilePath.find("download")) + "vault/"; //only for test only for WIN //replace(aURL.begin(),aURL.end(),'/','\\'); @@ -152,7 +168,7 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() aGetFileRequest->setArgs0(aPathToVault + aURL); aGetFileResponse = aStub->getFile(aGetFileRequest); - outputStream.open((aClientFileDir + aSourceFileName).c_str(), ofstream::binary); + outputStream.open((aClientFileDir + aSourceFileName).c_str(), std::ofstream::binary); int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv()); int* aBufSize = new int[aBufferSize]; unsigned char* aCopyBuffer = axutil_base64_binary_get_plain_binary(aGetFileResponse->get_return(), Environment::getEnv(), aBufSize); @@ -163,7 +179,7 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() //Set new URLs aFileIter.SetURL((aClientFileDir + aSourceFileName).c_str()); - //cout << "New location of the files " << aClientFileDir + aFileName << "\n"; + //std::cout << "New location of the files " << aClientFileDir + aFileName << "\n"; }//aFileIter }//aDocIter }//actIter @@ -183,15 +199,15 @@ SimanIO_Configuration SimanIO_Link::RetrieveConf() void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) { - cout << "StoreConf method is started\n"; + std::cout << "StoreConf method is started\n"; char* aSimanHost = getenv("SIMAN_WS_HOST"); if (aSimanHost == NULL) { CONFIGURSION_ERROR("The SIMAN_WS_HOST variable does not exist. Please set it.\n"); } - string aSimanWSHost(aSimanHost); - string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService"; + std::string aSimanWSHost(aSimanHost); + std::string anEndpointUri = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService"; Environment::initialize("SimanSalomeService.log",AXIS2_LOG_LEVEL_DEBUG); char* aClientHomeEnv = getenv("WSFCPP_HOME"); @@ -201,7 +217,7 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) CONFIGURSION_ERROR("The WSFCPP_HOME variable does not exist. Please set it.\n"); } - string aClientHome = AXIS2_GETENV("WSFCPP_HOME"); + std::string aClientHome = AXIS2_GETENV("WSFCPP_HOME"); SimanSalomeServiceStub* aStub = new SimanSalomeServiceStub(aClientHome, anEndpointUri); ServiceClient *client = aStub->getServiceClient(); @@ -220,11 +236,11 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) PutFileResponse* aPutFileResponse = new PutFileResponse(); //Prepare salome-siman.conf file - string aTmpDir = "/tmp"; - string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/"; - //string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/"; - string aClientFilePath = aClientFileDir + "salome-siman.conf"; - ofstream aSalomeSimanFile; + std::string aTmpDir = "/tmp"; + std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myStudy + "/" + myScenario + "/" + myUser + "/"; + //std::string aClientFileDir = aTmpDir + "/SimanSalome/" + myUser + "/download/"; + std::string aClientFilePath = aClientFileDir + "salome-siman.conf"; + std::ofstream aSalomeSimanFile; aSalomeSimanFile.open(aClientFilePath.c_str()); //Get the actual file URLs and put these files onto server. @@ -236,13 +252,13 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) /*const*/ SimanIO_Document& aDoc = aDocIter.Document(); SimanIO_Document::FilesIterator aFileIter(aDoc); for(; aFileIter.More(); aFileIter.Next()) { - string aURL = aFileIter.URL(); - string aFileName = aURL.substr(aURL.find_last_of("/\\")+1); - cout << "aURL = " << aURL << "\n"; - cout << " aFileName= " << aFileName << "\n"; + std::string aURL = aFileIter.URL(); + std::string aFileName = aURL.substr(aURL.find_last_of("/\\")+1); + std::cout << "aURL = " << aURL << "\n"; + std::cout << "aFileName= " << aFileName << "\n"; //get size of the input file - ifstream inputStream (aURL.c_str(), ifstream::binary); - inputStream.seekg(0,ifstream::end); + std::ifstream inputStream (aURL.c_str(), std::ifstream::binary); + inputStream.seekg(0,std::ifstream::end); int aSize = inputStream.tellg(); inputStream.seekg(0); @@ -250,6 +266,7 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) char* aCopyBuffer; aCopyBuffer = new char [aSize]; inputStream.read(aCopyBuffer,aSize); + std::cout << "Upload a file with the size" << aSize << "\n"; axutil_base64_binary_t* aRequestDH = axutil_base64_binary_create_with_plain_binary(Environment::getEnv(), reinterpret_cast(aCopyBuffer), aSize); inputStream.close(); delete[] aCopyBuffer; @@ -261,12 +278,16 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) aPutFileResponse = aStub->putFile(aPutFileRequest); + std::cout << "End of upload. New file locaton is: " << aPutFileResponse->get_return() << "\n"; + //Write information into salome-siman.conf file - ostringstream activityId; - ostringstream documentId; + std::ostringstream activityId; + std::ostringstream documentId; activityId << actIter.ActivityId(); documentId << aDocIter.DocId(); aSalomeSimanFile << myScenario + "," + myUser + "," + activityId.str() + "," + documentId.str() + "," + aPutFileResponse->get_return() + "\n"; + std::cout << "Line in the SalomeSimanFile " << myScenario + "," + myUser + "," + activityId.str() + "," + documentId.str() + "," + aPutFileResponse->get_return() <<"\n"; + std::cout <<"==========\n"; }//aFileIter }//aDocIter @@ -275,8 +296,8 @@ void SimanIO_Link::StoreConf(/*const*/ SimanIO_Configuration& theConf) aSalomeSimanFile.close(); //Put the salome-siman.conf file onto server - ifstream inputStream (aClientFilePath.c_str(), ifstream::binary); - inputStream.seekg(0,ifstream::end); + std::ifstream inputStream (aClientFilePath.c_str(), std::ifstream::binary); + inputStream.seekg(0,std::ifstream::end); int aSize = inputStream.tellg(); inputStream.seekg(0); diff --git a/src/SimanIO_Link.hxx b/src/SimanIO_Link.hxx index b56c80a..0e99439 100644 --- a/src/SimanIO_Link.hxx +++ b/src/SimanIO_Link.hxx @@ -1,7 +1,26 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #ifndef SIMANIO_LINK_H #define SIMANIO_LINK_H -#include +#include "SimanIO_Configuration.hxx" /** * \brief Class for creation of connection with SIMAN database. diff --git a/src/SimanIO_Version.hxx.in b/src/SimanIO_Version.hxx.in new file mode 100644 index 0000000..e012f96 --- /dev/null +++ b/src/SimanIO_Version.hxx.in @@ -0,0 +1,39 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + +#if !defined(SIMANIO_VERSION_H) +#define SIMANIO_VERSION_H + +/*! + Specify version of SimanIO library, as follows + + SIMANIO_VERSION_MAJOR : (integer) number identifying major version + SIMANIO_VERSION_MINOR : (integer) number identifying minor version + SIMANIO_VERSION_PATCH : (integer) number identifying patch version + SIMANIO_VERSION_STR : (string) complete version number "major.minor.patch" + SIMANIO_VERSION : (hex) complete version number (major << 16) + (minor << 8) + patch +*/ + +#define SIMANIO_VERSION_MAJOR @SIMANIO_MAJOR_VERSION@ +#define SIMANIO_VERSION_MINOR @SIMANIO_MINOR_VERSION@ +#define SIMANIO_VERSION_PATCH @SIMANIO_PATCH_VERSION@ +#define SIMANIO_VERSION_STR "@SIMANIO_VERSION@" +#define SIMANIO_VERSION (SIMANIO_VERSION_MAJOR << 16 | SIMANIO_VERSION_MINOR << 8 | SIMANIO_VERSION_PATCH) + +#endif // SIMANIO_VERSION_H diff --git a/src/TestCreateConfigFile.cpp b/src/TestCreateConfigFile.cpp index 50ff322..a3c40b1 100644 --- a/src/TestCreateConfigFile.cpp +++ b/src/TestCreateConfigFile.cpp @@ -1,3 +1,22 @@ +// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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 +// + #include "CreateConfigFile.h" #include "CreateConfigFileResponse.h" #include "GetFile.h" @@ -6,9 +25,9 @@ #include "PutFileResponse.h" #include "SimanSalomeServiceStub.h" #include +#include #include #include -#include #include #include @@ -16,8 +35,6 @@ #include #include - -using namespace std; using namespace org_splat_ws_server_service_salome; using namespace wso2wsf; @@ -27,14 +44,14 @@ int main(int argc, char *argv[]) char * ttest = getenv("SIMAN_WS_HOS"); if (ttest == NULL) - cout<<"expected\n"; + std::cout<<"expected\n"; else - cout<<"unexpected\n"; + std::cout<<"unexpected\n"; - string aSimanWSHost(getenv("SIMAN_WS_HOST")); - string endpointUriTT = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService"; + std::string aSimanWSHost(getenv("SIMAN_WS_HOST")); + std::string endpointUriTT = "http://" + aSimanWSHost + "/Siman-WS/services/SimanSalomeService"; - cout<<"enpoint uri" << endpointUriTT << "\n"; + std::cout<<"enpoint uri" << endpointUriTT << "\n"; Environment::initialize("SimanSalomeService.log",AXIS2_LOG_LEVEL_DEBUG); @@ -61,7 +78,7 @@ int main(int argc, char *argv[]) long long studyId = 1000; long long scenarioId = 1001; long long userId = 8; - string newUserId = "8"; + std::string newUserId = "8"; aRequest->setArgs0(studyId); aRequest->setArgs1(scenarioId); @@ -71,12 +88,12 @@ int main(int argc, char *argv[]) aResponse = aStub->createConfigFile(aRequest); - cout<< "Response:: "<get_return()<get_return()<get_return(); std::string aResponseFileName = aResponseFilePath.substr(aResponseFilePath.find_last_of("/\\")+1); - cout << aResponseFileName << "\n"; + std::cout << aResponseFileName << "\n"; //Set options axis2_options_set_action(axis2options, Environment::getEnv(), "urn:getFile"); @@ -89,11 +106,11 @@ int main(int argc, char *argv[]) std::ofstream outputStream; std::string aClientFilePath = "/dn24/SIMAN/siman_temp/download/" + aResponseFileName; - outputStream.open(aClientFilePath.c_str(), ofstream::binary); + outputStream.open(aClientFilePath.c_str(), std::ofstream::binary); int aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv()); - cout<get_return(), Environment::getEnv(), aBufSize); //char* aCopyBuf = aCopyBuf; @@ -105,13 +122,13 @@ int main(int argc, char *argv[]) outputStream.close(); //Second test - /*string aSourceLoc = "W:\\testvideo\\Darvin.avi"; + /*std::string aSourceLoc = "W:\\testvideo\\Darvin.avi"; aGetFileRequest->setArgs0(aSourceLoc); aGetFileResponse = aStub->getFile(aGetFileRequest); - outputStream.open("/dn24/SIMAN/siman_temp/download/Darvin.avi", ofstream::binary); + outputStream.open("/dn24/SIMAN/siman_temp/download/Darvin.avi", std::ofstream::binary); aBufferSize = axutil_base64_binary_get_decoded_binary_len(aGetFileResponse->get_return(), Environment::getEnv()); - cout<get_return(), Environment::getEnv(), aBufSize); @@ -122,7 +139,7 @@ int main(int argc, char *argv[]) outputStream.close(); */ //End second test - cout << "See file on path" << aClientFilePath << "\n"; + std::cout << "See file on path" << aClientFilePath << "\n"; //Upload test axis2_options_set_action(axis2options, Environment::getEnv(), "urn:putFile"); @@ -131,10 +148,10 @@ int main(int argc, char *argv[]) //char* aSourceFile = "/dn24/SIMAN/siman_temp/download/Mesh_1.med"; //get size of the input file - ifstream infile ("/dn24/SIMAN/siman_temp/download/Mesh_1.med",ifstream::binary); - infile.seekg(0,ifstream::end); + std::ifstream infile ("/dn24/SIMAN/siman_temp/download/Mesh_1.med",std::ifstream::binary); + infile.seekg(0,std::ifstream::end); int aSize = infile.tellg(); - cout << "Size of the input file is: " << aSize << "\n"; + std::cout << "Size of the input file is: " << aSize << "\n"; infile.seekg(0); char * inBuffer; @@ -151,12 +168,12 @@ int main(int argc, char *argv[]) aPutFileRequest->setArgs1("Mesh_1.med"); aPutFileRequest->setArgs2(userId); - cout << "test" <<"\n"; + std::cout << "test" <<"\n"; PutFileResponse* aPutFileResponse = new PutFileResponse(); aPutFileResponse = aStub->putFile(aPutFileRequest); - cout<< "Response:: "<get_return()<get_return()<