wmake: Correct issues introduced during updates for shellcheck

Patch contributed by Bruno Santos
Resolves bug-report https://bugs.openfoam.org/view.php?id=2983
This commit is contained in:
Henry Weller
2018-06-17 20:42:36 +01:00
parent 46821b553c
commit ee4ed5d942
5 changed files with 45 additions and 16 deletions

View File

@ -38,7 +38,7 @@ Script=${0##*/}
# Source the wmake functions # Source the wmake functions
# shellcheck source=scripts/wmakeFunctions # shellcheck source=scripts/wmakeFunctions
. ${0%/*}/scripts/wmakeFunctions . "${0%/*}/scripts/wmakeFunctions"
error() { error() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done

View File

@ -39,7 +39,7 @@ Script=${0##*/}
# Source the wmake functions # Source the wmake functions
# shellcheck source=scripts/wmakeFunctions # shellcheck source=scripts/wmakeFunctions
. ${0%/*}/scripts/wmakeFunctions . "${0%/*}/scripts/wmakeFunctions"
usage() { usage() {
cat<<USAGE cat<<USAGE

View File

@ -153,7 +153,7 @@ do
# Parallel compilation on all cores of local machine # Parallel compilation on all cores of local machine
-j) -j)
useAllCores useAllCores
test $# -ge 2 && (($2 + 1)) > /dev/null 2>&1 \ [ $# -ge 2 ] && [ "$2" -gt 0 ] > /dev/null 2>&1 \
&& shift && export WM_NCOMPPROCS=$1 && shift && export WM_NCOMPPROCS=$1
echo "Compiling enabled on $WM_NCOMPPROCS cores" echo "Compiling enabled on $WM_NCOMPPROCS cores"
;; ;;
@ -222,11 +222,11 @@ then
WM_NCOMPPROCS=$(wmakeScheduler -count) || unset WM_NCOMPPROCS WM_NCOMPPROCS=$(wmakeScheduler -count) || unset WM_NCOMPPROCS
fi fi
if [ "$WM_NCOMPPROCS" ] if [ -n "$WM_NCOMPPROCS" ]
then then
parOpt="-j $WM_NCOMPPROCS" parOpt="-j $WM_NCOMPPROCS"
if [ "$WM_NCOMPPROCS" -gt 1 ] && [ ! "$MAKEFLAGS" ] if [ "$WM_NCOMPPROCS" -gt 1 ] && [ -z "$MAKEFLAGS" ]
then then
lockDir=$HOME/.$WM_PROJECT/.wmake lockDir=$HOME/.$WM_PROJECT/.wmake

View File

@ -55,7 +55,7 @@ Script=${0##*/}
# Source the wmake functions # Source the wmake functions
# shellcheck source=scripts/wmakeFunctions # shellcheck source=scripts/wmakeFunctions
. ${0%/*}/scripts/wmakeFunctions . "${0%/*}/scripts/wmakeFunctions"
usage() { usage() {
cat<<USAGE cat<<USAGE
@ -92,6 +92,18 @@ error() {
exit 1 exit 1
} }
removeDepFiles()
{
if [ "$#" -eq 1 ]
then
find "$1" -name '*.dep' -print0 | xargs -0t rm 2>/dev/null
elif [ "$#" -eq 2 ]
then
find "$1" -name '*.dep' -exec grep -q "$2" '{}' \; \
-exec rm '{}' \; -print
fi
}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Parse arguments and options # Parse arguments and options
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -144,20 +156,37 @@ files)
findObjectDir . findObjectDir .
# With the -a/-all option replace the current platform with a wildcard # First give the verbose information for the current searching method
if [ "$all" = "all" ]
then
objectsDir=$(echo "$objectsDir" | sed s%"$WM_OPTIONS"%*% )
fi
if [ "$#" -eq 0 ] if [ "$#" -eq 0 ]
then then
echo "removing all .dep files ..." echo "removing all .dep files ..."
find "$objectsDir" -name '*.dep' -print0 | xargs -0t rm 2>/dev/null
else else
echo "removing .dep files referring to $1 ..." echo "removing .dep files referring to $1 ..."
find "$objectsDir" -name '*.dep' -exec grep -q "$1" '{}' \; \ fi
-exec rm '{}' \; -print
# With the -a/-all option replace the current platform with a wildcard
if [ "$all" = "all" ]
then
# Handle the removal on all platforms for consistency
mainPath=${objectsDir%%/$WM_OPTIONS*}
objSubPath=${objectsDir##*$WM_OPTIONS/}
for pathEntry in "$mainPath"/*
do
if [ -e "$pathEntry/$objSubPath" ]
then
# Note:
# If $1 is empty, it should still work for the default method
removeDepFiles "$pathEntry/$objSubPath" "$1"
fi
done
else
# Handle only the removal for the current WM_OPTIONS
removeDepFiles "$objectsDir" "$1"
fi fi
;; ;;

View File

@ -39,7 +39,7 @@ Script=${0##*/}
# Source the wmake functions # Source the wmake functions
# shellcheck source=scripts/wmakeFunctions # shellcheck source=scripts/wmakeFunctions
. ${0%/*}/scripts/wmakeFunctions . "${0%/*}/scripts/wmakeFunctions"
usage() { usage() {
cat<<USAGE cat<<USAGE