3 # Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
5 # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
6 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2.1 of the License, or (at your option) any later version.
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # Lesser General Public License for more details.
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this library; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
26 # function show_usage() : print help an exit
32 echo "Run standalone SALOME desktop".
34 echo "Usage: $(basename ${0}) [options]"
37 echo "-h, --help Print this information and exit."
38 echo "-v, --version Print SALOME version and exit."
39 echo "-m MODULES, --modules=MODULES Comma-separated list of modules to be used within SALOME session."
40 echo "-r RCFILE, --resources=RCFILE User preferences file to be used within SALOME session, instead of default one."
41 echo "-a LANGUAGE, --language=LANGUAGE Language to be used within SALOME session, instead of default one."
42 echo "-z, --no-splash Do not display splash screeen."
43 echo "-c, --no-exception-handler Do not install exception handler (allows debugging exceptions)."
44 echo "-l, --show-license Show license dialog at start-up."
47 echo " $(basename ${0}) --modules=LIGHT,PYLIGHT"
53 # function show_version() : print SALOME version an exit
58 local where=$(readlink -f $(dirname "${0}"))
59 if [ -f ${where}/VERSION ]
64 echo "Error: can't find VERSION file" > /dev/stderr
72 # function long_option() : extract value from long command line option
80 if [ $(echo ${value} | grep -e "^${option}=") ]
82 value=$(echo ${value} | sed -e "s%^${option}=%%")
87 if [ "${value}" = "" ]
89 echo "Error: please, specify value for option '--${option}'" > /dev/stderr
97 # function remove_duplications() : remove duplications
100 remove_duplications()
110 echo ${unique} | grep -qvE "\<${m}\>" && unique+=" ${m}"
119 # function run_light_salome(): run SALOME
128 local debug_exceptions=0
132 # process command line options
136 while getopts ":-:hvzclm:r:a:" option "${@}"
138 if [ "${option}" = "-" ]
142 version ) show_version ;;
143 no-splash ) no_splash=1 ;;
144 no-exception-handler ) debug_exceptions=1 ;;
145 show-license ) show_license=1 ;;
146 modules* ) modules=$(long_option modules ${OPTARG}) ;;
147 resources* ) rcfile=$(long_option resources ${OPTARG}) ;;
148 language* ) language=$(long_option language ${OPTARG}) ;;
149 * ) echo "Wrong option: --${OPTARG}" ; return 1 ;;
156 c ) debug_exceptions=1 ;;
157 l ) show_license=1 ;;
158 m* ) modules=${OPTARG} ;;
159 r* ) rcfile=${OPTARG} ;;
160 a* ) language=${OPTARG} ;;
161 ? ) echo "Wrong option" ; return 1 ;;
165 shift $((OPTIND - 1))
167 modules=$(echo ${modules} | sed -e "s%,% %g")
170 # if modules aren't given in command line option, try to detect all available modules
173 if [ "${modules}" = "" ]
176 for envvar in $(env | awk -F= '{print $1}' | grep _ROOT_DIR)
178 local mdir=${!envvar}
179 local mname=$(echo ${envvar} | awk -F_ '{print $1}')
180 local mname_lc=$(echo ${mname} | tr 'A-Z' 'a-z')
181 if [ -f ${mdir}/share/salome/resources/${mname_lc}/LightApp.xml ] || [ -f ${mdir}/share/salome/resources/LightApp.xml ]
189 # remove duplications from modules list
192 modules=$(remove_duplications ${modules})
198 if [ "${LightAppResources}" = "" ]
200 export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
202 export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
205 local pyversion=$(python3 -c "import sys; print(sys.version[:3])" 2>/dev/null)
207 local my_ld_library_path
211 for m in KERNEL GUI ${modules}
213 local root=${m}_ROOT_DIR
215 if [ "${root}" != "" ]
217 local m_lc=$(echo ${m} | tr 'A-Z' 'a-z')
218 test -d ${root}/bin/salome && my_path+=:${root}/bin/salome
219 test -d ${root}/lib/salome && my_ld_library_path+=:${root}/lib/salome
220 if [ "${pyversion}" != "" ]
222 test -d ${root}/bin/salome && my_pythonpath+=:${root}/bin/salome
223 test -d ${root}/lib/salome && my_pythonpath+=:${root}/lib/salome
224 test -d ${root}/lib/python${pyversion}/site-packages/salome && my_pythonpath+=:${root}/lib/python${pyversion}/site-packages/salome
226 if [ -f ${root}/share/salome/resources/${m_lc}/LightApp.xml ]
228 export LightAppConfig+=:${root}/share/salome/resources/${m_lc}
229 elif [ -f ${root}/share/salome/resources/LightApp.xml ]
231 export LightAppConfig+=:${root}/share/salome/resources
233 export SALOMEPATH+=:${root}
237 PATH=${my_path}:${PATH}
238 PATH=$(echo ${PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g")
240 LD_LIBRARY_PATH=${my_ld_library_path}:${LD_LIBRARY_PATH}
241 LD_LIBRARY_PATH=$(echo ${LD_LIBRARY_PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g")
242 export LD_LIBRARY_PATH
243 PYTHONPATH=${my_pythonpath}:${PYTHONPATH}
244 PYTHONPATH=$(echo ${PYTHONPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g")
246 LightAppConfig=$(echo ${LightAppConfig} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g")
247 export LightAppConfig
248 SALOMEPATH=$(echo ${SALOMEPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g")
255 local options="--modules=$(echo ${modules} | tr ' ' ',')"
256 test "${rcfile}" != "" && options+=" --resources=${rcfile}"
257 test "${language}" != "" && options+=" --language=${language}"
258 test "${no_splash}" = "1" && options+=" --no-splash"
259 test "${debug_exceptions}" = "1" && options+=" --no-exception-handler"
260 test "${show_license}" = "1" && options+=" --show-license"
261 suitexe LightApp ${options} "${@}"
265 # call wrapper function (entry point)
268 run_light_salome "${@}"