1 // Copyright (C) 2021-2023 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include <QProcessEnvironment>
26 int main(int argc, char *argv[])
28 constexpr char MAIN_PROGRAM[] = "SALOME_Session_Server_No_Server";
29 constexpr char PYQT5_NOT_MASTER[] = "PYQT5_NOT_MASTER";
31 const char *MODULES[]={"SHAPERSTUDY","GEOM","SMESH","YACS","HYBRIDPLUGIN","GHS3DPLUGIN","BLSURFPLUGIN","GMSHPLUGIN","HEXABLOCKPLUGIN","HEXOTICPLUGIN","GHS3DPRLPLUGIN","NETGENPLUGIN"};
32 const char *MODULES_PATH[]={"GUI","SHAPER","SHAPERSTUDY","GEOM","SMESH","YACS","HYBRIDPLUGIN","GHS3DPLUGIN","BLSURFPLUGIN","GMSHPLUGIN","HEXABLOCKPLUGIN","GHS3DPRLPLUGIN","NETGENPLUGIN"};
34 const char *MODULES[]={"SHAPERSTUDY","GEOM","SMESH","HYBRIDPLUGIN","BLSURFPLUGIN","GMSHPLUGIN","HEXABLOCKPLUGIN","HEXOTICPLUGIN","NETGENPLUGIN"};
35 const char *MODULES_PATH[]={"GUI","SHAPER","SHAPERSTUDY","GEOM","SMESH","HYBRIDPLUGIN","BLSURFPLUGIN","GMSHPLUGIN","HEXABLOCKPLUGIN","NETGENPLUGIN"};
37 constexpr char APPCONFIG[]="SalomeAppSLConfig";
38 QProcessEnvironment pe(QProcessEnvironment::systemEnvironment());
39 QStringList modulesPaths;
40 for(auto elt : MODULES_PATH)
42 QString elt_root_dir( QString("%1_ROOT_DIR").arg(elt) );
43 if( !pe.contains(elt_root_dir) || pe.value(elt_root_dir).isEmpty() )
45 std::cerr << elt_root_dir.toStdString() << " is not defined in your environment !" << std::endl;
48 modulesPaths << QDir::fromNativeSeparators( QString("%1/share/salome/resources/%2").arg( pe.value(elt_root_dir) ).arg( QString(elt).toLower() ) );
50 // fill LightAppConfig env var
51 QString appconfig_val( modulesPaths.join(QDir::listSeparator()));
52 pe.insert(APPCONFIG,appconfig_val);
53 //tells shutup to salome.salome_init invoked at shaper engine ignition
54 pe.insert(PYQT5_NOT_MASTER,"1");
55 //resource file retrieve
59 proc.setProcessEnvironment(pe);
60 proc.setProgram("python3");
61 proc.setArguments({"-c","from launchConfigureParser import userFile ; import sys ; sys.stdout.write(userFile(\"SalomeApp\",\"salome\"))"});
63 proc.waitForFinished(-1);
64 if(proc.exitStatus() != QProcess::NormalExit)
66 std::cerr << "Fail to retrieve resource file from launchConfigureParser python module !" << std::endl;
69 QByteArray val(proc.readAllStandardOutput());
70 resfile = QString::fromUtf8(val);
74 proc.setProcessEnvironment(pe);
75 proc.setProgram(MAIN_PROGRAM);
77 QStringList args({"--with","Registry","(","--salome_session","theSession",")","--with","ModuleCatalog","(","-common"});
79 for(std::size_t im = 0 ; im < sizeof(MODULES)/sizeof(decltype(MODULES[0])) ; ++im )
81 QString root_dir = pe.value( QString("%1_ROOT_DIR").arg(MODULES[im]) );
82 catalogs << QDir::toNativeSeparators( QString("%1/share/salome/resources/%2/%3Catalog.xml").arg(root_dir).arg(QString(MODULES[im]).toLower()).arg(MODULES[im]) );
84 args << catalogs.join("::");
86 args << "--with" << "SALOMEDS" << "(" << ")" << "--with" << "Container" << "(" << "FactoryServer" << ")" << "--with" << "SalomeAppEngine" << "(" << ")" << "CPP";
87 args << QString("--resources=%1").arg(resfile) << "--modules" << "(SHAPER:GEOM:SMESH:YACS)";
88 if( pe.contains("VERBOSE") )
90 std::cout << "Overloaded env var :" << std::endl;
91 std::cout << " - " << APPCONFIG << " = " << appconfig_val.toStdString() << std::endl;
92 std::cout << "Command launched :" << std::endl;
93 std::cout << MAIN_PROGRAM << " " << args.join(" ").toStdString() << std::endl;
95 proc.setArguments(args);
96 proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
98 proc.waitForFinished(-1);
99 return proc.exitCode();