X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FrunLightSalome.sh;h=08b04d757c18a39327950e9c1d62ed8bb12b9a4f;hb=7d8793b0eca98467fffc16a5acf8e8022a15f77e;hp=8caaaa9165d44e1606378bdff7ea5e4b56861529;hpb=1c889394b028b786898a995d38c07c8f3d564837;p=modules%2Fgui.git
diff --git a/bin/runLightSalome.sh b/bin/runLightSalome.sh
index 8caaaa916..08b04d757 100755
--- a/bin/runLightSalome.sh
+++ b/bin/runLightSalome.sh
@@ -1,149 +1,240 @@
#!/bin/bash -f
-# Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+
+# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
#
-# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#
-# 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 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.
+# 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
+# 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
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
+
# File : runLightSalome.sh
# Author : Vadim SANDLER, Open CASCADE S.A.S, vadim.sandler@opencascade.com
+
+
###
-# set default value for the LightAppConfig variable, which
-# is necessary for loading of .ini or .xml resources file
+# function show_usage() : print help an exit
###
-#
-if [ -z "$LightAppConfig" ] ; then
- export LightAppConfig=${GUI_ROOT_DIR}/share/salome/resources/gui
-else
- export LightAppConfig=${LightAppConfig}:${GUI_ROOT_DIR}/share/salome/resources/gui
-fi
-if [ -z "$LightAppResources" ] ; then
- export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
-else
- export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
-fi
+
+show_usage() {
+ local RET=0
+ if [ $# -gt 0 ] ; then RET=$1 ; fi
+ local MOVE1="echo -en \\033[35G"
+ local MOVE2="echo -en \\033[22G"
+ echo
+ echo "Run standalone SALOME desktop".
+ echo
+ echo "Usage: $(basename $0) [options]"
+ echo
+ echo "Options:"
+ echo " * all options have both short and long format;"
+ echo " * some options require additional parameter (below referenced as )"
+ echo " which should be separated by = symbol from the option itself."
+ echo
+ echo -en " --help"
+ ${MOVE2} ; echo -en "(-h)"
+ ${MOVE1} ; echo "Display this information and exit."
+ echo -en " --version"
+ ${MOVE2} ; echo -en "(-v)"
+ ${MOVE1} ; echo "Print SALOME version and exit."
+ echo -en " --modules="
+ ${MOVE2} ; echo -en "(-m)"
+ ${MOVE1} ; echo "List of modules, separated by comma, to be used within SALOME session."
+ echo
+ echo "Example:"
+ echo " $(basename $0) --modules=LIGHT,PYLIGHT"
+ echo
+ exit ${RET}
+}
###
-# process --modules=... command line option (get list of modules)
+# function show_version() : print SALOME version an exit
###
-modules=""
-
-for arg in X $* ; do
- if [ "$arg" != "X" ] ; then
- case $arg in
- --modules=* ) modules=`echo $arg | awk -F= '{ print $2 }' | sed -e "s%,% %g"` ;;
- *) ;;
- esac
+show_version() {
+ local RET=0
+ local DIR=$(dirname $0)
+ if [ -z "${DIR}" ] ; then DIR=. ; fi
+ if [ -f ${DIR}/VERSION ] ; then
+ cat ${DIR}/VERSION
+ else
+ echo
+ echo "Error: can't find VERSION file" > /dev/stderr
+ echo
+ RET=1
fi
-done
-
-modules="KERNEL GUI $modules"
+ exit ${RET}
+}
###
-# exclude modules duplication
+# function option_modules() : process --modules / -m command line option
###
-mods=""
-
-for mod in $modules ; do
- echo $mods | grep -E "\<$mod\>" >/dev/null 2>&1
- if [ "$?" == "1" ] ; then
- mods="$mods $mod"
+option_modules() {
+ local MODS=`echo $1 | awk -F "=" '{ if(NF>1) print $2 ; else print $1 }'`
+ if [ "X${MODS}" = "X" ] ; then
+ echo
+ echo "Error: Please, specify list of modules" > /dev/stderr
+ echo
+ exit 1
fi
-done
+ MODULES=`echo ${MODS} | sed -e "s%,% %g"`
+ return
+}
+
###
-# set additional environment
+# function run_light_salome(): run SALOME
###
-python_version=`python -c "import sys; print sys.version[:3]" 2>/dev/null`
-
-MY_PATH=""
-MY_LD_LIBRARY_PATH=""
-MY_PYTHONPATH=""
-
-for mod in $mods ; do
- if [ "$arg" != "X" ] ; then
- root_dir=`printenv ${mod}_ROOT_DIR`
- if [ "$root_dir" != "" ] ; then
- mod_lower=`echo $mod | tr "A-Z" "a-z"`
- if [ -d ${root_dir}/bin/salome ] ; then
- if [ "${MY_PATH}" == "" ] ; then
- MY_PATH=${root_dir}/bin/salome
- else
- MY_PATH=${MY_PATH}:${root_dir}/bin/salome
- fi
- fi
- if [ -d ${root_dir}/lib/salome ] ; then
- if [ "${MY_LD_LIBRARY_PATH}" == "" ] ; then
- MY_LD_LIBRARY_PATH=${root_dir}/lib/salome
- else
- MY_LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${root_dir}/lib/salome
- fi
+run_light_salome(){
+
+ local MODULES
+
+ ###
+ # process command line options
+ ###
+
+ local OPTION
+ while getopts ":-:hvm:" OPTION "$@" ; do
+ if [ "${OPTION}" = "-" ] ; then
+ case ${OPTARG} in
+ help ) show_usage ;;
+ version ) show_version ;;
+ modules* ) option_modules "${OPTARG}" ;;
+ * ) echo "!!!Wrong option!!!" ; exit 1 ;;
+ esac
+ else
+ case ${OPTION} in
+ h ) show_usage ;;
+ v ) show_version ;;
+ m* ) option_modules "${OPTARG}" ;;
+ ? ) echo "!!!Wrong option!!!" ; exit 1 ;;
+ esac
+ fi
+ done
+ shift $((OPTIND - 1))
+
+ ###
+ # by default try to detect all available modules
+ ###
+
+ if [ -z "${MODULES}" ] ; then
+ local ENVVAR
+ local ROOTDIR
+ for ENVVAR in `env | awk -F= '{print $1}' | grep _ROOT_DIR` ; do
+ local MOD=`echo $ENVVAR | awk -F_ '{print $1}'`
+ local LMOD=`echo ${MOD} | tr 'A-Z' 'a-z'`
+ ROOTDIR=`printenv ${ENVVAR}`
+ if [ -f ${ROOTDIR}/share/salome/resources/${LMOD}/LightApp.xml ] || [ -f ${ROOTDIR}/share/salome/resources/LightApp.xml ] ; then
+ MODULES="${MODULES} ${MOD}"
fi
- if [ "${python_version}" != "" ] ; then
- if [ -d ${root_dir}/bin/salome ] ; then
- if [ "${MY_PYTHONPATH}" == "" ] ; then
- MY_PYTHONPATH=${root_dir}/bin/salome
- else
- MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/bin/salome
- fi
- fi
- if [ -d ${root_dir}/lib/salome ] ; then
- if [ "${MY_PYTHONPATH}" == "" ] ; then
- MY_PYTHONPATH=${root_dir}/lib/salome
- else
- MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/lib/salome
- fi
- fi
- if [ -d ${root_dir}/lib/python${python_version}/site-packages/salome ] ; then
- if [ "${MY_PYTHONPATH}" == "" ] ; then
- MY_PYTHONPATH=${root_dir}/lib/python${python_version}/site-packages/salome
- else
- MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/lib/python${python_version}/site-packages/salome
- fi
- fi
+ done
+ fi
+
+ ###
+ # initial environment
+ ###
+
+ if [ -z "${LightAppResources}" ] ; then
+ export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
+ else
+ export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
+ fi
+
+ MODULES="KERNEL GUI ${MODULES}"
+
+ ###
+ # exclude modules duplication
+ ###
+
+ local MODS=""
+ local MOD
+ for MOD in ${MODULES} ; do
+ echo ${MODS} | grep -E "\<${MOD}\>" >/dev/null 2>&1
+ if [ "$?" == "1" ] ; then
+ MODS="${MODS} ${MOD}"
+ fi
+ done
+ MODULES=${MODS}
+
+ ###
+ # set additional environment
+ ###
+
+ local PVERSION=`python -c "import sys; print sys.version[:3]" 2>/dev/null`
+
+ local MY_PATH=""
+ local MY_LD_LIBRARY_PATH=""
+ local MY_PYTHONPATH=""
+
+ for MOD in ${MODULES} ; do
+ local ROOTDIR=`printenv ${MOD}_ROOT_DIR`
+ if [ -z "${ROOTDIR}" ] ; then continue ; fi
+ local LMOD=`echo ${MOD} | tr 'A-Z' 'a-z'`
+ if [ -d ${ROOTDIR}/bin/salome ] ; then
+ MY_PATH=${MY_PATH}:${ROOTDIR}/bin/salome
+ fi
+ if [ -d ${ROOTDIR}/lib/salome ] ; then
+ MY_LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${ROOTDIR}/lib/salome
+ fi
+ if [ "${PVERSION}" != "" ] ; then
+ if [ -d ${ROOTDIR}/bin/salome ] ; then
+ MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/bin/salome
fi
- if [ "$mod" != "KERNEL" ] && [ "$mod" != "GUI" ] ; then
- export LightAppConfig=${LightAppConfig}:${root_dir}/share/salome/resources/${mod_lower}
+ if [ -d ${ROOTDIR}/lib/salome ] ; then
+ MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/lib/salome
fi
- if [ "${SALOMEPATH}" == "" ] ; then
- export SALOMEPATH=${root_dir}
- else
- export SALOMEPATH=${SALOMEPATH}:${root_dir}
+ if [ -d ${ROOTDIR}/lib/python${PVERSION}/site-packages/salome ] ; then
+ MY_PYTHONPATH=${MY_PYTHONPATH}:${ROOTDIR}/lib/python${PVERSION}/site-packages/salome
fi
fi
- fi
-done
-
-if [ "${MY_PATH}" != "" ] ; then
- export PATH=${MY_PATH}:${PATH}
-fi
-if [ "${MY_LD_LIBRARY_PATH}" != "" ] ; then
- export LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}
-fi
-if [ "${PYTHONPATH}" != "" ] ; then
- export PYTHONPATH=${MY_PYTHONPATH}:${PYTHONPATH}
-fi
+ if [ -f ${ROOTDIR}/share/salome/resources/${LMOD}/LightApp.xml ] ; then
+ export LightAppConfig=${LightAppConfig}:${ROOTDIR}/share/salome/resources/${LMOD}
+ elif [ -f ${ROOTDIR}/share/salome/resources/LightApp.xml ] ; then
+ export LightAppConfig=${LightAppConfig}:${ROOTDIR}/share/salome/resources
+ fi
+ export SALOMEPATH=${SALOMEPATH}:${ROOTDIR}
+ done
+
+ PATH=${MY_PATH}:${PATH}
+ PATH=`echo ${PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
+ export PATH
+ LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}
+ LD_LIBRARY_PATH=`echo ${LD_LIBRARY_PATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
+ export LD_LIBRARY_PATH
+ PYTHONPATH=${MY_PYTHONPATH}:${PYTHONPATH}
+ PYTHONPATH=`echo ${PYTHONPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
+ export PYTHONPATH
+ LightAppConfig=`echo ${LightAppConfig} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
+ export LightAppConfig
+ SALOMEPATH=`echo ${SALOMEPATH} | sed -e "s,^:,,;s,:$,,;s,::\+,:,g"`
+ export SALOMEPATH
+
+ ###
+ # start application
+ ###
+
+ MODULES=`echo $MODULES | tr " " ","`
+ SUITApp LightApp --modules=${MODULES} "$*" &
+}
###
-# start application
+# call wrapper function (entry point)
###
-SUITApp LightApp $* &
+run_light_salome "$@"
\ No newline at end of file