From 397e503db0793fa25fcd5d3c39c6bbdae0909bd0 Mon Sep 17 00:00:00 2001 From: spo Date: Wed, 14 Oct 2015 10:49:51 +0300 Subject: [PATCH] Improve scripts for Linux --- env.sh | 19 +++++++++++----- env_linux.sh | 16 ++++++++++++-- env_salome.sh | 6 ++--- env_standalone.sh | 12 +++++++--- linux_run.sh | 17 ++++---------- salome_run.sh | 56 +++++++---------------------------------------- 6 files changed, 50 insertions(+), 76 deletions(-) diff --git a/env.sh b/env.sh index 67da8f758..68b0c0931 100644 --- a/env.sh +++ b/env.sh @@ -1,16 +1,23 @@ #!/bin/bash -x -set -o nounset +# Path to sources +export SOURCES_DIR=$(pwd) +# Path to build directory +export BUILD_DIR=$(cd ../build && pwd) +# Path to linux_run.sh & salome_run.sh +export AUT_DIR=$(pwd) +# Path to env_*.sh files +export TOOLS_DIR=$(pwd) + +# Extracts INST_ROOT directory for SALOME if [[ ! -f env_config.sh ]]; then echo "Can not find env_config.sh. Please, run config.sh." exit 1 fi source env_config.sh -export ROOT_DIR=$(cd $(dirname $0)/.. && pwd) -export SOURCES_DIR=${ROOT_DIR}/sources -export BUILD_DIR=${ROOT_DIR}/build${PLATFORM} -export INSTALL_DIR=${ROOT_DIR}/install${PLATFORM} - +# Path to solvespace-2 export NEWGEOM_PDIR=/dn48/newgeom/common/products +# Path to install directory +export NEWGEOM_ROOT_DIR=$(cd ../install && pwd) diff --git a/env_linux.sh b/env_linux.sh index b2a04b0f8..379bdd24c 100644 --- a/env_linux.sh +++ b/env_linux.sh @@ -1,7 +1,20 @@ #!/bin/bash +# This script uses: +# +# INST_ROOT - path of SALOME (env_products.sh) +# NEWGEOM_PDIR - path of PRODUCTS for NEWGEOM (SolveSpace, lcov) +# NEWGEOM_ROOT_DIR - path of NEWGEOM installation + +for path in INST_ROOT NEWGEOM_PDIR NEWGEOM_ROOT_DIR; do + if [[ -z ${!path+x} ]]; then + echo "${path} not found."; exit 1 + else + echo "Found ${path}: ${!path}" + fi +done + set +u -echo "Export SALOME from ${INST_ROOT}..." source ${INST_ROOT}/env_products.sh set -u @@ -25,7 +38,6 @@ export PATH=${CASROOT}:${PATH} ## #------ NewGEOM ------ -export NEWGEOM_ROOT_DIR=${INSTALL_DIR} export PATH=${NEWGEOM_ROOT_DIR}/bin:${NEWGEOM_ROOT_DIR}/plugins:${PATH} export PYTHONPATH=${NEWGEOM_ROOT_DIR}/swig:${NEWGEOM_ROOT_DIR}/plugins:${NEWGEOM_ROOT_DIR}/addons:${NEWGEOM_ROOT_DIR}/pythonAPI:${PYTHONPATH} export LD_LIBRARY_PATH=${NEWGEOM_ROOT_DIR}/bin:${NEWGEOM_ROOT_DIR}/swig:${NEWGEOM_ROOT_DIR}/plugins:${LD_LIBRARY_PATH} diff --git a/env_salome.sh b/env_salome.sh index eea2eca66..e4898ba70 100644 --- a/env_salome.sh +++ b/env_salome.sh @@ -1,9 +1,7 @@ #!/bin/bash -a_dir=$(dirname $0) - -source ${a_dir}/env_linux.sh +source ${TOOLS_DIR}/env_linux.sh # Correcting path which defined with error export LD_LIBRARY_PATH=${KERNEL_ROOT_DIR}/lib/salome:${LD_LIBRARY_PATH} -export SalomeAppConfig=${INSTALL_DIR}/share/salome/resources/newgeom:${GUI_ROOT_DIR}/share/salome/resources/gui +export SalomeAppConfig=${NEWGEOM_ROOT_DIR}/share/salome/resources/newgeom:${GUI_ROOT_DIR}/share/salome/resources/gui diff --git a/env_standalone.sh b/env_standalone.sh index 6be641c77..7e55f36cc 100644 --- a/env_standalone.sh +++ b/env_standalone.sh @@ -1,8 +1,14 @@ #!/bin/bash -a_dir=$(dirname $0) +for path in TOOLS_DIR; do + if [[ -z "${!path}" ]]; then + echo "${path} not found."; exit 1 + else + echo "Found ${path}: ${!path}" + fi +done -source ${a_dir}/env_linux.sh +source ${TOOLS_DIR}/env_linux.sh export LD_LIBRARY_PATH=${KERNEL_ROOT_DIR}/lib/salome:${LD_LIBRARY_PATH} -export LightAppConfig=${INSTALL_DIR}/share/salome/resources/newgeom:${GUI_ROOT_DIR}/share/salome/resources/gui +export LightAppConfig=${NEWGEOM_ROOT_DIR}/share/salome/resources/newgeom:${GUI_ROOT_DIR}/share/salome/resources/gui diff --git a/linux_run.sh b/linux_run.sh index 10b611264..5294b8828 100755 --- a/linux_run.sh +++ b/linux_run.sh @@ -1,17 +1,8 @@ #!/bin/bash -a_dir=$(dirname $0) +source env.sh +source ${TOOLS_DIR}/env_standalone.sh -cd ${a_dir} +APP=${NEWGEOM_ROOT_DIR}/bin/GeomApp -source ${a_dir}/env.sh -source ${a_dir}/env_standalone.sh - -if [ -f GDB ]; then - ${INSTALL_DIR}/bin/GeomApp >>log_GeomApp 2>>err_GeomApp & - APP_PID=$! - echo "Connecting GDB to PID ${APP_PID}..." - gdb - ${APP_PID} >>log_gdb_linux 2>>err_gdb_linux -else - ${INSTALL_DIR}/bin/GeomApp -fi +${APP} diff --git a/salome_run.sh b/salome_run.sh index cd02e5baa..ce82805fa 100755 --- a/salome_run.sh +++ b/salome_run.sh @@ -1,18 +1,7 @@ -#!/bin/bash -x +#!/bin/bash -a_dir=$(dirname $0) - -cd ${a_dir} - -source ${a_dir}/env.sh -source ${a_dir}/env_salome.sh - -SALOME_ARGS="-r ./test.squish/shared/testdata/SalomeApp.xml" -if [ -f GDB ]; then - echo "No --gdb-session" - #SALOME_ARGS="${SALOME_ARGS} --gdb-session" -fi -SALOME_ARGS="${SALOME_ARGS} --ns-port-log=$(pwd)/.salomeport" +source env.sh +source ${TOOLS_DIR}/env_salome.sh # kill processes of previous SALOME run if [ -f .salomeport ]; then @@ -22,42 +11,13 @@ if [ -f .salomeport ]; then rm .salomeport fi -${KERNEL_ROOT_DIR}/bin/salome/runSalome.py ${SALOME_ARGS} >log_runSalome 2>err_runSalome & -SALOME_PID=$! - -ATTEMPT=0 -while [[ ! -f .salomeport && ${ATTEMPT} -lt 5 ]]; do - sleep 5 - SALOME_PORT=$(cat .salomeport) - ATTEMPT=$[${ATTEMPT}+1] -done -if [ ${ATTEMPT} = 5 ]; then - echo "Can not receive SALOME_PORT: file .salomeport does not exist..." - exit 1 -fi - -echo "SALOME_PORT ${SALOME_PORT}" - -if [ -f GDB ]; then - SALOME_SESSION_SERVER_PID="$(salome_pid.py ${SALOME_PORT} 'SALOME_Session_Server' 2>/dev/null)" - ATTEMPT=0 - while [[ "${SALOME_SESSION_SERVER_PID}" = "" && "${ATTEMPT}" -lt 5 ]]; do - sleep 5 - SALOME_SESSION_SERVER_PID="$(salome_pid.py ${SALOME_PORT} 'SALOME_Session_Server' 2>/dev/null)" - ATTEMPT=$[${ATTEMPT}+1] - done - if [ ${ATTEMPT} = 5 ]; then - echo "Can not receive SALOME_SESSION_SERVER_PID..." - exit 2 - fi - - echo "SALOME_SESSION_SERVER_PID ${SALOME_SESSION_SERVER_PID}" - echo "Connecting GDB to PID ${SALOME_SESSION_SERVER_PID}..." - gdb - ${SALOME_SESSION_SERVER_PID} >>log_gdb_salome 2>>err_gdb_salome -fi +SALOME_ARGS="" +SALOME_ARGS="${SALOME_ARGS} -r ./test.squish/shared/testdata/SalomeApp.xml" +SALOME_ARGS="${SALOME_ARGS} --ns-port-log=$(pwd)/.salomeport" -wait ${SALOME_PID} +${KERNEL_ROOT_DIR}/bin/salome/runSalome.py ${SALOME_ARGS} >log_runSalome 2>err_runSalome +SALOME_PORT=$(cat .salomeport) echo "Kill SALOME on port ${SALOME_PORT}" ${KERNEL_ROOT_DIR}/bin/salome/killSalomeWithPort.py ${SALOME_PORT} pkill -f "omniNames -start ${SALOME_PORT}" -- 2.39.2