X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=scripts%2FSA_build;h=84d8b2bc2e44af4a6cf9ff4f22710094e507b507;hb=refs%2Ftags%2FV5_1_2rc2;hp=5c1328afac18802ae37204617b7d7651f06a617f;hpb=53f7af15eebcc3d8b2b98cba636fb8c9d4fba8dd;p=tools%2Fhxx2salome.git diff --git a/scripts/SA_build b/scripts/SA_build index 5c1328a..84d8b2b 100755 --- a/scripts/SA_build +++ b/scripts/SA_build @@ -1,4 +1,8 @@ #!/bin/bash +# -- +# Copyright (C) CEA, EDF +# Author : Nicolas Crouzet (CEA) +# -- # # Utility for building Salome Modules # @@ -39,8 +43,10 @@ usage() echo " --disable-debug : compilation without debug traces" echo " --batch : compilation is done in batch mode - no prompting" echo " --environ=path : set environment file to path (should be absolute)" - echo " --install=path : set install directory where module building is done (should be absolute)" - echo " --compile-only -c : no building - just compile by calling make && make install" + echo " this file will be updated with new environment variables. " + echo " it will also be sources if it has sh syntax" + echo " --install=path : set install directory where module building and install is done (should be absolute)" + echo " --compile-only -c : no building and configure - just compile by calling make && make install" echo " --local -l : look for source directories localy - build and install localy" echo " --sources=src1,src2,... : for specifying source directories that don't end up with _SRC" echo @@ -109,12 +115,20 @@ compile() make if [ $? -eq 0 ] then - # compilation succeeded : we make install + echo -e "\n [OK] Compile : ${module}/${SOURCE_NAME}_SRC" >> $CR + echo Compilation succeeded : we make install echo echo "----------------- Install ---------------------" make install + if [ $? -eq 0 ] + then + echo -e " [OK] Install : ${module}/${SOURCE_NAME}_SRC" >> $CR + else + echo -e " [KO] Install : ${module}/${SOURCE_NAME}_SRC" >> $CR + fi else - exit 1 + echo Compilation failed + echo -e "\n [KO] Compile : ${module}/${SOURCE_NAME}_SRC" >> $CR fi } @@ -171,7 +185,14 @@ build_source_dir() ask_confirmation "Compile ?" fi cd ${INSTALL_ROOT_DIR}/${module}/${SOURCE_NAME}_BUILD - compile + if [ $? -eq 0 ] + then + compile + else + echo "ERROR : build directory ${INSTALL_ROOT_DIR}/${module}/${SOURCE_NAME}_BUILD not found" + echo " with -c option, build directory should already exist" + exit + fi else if [ $BATCH_MODE -eq 0 ] @@ -227,17 +248,45 @@ build_source_dir() update_environ() { cp ${ENVIRON_FILE} ${ENVIRON_FILE}.old - grep " $1" ${ENVIRON_FILE}.old - if [ $? -eq 0 ] + if [ "${SHELL_EXT}" == "sh" ] then - # if variable is already set, we replace old setting by new one - cat ${ENVIRON_FILE}.old | awk -v var_root_dir=$1 -v path=$2 -v src_root_dir=$3 -v src_dir=$4 ' - $1=="export" && $2 ~ var_root_dir {print "#"$0; $0="export "var_root_dir "=" path} - $1=="export" && $2 ~ src_root_dir {print "#"$0; $0="export "src_root_dir "=" src_dir} - { print $0}' > ${ENVIRON_FILE} + grep " $1" ${ENVIRON_FILE}.old > /dev/null + if [ $? -eq 0 ] + then + # if variable is already set, we replace old setting by new one + cat ${ENVIRON_FILE}.old | awk -v var_root_dir=$1 -v path=$2 -v src_root_dir=$3 -v src_dir=$4 ' + $1=="export" && $2 ~ "^"var_root_dir"=" {print "#"$0; $0="export "var_root_dir "=" path} + $1=="export" && $2 ~ "^"src_root_dir"=" {print "#"$0; $0="export "src_root_dir "=" src_dir} + $1 ~ "^"var_root_dir"=" {print "#"$0; $0=var_root_dir "=" path} + $1 ~ "^"src_root_dir"=" {print "#"$0; $0=src_root_dir "=" src_dir} + { print $0}' > ${ENVIRON_FILE} + else + echo -e "##\n#------ ${SOURCE_NAME}-Src ------\nexport $3=$4" >> ${ENVIRON_FILE} + echo -e "##\n#------ ${SOURCE_NAME}-Bin ------\nexport $1=$2" >> ${ENVIRON_FILE} + if [ -d $2/lib ] && [ ! -d $2/lib/salome ] + then + # for salome modules, do nothing + echo -e "export PYTHONPATH=\${${1}}/bin:\${${1}}/lib:\${PYTHONPATH}" >> ${ENVIRON_FILE} + fi + fi else - echo -e "##\n#------ ${SOURCE_NAME}-Src ------\nexport $3=$4" >> ${ENVIRON_FILE} - echo -e "##\n#------ ${SOURCE_NAME}-Bin ------\nexport $1=$2" >> ${ENVIRON_FILE} + grep " $1" ${ENVIRON_FILE}.old > /dev/null + if [ $? -eq 0 ] + then + # if variable is already set, we replace old setting by new one + cat ${ENVIRON_FILE}.old | awk -v var_root_dir=$1 -v path=$2 -v src_root_dir=$3 -v src_dir=$4 ' + $1=="setenv" && $2 == var_root_dir {print "#"$0; $0="setenv "var_root_dir " " path} + $1=="setenv" && $2 == src_root_dir {print "#"$0; $0="setenv "src_root_dir " " src_dir} + { print $0}' > ${ENVIRON_FILE} + else + echo -e "##\n#------ ${SOURCE_NAME}-Src ------\nsetenv $3 $4" >> ${ENVIRON_FILE} + echo -e "##\n#------ ${SOURCE_NAME}-Bin ------\nsetenv $1 $2" >> ${ENVIRON_FILE} + if [ -d $2/lib ] && [ ! -d $2/lib/salome ] + then + echo -e "setenv PYTHONPATH \${${1}}/bin:\${${1}}/lib:\${PYTHONPATH}" >> ${ENVIRON_FILE} + fi + + fi fi } @@ -303,14 +352,30 @@ echo "Liste repertoire echo "Options configure : $OPTIONS_CONFIGURE" echo "Environment File : $ENVIRON_FILE" echo +CR=/tmp/${USER}_SA_build_CR +echo -e "\n" > $CR -if [ $ENVIRON_FILE ] && [ -f $ENVIRON_FILE ] +if [ $ENVIRON_FILE ] && [ -f $ENVIRON_FILE ] # if an existing environment file was specified then - # force option for compilation - then source environment - cat ${ENVIRON_FILE} | sed "s/ENV_FOR_LAUNCH=1/ENV_FOR_LAUNCH=0/g" > ${ENVIRON_FILE}.tmp - source ${ENVIRON_FILE}.tmp - rm ${ENVIRON_FILE}.tmp - echo source Environment File with ENV_FOR_LAUNCH=0 + # get shell extension + case ${ENVIRON_FILE##*\.} in + bash) SHELL_EXT=sh;; + ksh) SHELL_EXT=sh;; + csh) SHELL_EXT=csh;; + sh) SHELL_EXT=sh;; + *) SHELL_EXT=sh;echo WARNING : shell extension not recognized! Assume sh ;; + esac + if [ "${SHELL_EXT}" == "sh" ] + then + # if shell syntax is sh, source environment with ENV_FOR_LAUNCH set to 0 + cat ${ENVIRON_FILE} | sed "s/ENV_FOR_LAUNCH=1/ENV_FOR_LAUNCH=0/g" > ${ENVIRON_FILE}.tmp + source ${ENVIRON_FILE}.tmp + rm ${ENVIRON_FILE}.tmp + echo source Environment File with ENV_FOR_LAUNCH=0 + else + echo "WARNING : environment file has csh extension => cannot source it and assume environment already set." + echo -e " (if compilation fails, please set environment before, of choose an sh syntax file)\n" + fi else echo Warning : Environment File Not Found! fi @@ -344,3 +409,5 @@ else done fi +echo -e "\n----------------- Résumé ----------------" +cat ${CR}