3 # Copyright (C) 2007-2015 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
25 # File : runLightSalome.sh
26 # Author : Vadim SANDLER, Open CASCADE S.A.S, vadim.sandler@opencascade.com
30 # function show_usage() : print help an exit
35 if [ $# -gt 0 ] ; then RET=$1 ; fi
36 local MOVE1="echo -en \\033[35G"
37 local MOVE2="echo -en \\033[22G"
39 echo "Run standalone SALOME desktop".
41 echo "Usage: $(basename $0) [options]"
44 echo "-m MODULES, --modules=MODULES List of modules, separated by comma, to be used within SALOME session."
45 echo "-r RCFILE, --resources=RCFILE Preferences file to be used within SALOME session."
46 echo "-v, --version Print SALOME version and exit."
47 echo "-h, --help Print this help and exit."
50 echo " $(basename $0) --modules=LIGHT,PYLIGHT"
56 # function show_version() : print SALOME version an exit
61 local DIR=$(dirname $0)
62 if [ -z "${DIR}" ] ; then DIR=. ; fi
63 if [ -f ${DIR}/VERSION ] ; then
67 echo "Error: can't find VERSION file" > /dev/stderr
75 # function option_modules() : process --modules / -m command line option
82 MODS=`echo $1 | awk -F "=" '{ if(NF>1) print $2 ; else print "" }'`
86 echo "Error: Invalid option format, please use --modules=MODULES" > /dev/stderr
94 if [ "X${MODS}" = "X" ] ; then
96 echo "Error: Please, specify list of modules" > /dev/stderr
100 MODULES=`echo ${MODS} | sed -e "s%,% %g"`
105 # function option_resources() : process --resources / -r command line option
112 RCF=`echo $1 | awk -F "=" '{ if(NF>1) print $2 ; else print "" }'` ;;
115 echo "Error: Invalid option format, please use --resources=RCFILE" > /dev/stderr
121 if [ "X${RCF}" = "X" ] ; then
123 echo "Error: Please, specify resource file" > /dev/stderr
127 RCFILE="--resources=${RCF}"
132 # function run_light_salome(): run SALOME
141 # process command line options
145 while getopts ":-:hvm:r:" OPTION "$@" ; do
146 if [ "${OPTION}" = "-" ] ; then
149 version ) show_version ;;
150 modules* ) option_modules "${OPTARG}" ;;
151 resources* ) option_resources "${OPTARG}" ;;
152 * ) echo "!!!Wrong option!!!" ; exit 1 ;;
158 m* ) option_modules "${OPTARG}" ;;
159 r* ) option_resources "${OPTARG}" ;;
160 ? ) echo "!!!Wrong option!!!" ; exit 1 ;;
164 shift $((OPTIND - 1))
167 # by default try to detect all available modules
170 if [ -z "${MODULES}" ] ; then
173 for ENVVAR in `env | awk -F= '{print $1}' | grep _ROOT_DIR` ; do
174 local MOD=`echo $ENVVAR | awk -F_ '{print $1}'`
175 local LMOD=`echo ${MOD} | tr 'A-Z' 'a-z'`
176 ROOTDIR=`printenv ${ENVVAR}`
177 if [ -f ${ROOTDIR}/share/salome/resources/${LMOD}/LightApp.xml ] || [ -f ${ROOTDIR}/share/salome/resources/LightApp.xml ] ; then
178 MODULES="${MODULES} ${MOD}"
184 # initial environment
187 if [ -z "${LightAppResources}" ] ; then
188 export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
190 export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
194 # exclude modules duplication
199 for MOD in ${MODULES} ; do
204 echo ${MODS} | grep -E "\<${MOD}\>" >/dev/null 2>&1
205 if [ "$?" == "1" ] ; then
206 MODS="${MODS} ${MOD}"
214 # set additional environment
217 local PVERSION=`python -c "import sys; print sys.version[:3]" 2>/dev/null`
220 local MY_LD_LIBRARY_PATH=""
221 local MY_PYTHONPATH=""
223 for MOD in KERNEL GUI ${MODULES} ; do
224 local ROOTDIR=`printenv ${MOD}_ROOT_DIR`
225 if [ -z "${ROOTDIR}" ] ; then continue ; fi
226 local LMOD=`echo ${MOD} | tr 'A-Z' 'a-z'`
227 if [ -d ${ROOTDIR}/bin/salome ] ; then
228 MY_PATH=${MY_PATH}:${ROOTDIR}/bin/salome
230 if [ -d ${ROOTDIR}/lib/salome ] ; then
231 MY_LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${ROOTDIR}/lib/salome
233 if [ "${PVERSION}" != "" ] ; then
234 if [ -d ${ROOTDIR}/bin/salome ] ; then
235 MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/bin/salome
237 if [ -d ${ROOTDIR}/lib/salome ] ; then
238 MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/lib/salome
240 if [ -d ${ROOTDIR}/lib/python${PVERSION}/site-packages/salome ] ; then
241 MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/lib/python${PVERSION}/site-packages/salome
244 if [ -f ${ROOTDIR}/share/salome/resources/${LMOD}/LightApp.xml ] ; then
245 export LightAppConfig=${LightAppConfig}:${ROOTDIR}/share/salome/resources/${LMOD}
246 elif [ -f ${ROOTDIR}/share/salome/resources/LightApp.xml ] ; then
247 export LightAppConfig=${LightAppConfig}:${ROOTDIR}/share/salome/resources
249 export SALOMEPATH=${SALOMEPATH}:${ROOTDIR}
252 PATH=${MY_PATH}:${PATH}
253 PATH=`echo ${PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
255 LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}
256 LD_LIBRARY_PATH=`echo ${LD_LIBRARY_PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
257 export LD_LIBRARY_PATH
258 PYTHONPATH=${MY_PYTHONPATH}:${PYTHONPATH}
259 PYTHONPATH=`echo ${PYTHONPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
261 LightAppConfig=`echo ${LightAppConfig} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
262 export LightAppConfig
263 SALOMEPATH=`echo ${SALOMEPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
270 SUITApp LightApp --modules=`echo $MODULES | tr " " ","` "${RCFILE}" "$@" &
274 # call wrapper function (entry point)
277 run_light_salome "$@"