Salome HOME
8caaaa9165d44e1606378bdff7ea5e4b56861529
[modules/gui.git] / bin / runLightSalome.sh
1 #!/bin/bash -f
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # File   : runLightSalome.sh
24 # Author : Vadim SANDLER, Open CASCADE S.A.S, vadim.sandler@opencascade.com
25 ###
26 # set default value for the LightAppConfig variable, which 
27 # is necessary for loading of .ini or .xml resources file
28 ###
29 #
30 if [ -z "$LightAppConfig" ] ; then
31   export LightAppConfig=${GUI_ROOT_DIR}/share/salome/resources/gui
32 else
33   export LightAppConfig=${LightAppConfig}:${GUI_ROOT_DIR}/share/salome/resources/gui
34 fi
35 if [ -z "$LightAppResources" ] ; then
36   export LightAppResources=${GUI_ROOT_DIR}/share/salome/resources/gui
37 else
38   export LightAppResources=${LightAppResources}:${GUI_ROOT_DIR}/share/salome/resources/gui
39 fi
40
41 ###
42 # process --modules=... command line option (get list of modules)
43 ###
44
45 modules=""
46
47 for arg in X $* ; do
48     if [ "$arg" != "X" ] ; then
49         case $arg in
50             --modules=* )  modules=`echo $arg | awk -F= '{ print $2 }' | sed -e "s%,% %g"` ;;
51             *)             ;;
52         esac
53     fi
54 done
55
56 modules="KERNEL GUI $modules"
57
58 ###
59 # exclude modules duplication
60 ###
61
62 mods=""
63
64 for mod in $modules ; do
65     echo $mods | grep -E "\<$mod\>" >/dev/null 2>&1
66     if [ "$?" == "1" ] ; then
67         mods="$mods $mod"
68     fi
69 done
70
71 ###
72 # set additional environment
73 ###
74
75 python_version=`python -c "import sys; print sys.version[:3]" 2>/dev/null`
76
77 MY_PATH=""
78 MY_LD_LIBRARY_PATH=""
79 MY_PYTHONPATH=""
80
81 for mod in $mods ; do
82     if [ "$arg" != "X" ] ; then
83         root_dir=`printenv ${mod}_ROOT_DIR`
84         if [ "$root_dir" != "" ] ; then
85             mod_lower=`echo $mod | tr "A-Z" "a-z"`
86             if [ -d ${root_dir}/bin/salome ] ; then
87                 if [ "${MY_PATH}" == "" ] ; then
88                     MY_PATH=${root_dir}/bin/salome
89                 else
90                     MY_PATH=${MY_PATH}:${root_dir}/bin/salome
91                 fi
92             fi
93             if [ -d ${root_dir}/lib/salome ] ; then
94                 if [ "${MY_LD_LIBRARY_PATH}" == "" ] ; then
95                     MY_LD_LIBRARY_PATH=${root_dir}/lib/salome
96                 else
97                     MY_LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${root_dir}/lib/salome
98                 fi
99             fi
100             if [ "${python_version}" != "" ] ; then
101                 if [ -d ${root_dir}/bin/salome ] ; then
102                     if [ "${MY_PYTHONPATH}" == "" ] ; then
103                         MY_PYTHONPATH=${root_dir}/bin/salome
104                     else
105                         MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/bin/salome
106                     fi
107                 fi
108                 if [ -d ${root_dir}/lib/salome ] ; then
109                     if [ "${MY_PYTHONPATH}" == "" ] ; then
110                         MY_PYTHONPATH=${root_dir}/lib/salome
111                     else
112                         MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/lib/salome
113                     fi
114                 fi
115                 if [ -d ${root_dir}/lib/python${python_version}/site-packages/salome ] ; then 
116                     if [ "${MY_PYTHONPATH}" == "" ] ; then
117                         MY_PYTHONPATH=${root_dir}/lib/python${python_version}/site-packages/salome
118                     else
119                         MY_PYTHONPATH=${MY_PYTHONPATH}:${root_dir}/lib/python${python_version}/site-packages/salome
120                     fi
121                 fi
122             fi
123             if [ "$mod" != "KERNEL" ] && [ "$mod" != "GUI" ] ; then
124                 export LightAppConfig=${LightAppConfig}:${root_dir}/share/salome/resources/${mod_lower}
125             fi
126             if [ "${SALOMEPATH}" == "" ] ; then
127                 export SALOMEPATH=${root_dir}
128             else
129                 export SALOMEPATH=${SALOMEPATH}:${root_dir}
130             fi
131         fi
132     fi
133 done
134
135 if [ "${MY_PATH}" != "" ] ; then
136     export PATH=${MY_PATH}:${PATH}
137 fi
138 if [ "${MY_LD_LIBRARY_PATH}" != "" ] ; then
139     export LD_LIBRARY_PATH=${MY_LD_LIBRARY_PATH}:${LD_LIBRARY_PATH}
140 fi
141 if [ "${PYTHONPATH}" != "" ] ; then
142     export PYTHONPATH=${MY_PYTHONPATH}:${PYTHONPATH}
143 fi
144
145 ###
146 # start application
147 ###
148
149 SUITApp LightApp $* &