From 5713d44cd77c022c0f144209680d247c709d171c Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 23 Feb 2021 17:43:41 +0100 Subject: [PATCH] Go on to the finish --- src/Session/CMakeLists.txt | 4 ++ src/Session/salome2810.cxx | 80 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+) create mode 100644 src/Session/salome2810.cxx diff --git a/src/Session/CMakeLists.txt b/src/Session/CMakeLists.txt index 5a783b508..4702f4e9a 100644 --- a/src/Session/CMakeLists.txt +++ b/src/Session/CMakeLists.txt @@ -114,5 +114,9 @@ ADD_EXECUTABLE(SALOME_Session_Server SALOME_Session_Server.cxx) TARGET_LINK_LIBRARIES(SALOME_Session_Server ${_link_LIBRARIES} SalomeSession) INSTALL(TARGETS SALOME_Session_Server EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_BINS}) +add_executable(salome2810 salome2810.cxx) +target_link_libraries(salome2810 ${QT_LIBRARIES}) +install(TARGETS salome2810 DESTINATION ${SALOME_INSTALL_BINS}) + INSTALL(FILES ${SalomeSession_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) QT_INSTALL_TS_RESOURCES("${_ts_RESOURCES}" "${SALOME_GUI_INSTALL_RES_DATA}") diff --git a/src/Session/salome2810.cxx b/src/Session/salome2810.cxx new file mode 100644 index 000000000..8f09b85e4 --- /dev/null +++ b/src/Session/salome2810.cxx @@ -0,0 +1,80 @@ +// Copyright (C) 2021 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +#include +#include + +#include + +int main(int argc, char *argv[]) +{ + const char *MODULES[]={"SHAPERSTUDY","GEOM","SMESH"}; + constexpr char GUI_ROOT_DIR[]="GUI_ROOT_DIR"; + constexpr char GEOM_ROOT_DIR[]="GEOM_ROOT_DIR"; + constexpr char SMESH_ROOT_DIR[]="SMESH_ROOT_DIR"; + constexpr char SHAPER_ROOT_DIR[]="SHAPER_ROOT_DIR"; + constexpr char SHAPERSTUDY_ROOT_DIR[]="SHAPERSTUDY_ROOT_DIR"; + constexpr char APPCONFIG[]="SalomeAppSLConfig"; + QProcessEnvironment pe(QProcessEnvironment::systemEnvironment()); + for(auto elt : {GUI_ROOT_DIR,GEOM_ROOT_DIR,SMESH_ROOT_DIR,SHAPER_ROOT_DIR,SHAPERSTUDY_ROOT_DIR} ) + { + if( !pe.contains(elt) || pe.value(elt).isEmpty() ) + { + std::cerr << elt << " is not defined in your environment !" << std::endl; + return 1; + } + } + // fill LightAppConfig env var + QString gui_root_dir( QDir::fromNativeSeparators(pe.value(GUI_ROOT_DIR)) ); + QString shaper_root_dir( QDir::fromNativeSeparators(pe.value(SHAPER_ROOT_DIR)) ); + QString shaperstudy_root_dir( QDir::fromNativeSeparators(pe.value(SHAPERSTUDY_ROOT_DIR)) ); + QString geom_root_dir( QDir::fromNativeSeparators(pe.value(GEOM_ROOT_DIR)) ); + QString smesh_root_dir( QDir::fromNativeSeparators(pe.value(SMESH_ROOT_DIR)) ); + QString appconfig_val( QString("%1:%2:%3:%4:%5") + .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/gui").arg(gui_root_dir) ) ) + .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/shaper").arg(shaper_root_dir) ) ) + .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/shaperstudy").arg(shaperstudy_root_dir) ) ) + .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/geom").arg(geom_root_dir) ) ) + .arg( QDir::toNativeSeparators( QString("%1/share/salome/resources/smesh").arg(smesh_root_dir) ) ) ); + pe.insert(APPCONFIG,appconfig_val); + //tells shutup to salome.salome_init invoked at shaper engine ignition + pe.insert("SALOME_EMB_SERVANT","1"); + // + QProcess proc; + proc.setProcessEnvironment(pe); + proc.setProgram("SALOME_Session_Server"); + + QStringList args({"--with","Registry","(","--salome_session","theSession",")","--with","ModuleCatalog","(","-common"}); + QStringList catalogs; + for(std::size_t im = 0 ; im < sizeof(MODULES)/sizeof(decltype(MODULES[0])) ; ++im ) + { + QString root_dir = pe.value( QString("%1_ROOT_DIR").arg(MODULES[im]) ); + catalogs << QDir::toNativeSeparators( QString("%1/share/salome/resources/%2/%3Catalog.xml").arg(root_dir).arg(root_dir.toLower()).arg(root_dir) ); + } + args << catalogs.join("::"); + args << ")"; + args << "--with" << "SALOMEDS" << "(" << ")" << "--with" << "Container" << "(" << "FactoryServer" << ")" << "--with" << "SalomeAppEngine" << "(" << ")" << "CPP"; + args << "--resources=/home/H87074/.config/salome/SalomeApprc.9.5.BR" << "--modules" << "(SHAPER:GEOM:SMESH)"; + proc.setArguments(args); + proc.setProcessChannelMode( QProcess::ForwardedErrorChannel ); + proc.start(); + proc.waitForFinished(); + return proc.exitCode(); +} -- 2.39.2