1
0
Fork 0

download_and_compile.sh: new function _logOutput()

Use this function for all commands that produce output we want to see on
the terminal and in the log file. Actually, the first parmeter of the
function, which is optional, allows one to choose where we want the
output to be written to: the terminal and/or the log file (three
possibilities, since for none of these, '>/dev/null' redirection can be
used directly).
This commit is contained in:
Florent Rougon 2018-10-11 12:12:36 +02:00
parent 6520925c5b
commit 2874e0eade

View file

@ -64,6 +64,22 @@ function _printLog(){
echo "$@" | tee -a "$LOGFILE" echo "$@" | tee -a "$LOGFILE"
} }
# Echo the contents of stdin to the terminal and/or to $LOGFILE.
function _logOutput(){
case "$1" in
term)
cat ;;
file)
cat >> "$LOGFILE" ;;
""|term+file)
tee -a "$LOGFILE" ;;
*)
_printLog "Bug in ${PROGNAME}: unexpected value for the first parameter" \
"of _logOutput(): '$1'"
exit 1 ;;
esac
}
function _logSep(){ function _logSep(){
echo "***********************************" >> $LOGFILE echo "***********************************" >> $LOGFILE
} }
@ -153,9 +169,9 @@ function _make(){
pkg=$1 pkg=$1
cd "$CBD"/build/$pkg cd "$CBD"/build/$pkg
echo "MAKE $pkg" >> $LOGFILE echo "MAKE $pkg" >> $LOGFILE
make $JOPTION $OOPTION 2>&1 | tee -a $LOGFILE make $JOPTION $OOPTION 2>&1 | _logOutput
echo "INSTALL $pkg" >> $LOGFILE echo "INSTALL $pkg" >> $LOGFILE
make install 2>&1 | tee -a $LOGFILE make install 2>&1 | _logOutput
fi fi
} }
@ -653,7 +669,7 @@ if _elementIn "CMAKE" "${WHATTOBUILD[@]}"; then
_printLog "CONFIGURING CMake" _printLog "CONFIGURING CMake"
cd "$CBD"/build/cmake cd "$CBD"/build/cmake
../../cmake/configure --prefix="$INSTALL_DIR_CMAKE" \ ../../cmake/configure --prefix="$INSTALL_DIR_CMAKE" \
2>&1 | tee -a $LOGFILE 2>&1 | _logOutput
fi fi
_make cmake _make cmake
@ -689,7 +705,7 @@ if _elementIn "PLIB" "${WHATTOBUILD[@]}"; then
cd "$CBD"/build/plib cd "$CBD"/build/plib
"$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ "$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_PLIB" \ -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_PLIB" \
../../plib 2>&1 | tee -a $LOGFILE ../../plib 2>&1 | _logOutput
fi fi
_make plib _make plib
@ -723,7 +739,7 @@ if _elementIn "OPENRTI" "${WHATTOBUILD[@]}"; then
rm -f CMakeCache.txt rm -f CMakeCache.txt
"$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ "$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_OPENRTI" \ -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_OPENRTI" \
../../openrti 2>&1 | tee -a $LOGFILE ../../openrti 2>&1 | _logOutput
fi fi
_make openrti _make openrti
@ -756,7 +772,8 @@ if _elementIn "OSG" "${WHATTOBUILD[@]}"; then
OSG_BUILD_TYPE=Release OSG_BUILD_TYPE=Release
fi fi
"$CMAKE" -DCMAKE_BUILD_TYPE="$OSG_BUILD_TYPE" \ "$CMAKE" -DCMAKE_BUILD_TYPE="$OSG_BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_OSG" ../../openscenegraph/ 2>&1 | tee -a $LOGFILE -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_OSG" ../../openscenegraph \
2>&1 | _logOutput
fi fi
_make openscenegraph _make openscenegraph
@ -795,7 +812,7 @@ if _elementIn "SIMGEAR" "${WHATTOBUILD[@]}"; then
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_SIMGEAR" \ -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_SIMGEAR" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR_OSG;$INSTALL_DIR_OPENRTI" \ -DCMAKE_PREFIX_PATH="$INSTALL_DIR_OSG;$INSTALL_DIR_OPENRTI" \
$SG_CMAKEARGS \ $SG_CMAKEARGS \
../../simgear 2>&1 | tee -a $LOGFILE ../../simgear 2>&1 | _logOutput
fi fi
_make simgear _make simgear
@ -843,7 +860,7 @@ if _elementIn "FGFS" "${WHATTOBUILD[@]}" || \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_OSG;$INSTALL_DIR_OPENRTI;$INSTALL_DIR_PLIB" \ -DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_OSG;$INSTALL_DIR_OPENRTI;$INSTALL_DIR_PLIB" \
-DFG_DATA_DIR="$INSTALL_DIR_FGFS/fgdata" \ -DFG_DATA_DIR="$INSTALL_DIR_FGFS/fgdata" \
$FG_CMAKEARGS \ $FG_CMAKEARGS \
../../flightgear 2>&1 | tee -a $LOGFILE ../../flightgear 2>&1 | _logOutput
fi fi
_make flightgear _make flightgear
@ -898,7 +915,7 @@ if _elementIn "FGRUN" "${WHATTOBUILD[@]}"; then
"$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \ "$CMAKE" -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_FGRUN" \ -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_FGRUN" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR" \ -DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR" \
../../fgrun/ 2>&1 | tee -a $LOGFILE ../../fgrun/ 2>&1 | _logOutput
fi fi
_make fgrun _make fgrun
@ -986,7 +1003,7 @@ if _elementIn "FGX" "${WHATTOBUILD[@]}"; then
cd $INSTALL_DIR_FGX cd $INSTALL_DIR_FGX
echo "MAKE AND INSTALL FGX" >> $LOGFILE echo "MAKE AND INSTALL FGX" >> $LOGFILE
echo "make $JOPTION $OOPTION " >> $LOGFILE echo "make $JOPTION $OOPTION " >> $LOGFILE
make $JOPTION $OOPTION | tee -a $LOGFILE make $JOPTION $OOPTION 2>&1 | _logOutput
cd .. cd ..
fi fi
@ -1079,7 +1096,7 @@ if _elementIn "TERRAGEAR" "${WHATTOBUILD[@]}"; then
"$CMAKE" -DCMAKE_BUILD_TYPE="Debug" \ "$CMAKE" -DCMAKE_BUILD_TYPE="Debug" \
-DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_TG" \ -DCMAKE_INSTALL_PREFIX:PATH="$INSTALL_DIR_TG" \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_CGAL" \ -DCMAKE_PREFIX_PATH="$INSTALL_DIR_SIMGEAR;$INSTALL_DIR_CGAL" \
../../terragear/ 2>&1 | tee -a $LOGFILE ../../terragear/ 2>&1 | _logOutput
fi fi
_make terragear _make terragear
@ -1130,7 +1147,7 @@ if _elementIn "TERRAGEARGUI" "${WHATTOBUILD[@]}"; then
rm -f ../../terrageargui/CMakeCache.txt rm -f ../../terrageargui/CMakeCache.txt
"$CMAKE" -DCMAKE_BUILD_TYPE="Release" \ "$CMAKE" -DCMAKE_BUILD_TYPE="Release" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR_TGGUI" \ -DCMAKE_INSTALL_PREFIX="$INSTALL_DIR_TGGUI" \
../../terrageargui 2>&1 | tee -a $LOGFILE ../../terrageargui 2>&1 | _logOutput
fi fi
_make terrageargui _make terrageargui