wmake.*: Improved robustness and portability using shellcheck
This commit is contained in:
54
wmake/wclean
54
wmake/wclean
@ -1,9 +1,9 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -37,6 +37,7 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source the wmake functions
|
||||||
|
# shellcheck source=scripts/wmakeFunctions
|
||||||
. ${0%/*}/scripts/wmakeFunctions
|
. ${0%/*}/scripts/wmakeFunctions
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
@ -120,7 +121,7 @@ then
|
|||||||
|
|
||||||
if [ "$dir" ]
|
if [ "$dir" ]
|
||||||
then
|
then
|
||||||
cd $dir 2>/dev/null || {
|
cd "$dir" 2>/dev/null || {
|
||||||
echo "$Script error: could not change to directory '$dir'" 1>&2
|
echo "$Script error: could not change to directory '$dir'" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -152,61 +153,61 @@ then
|
|||||||
echo "Removing empty directories..."
|
echo "Removing empty directories..."
|
||||||
|
|
||||||
# Get sub-directories avoiding particular directories
|
# Get sub-directories avoiding particular directories
|
||||||
|
# shellcheck disable=SC2044
|
||||||
for dir in $(find . -mindepth 1 -maxdepth 1 \
|
for dir in $(find . -mindepth 1 -maxdepth 1 \
|
||||||
-type d \( -name .git -prune -o -print \) )
|
-type d \( -name .git -prune -o -print \) )
|
||||||
do
|
do
|
||||||
echo " searching: $dir"
|
echo " searching: $dir"
|
||||||
find $dir -depth -type d -empty -exec rmdir {} \; -print
|
find "$dir" -depth -type d -empty -exec rmdir {} \; -print
|
||||||
done
|
done
|
||||||
|
|
||||||
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
|
# Second pass: clean up object directories with WM_PROJECT_DIR that don't
|
||||||
# have respective source code folders, along with the respective binaries
|
# have respective source code folders, along with the respective binaries
|
||||||
|
|
||||||
expandPath $PWD
|
expandPath "$PWD"
|
||||||
if [ "$exPath" = "$WM_PROJECT_DIR" ]
|
if [ "$exPath" = "$WM_PROJECT_DIR" ]
|
||||||
then
|
then
|
||||||
findObjectDir $PWD
|
findObjectDir "$PWD"
|
||||||
|
|
||||||
if [ -d $objectsDir ]
|
if [ -d "$objectsDir" ]
|
||||||
then
|
then
|
||||||
echo " Removing redundant object directories in $objectsDir"
|
echo " Removing redundant object directories in $objectsDir"
|
||||||
|
|
||||||
find $objectsDir -name 'variables' -print | \
|
find "$objectsDir" -name 'variables' -print | \
|
||||||
while read variablesFile
|
while read -r variablesFile
|
||||||
do
|
do
|
||||||
# Hack'ish way of getting the original source code path
|
# Hack'ish way of getting the original source code path
|
||||||
depFile=$(dirname $variablesFile)
|
depFile=$(dirname "$variablesFile")
|
||||||
depToSource $depFile
|
depToSource "$depFile"
|
||||||
|
|
||||||
# Check if the original source code directory exists
|
# Check if the original source code directory exists
|
||||||
if [ ! -r "$sourceFile" ]
|
if [ ! -r "$sourceFile" ]
|
||||||
then
|
then
|
||||||
# Delete the respective binary first
|
# Delete the respective binary first
|
||||||
binaryFile=$(cat $variablesFile |
|
binaryFile=$(grep -e '^ *\(EXE\|LIB\) *= *' "$variablesFile")
|
||||||
grep -e '^ *\(EXE\|LIB\) *= *' )
|
|
||||||
|
|
||||||
# Catch all file extension (o,a,so,?+) for libraries
|
# Catch all file extension (o,a,so,?+) for libraries
|
||||||
if echo $binaryFile | grep -qe '^ *LIB *= *'
|
if echo "$binaryFile" | grep -qe '^ *LIB *= *'
|
||||||
then
|
then
|
||||||
binaryFile="${binaryFile}.*"
|
binaryFile="${binaryFile}.*"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Isolate path and translate environment variables
|
# Isolate path and translate environment variables
|
||||||
binaryFile=$(echo $binaryFile | \
|
binaryFile=$(echo "$binaryFile" | \
|
||||||
sed -e 's/^ *\(EXE\|LIB\) *= *//' \
|
sed -e 's/^ *\(EXE\|LIB\) *= *//' \
|
||||||
-e 's/(/{/g' -e 's/)/}/g' )
|
-e 's/(/{/g' -e 's/)/}/g' )
|
||||||
|
|
||||||
# Expand environment variables for path
|
# Expand environment variables for path
|
||||||
binaryFile=$(eval echo $binaryFile)
|
binaryFile=$(eval echo "$binaryFile")
|
||||||
|
|
||||||
# Verbosely remove binary file
|
# Verbosely remove binary file
|
||||||
if [ -n "$binaryFile" -a -e "$binaryFile" ]
|
if [ -n "$binaryFile" ] && [ -e "$binaryFile" ]
|
||||||
then
|
then
|
||||||
rm -vf $binaryFile 2>/dev/null
|
rm -vf "$binaryFile" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the deprecated object directory
|
# Remove the deprecated object directory
|
||||||
rm -rvf $depFile 2>/dev/null
|
rm -rvf "$depFile" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -232,16 +233,17 @@ then
|
|||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
# For all the sub-directories containing a 'Make' directory
|
# For all the sub-directories containing a 'Make' directory
|
||||||
for dir in `find . \( -type d -a -name Make \)`
|
# shellcheck disable=SC2044
|
||||||
|
for dir in $(find . \( -type d -a -name Make \))
|
||||||
do
|
do
|
||||||
dir=${dir%/Make} # Parent directory - trim /Make from the end
|
dir=${dir%/Make} # Parent directory - trim /Make from the end
|
||||||
|
|
||||||
# If Allwclean exists execute otherwise wclean
|
# If Allwclean exists execute otherwise wclean
|
||||||
if [ -e "$dir/Allwclean" ]
|
if [ -e "$dir/Allwclean" ]
|
||||||
then
|
then
|
||||||
$dir/Allwclean
|
"$dir/Allwclean"
|
||||||
else
|
else
|
||||||
$0 $dir
|
$0 "$dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
@ -255,15 +257,15 @@ unset targetType
|
|||||||
# Clean the 'Make' directory if present
|
# Clean the 'Make' directory if present
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [ -d $MakeDir ]
|
if [ -d "$MakeDir" ]
|
||||||
then
|
then
|
||||||
objectsDir=$MakeDir/$WM_OPTIONS
|
objectsDir=$MakeDir/$WM_OPTIONS
|
||||||
if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ]
|
if [[ "$PWD" = *"$WM_PROJECT_DIR"* ]]
|
||||||
then
|
then
|
||||||
platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
|
platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
|
||||||
objectsDir=$platformPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
|
objectsDir=$platformPath${PWD//$WM_PROJECT_DIR/}
|
||||||
fi
|
fi
|
||||||
rm -rf $objectsDir 2>/dev/null
|
rm -rf "$objectsDir" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -79,16 +79,16 @@ USAGE
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Print help message
|
# Print help message
|
||||||
if [ "$1" = "-h" -o "$1" = "-help" ]; then
|
if [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
||||||
usage && exit 0
|
usage && exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the script is executed from the project top-level directory
|
# Check the script is executed from the project top-level directory
|
||||||
[ "$PWD" = "$WM_PROJECT_DIR" ] || \
|
[ "$PWD" = "$WM_PROJECT_DIR" ] || \
|
||||||
error "Not in the project top-level directory " $WM_PROJECT_DIR
|
error "Not in the project top-level directory " "$WM_PROJECT_DIR"
|
||||||
|
|
||||||
# Get the platforms from the arguments
|
# Get the platforms from the arguments
|
||||||
platforms="$@"
|
platforms="$*"
|
||||||
|
|
||||||
# If no arguments are provided select the current platform
|
# If no arguments are provided select the current platform
|
||||||
if [ "$#" -lt 1 ]; then
|
if [ "$#" -lt 1 ]; then
|
||||||
@ -100,7 +100,7 @@ if [ "$platforms" = "-all" ]; then
|
|||||||
rm -rf platforms/*
|
rm -rf platforms/*
|
||||||
|
|
||||||
echo "Removing lnInclude directories"
|
echo "Removing lnInclude directories"
|
||||||
find . -depth -type d \( -name lnInclude \) | xargs rm -rf
|
find . -depth -type d \( -name lnInclude \) -print0 | xargs -0 rm -rf
|
||||||
|
|
||||||
tutorials/Allclean
|
tutorials/Allclean
|
||||||
else
|
else
|
||||||
@ -114,10 +114,10 @@ else
|
|||||||
[ -n "$platform" ] || continue
|
[ -n "$platform" ] || continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d platforms/${platform} ]
|
if [ -d platforms/"${platform}" ]
|
||||||
then
|
then
|
||||||
echo "Cleaning platform $platform"
|
echo "Cleaning platform $platform"
|
||||||
rm -rf platforms/${platform}*
|
rm -rf platforms/"${platform}"*
|
||||||
else
|
else
|
||||||
echo "Platform $platform not built"
|
echo "Platform $platform not built"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source the wmake functions
|
||||||
|
# shellcheck source=scripts/wmakeFunctions
|
||||||
. ${0%/*}/scripts/wmakeFunctions
|
. ${0%/*}/scripts/wmakeFunctions
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@ -90,9 +91,9 @@ checkEnv
|
|||||||
|
|
||||||
sourceFile=$1
|
sourceFile=$1
|
||||||
|
|
||||||
if [ ! -e $1 ]
|
if [ ! -e "$1" ]
|
||||||
then
|
then
|
||||||
sourceFile=$(find . -name $sourceFile -print -quit)
|
sourceFile=$(find . -name "$sourceFile" -print -quit)
|
||||||
if [ -z "$sourceFile" ]
|
if [ -z "$sourceFile" ]
|
||||||
then
|
then
|
||||||
echo "$Script: cannot find source file $1" 1>&2
|
echo "$Script: cannot find source file $1" 1>&2
|
||||||
@ -106,11 +107,11 @@ fi
|
|||||||
# and echo path for the dep file corresponding to the specified source file
|
# and echo path for the dep file corresponding to the specified source file
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
findObjectDir $sourceFile
|
findObjectDir "$sourceFile"
|
||||||
|
|
||||||
fileName=${1##*/}
|
fileName=${1##*/}
|
||||||
|
|
||||||
echo $objectsDir/$fileName.dep
|
echo "$objectsDir/$fileName.dep"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
67
wmake/wmake
67
wmake/wmake
@ -56,7 +56,8 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source the wmake functions
|
||||||
. ${0%/*}/scripts/wmakeFunctions
|
# shellcheck source=scripts/wmakeFunctions
|
||||||
|
. "${0%/*}/scripts/wmakeFunctions"
|
||||||
|
|
||||||
error() {
|
error() {
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
@ -116,7 +117,7 @@ useAllCores()
|
|||||||
{
|
{
|
||||||
if [ -r /proc/cpuinfo ]
|
if [ -r /proc/cpuinfo ]
|
||||||
then
|
then
|
||||||
WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l)
|
WM_NCOMPPROCS=$(grep -Ec "^processor" /proc/cpuinfo)
|
||||||
else
|
else
|
||||||
WM_NCOMPPROCS=1
|
WM_NCOMPPROCS=1
|
||||||
fi
|
fi
|
||||||
@ -152,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 && expr $2 + 1 > /dev/null 2>&1 \
|
test $# -ge 2 && (($2 + 1)) > /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"
|
||||||
;;
|
;;
|
||||||
@ -202,7 +203,7 @@ checkEnv
|
|||||||
|
|
||||||
# When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR
|
# When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR
|
||||||
# must be set
|
# must be set
|
||||||
[ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || {
|
[ "$1" = exe ] || { [ "$WM_PROJECT" ] && [ "$WM_PROJECT_DIR" ]; } || {
|
||||||
echo "$Script error:" 1>&2
|
echo "$Script error:" 1>&2
|
||||||
echo " environment variable \$WM_PROJECT or " \
|
echo " environment variable \$WM_PROJECT or " \
|
||||||
"\$WM_PROJECT_DIR not set" 1>&2
|
"\$WM_PROJECT_DIR not set" 1>&2
|
||||||
@ -216,25 +217,24 @@ checkEnv
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
|
# Set WM_NCOMPPROCS automatically when both WM_HOSTS and WM_SCHEDULER are set
|
||||||
if [ -z "$WM_NCOMPPROCS" -a -n "$WM_HOSTS" -a -n "$WM_SCHEDULER" ]
|
if [ -z "$WM_NCOMPPROCS" ] && [ -n "$WM_HOSTS" ] && [ -n "$WM_SCHEDULER" ]
|
||||||
then
|
then
|
||||||
WM_NCOMPPROCS=$(wmakeScheduler -count)
|
WM_NCOMPPROCS=$(wmakeScheduler -count) || unset WM_NCOMPPROCS
|
||||||
[ $? -eq 0 ] || unset WM_NCOMPPROCS
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$WM_NCOMPPROCS" ]
|
if [ "$WM_NCOMPPROCS" ]
|
||||||
then
|
then
|
||||||
parOpt="-j $WM_NCOMPPROCS"
|
parOpt="-j $WM_NCOMPPROCS"
|
||||||
|
|
||||||
if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ]
|
if [ "$WM_NCOMPPROCS" -gt 1 ] && [ ! "$MAKEFLAGS" ]
|
||||||
then
|
then
|
||||||
lockDir=$HOME/.$WM_PROJECT/.wmake
|
lockDir=$HOME/.$WM_PROJECT/.wmake
|
||||||
|
|
||||||
if [ -d $lockDir ]
|
if [ -d "$lockDir" ]
|
||||||
then
|
then
|
||||||
rm -f $lockDir/*
|
rm -f "$lockDir/*"
|
||||||
else
|
else
|
||||||
mkdir -p $lockDir
|
mkdir -p "$lockDir"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
make="$make --no-print-directory $parOpt"
|
make="$make --no-print-directory $parOpt"
|
||||||
@ -266,7 +266,7 @@ then
|
|||||||
|
|
||||||
if [ "$dir" ]
|
if [ "$dir" ]
|
||||||
then
|
then
|
||||||
cd $dir 2>/dev/null || {
|
cd "$dir" 2>/dev/null || {
|
||||||
echo "$Script error: could not change to directory '$dir'" 1>&2
|
echo "$Script error: could not change to directory '$dir'" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
@ -286,7 +286,7 @@ if [ -n "$update" ]
|
|||||||
then
|
then
|
||||||
wrmdep -update
|
wrmdep -update
|
||||||
wrmdep -old
|
wrmdep -old
|
||||||
wmakeLnIncludeAll -update $parOpt
|
wmakeLnIncludeAll -update "$parOpt"
|
||||||
wclean empty
|
wclean empty
|
||||||
export WM_UPDATE_DEPENDENCIES=yes
|
export WM_UPDATE_DEPENDENCIES=yes
|
||||||
elif [ -z "$all" ]
|
elif [ -z "$all" ]
|
||||||
@ -303,7 +303,7 @@ if [ "$all" = "all" ]
|
|||||||
then
|
then
|
||||||
if [ -e Allwmake ]
|
if [ -e Allwmake ]
|
||||||
then
|
then
|
||||||
./Allwmake -fromWmake $targetType
|
./Allwmake -fromWmake "$targetType"
|
||||||
exit $?
|
exit $?
|
||||||
else
|
else
|
||||||
# Have to keep track of the main exit code for the call to "make"
|
# Have to keep track of the main exit code for the call to "make"
|
||||||
@ -312,22 +312,21 @@ then
|
|||||||
# Find all the sub-directories containing a 'Make' directory
|
# Find all the sub-directories containing a 'Make' directory
|
||||||
FOAM_APPS=$(\
|
FOAM_APPS=$(\
|
||||||
for d in *; \
|
for d in *; \
|
||||||
do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] \
|
do [ -d "$d" ] && [ "$d" != Optional ] && [ "$d" != Make ] \
|
||||||
&& echo "$d"; \
|
&& echo "$d"; \
|
||||||
done | xargs \
|
done | xargs \
|
||||||
)
|
)
|
||||||
|
|
||||||
if [ ! "$FOAM_APPS" = "" ]
|
if [ ! "$FOAM_APPS" = "" ]
|
||||||
then
|
then
|
||||||
# Compile all applications in sub-directories
|
# Compile all applications in sub-directories
|
||||||
$make ${WM_CONTINUE_ON_ERROR:+-k} \
|
$make ${WM_CONTINUE_ON_ERROR:+-k} \
|
||||||
-f $WM_DIR/makefiles/apps \
|
-f "$WM_DIR/makefiles/apps" \
|
||||||
TARGET="$targetType" FOAM_APPS="$FOAM_APPS"
|
TARGET="$targetType" FOAM_APPS="$FOAM_APPS"
|
||||||
makeExitCode=$?
|
makeExitCode=$?
|
||||||
fi
|
fi
|
||||||
# If the current directory contains a 'Make' directory continue
|
# If the current directory contains a 'Make' directory continue
|
||||||
# otherwise exit, or always exit in case of error
|
# otherwise exit, or always exit in case of error
|
||||||
if [ ! -d $MakeDir -o $makeExitCode -ne 0 ]
|
if [ ! -d "$MakeDir" ] || [ "$makeExitCode" -ne 0 ]
|
||||||
then
|
then
|
||||||
exit $makeExitCode
|
exit $makeExitCode
|
||||||
fi
|
fi
|
||||||
@ -344,7 +343,7 @@ fi
|
|||||||
|
|
||||||
if [ "$all" = "queue" ]
|
if [ "$all" = "queue" ]
|
||||||
then
|
then
|
||||||
[ -n "$update" ] || wmakeLnIncludeAll $parOpt
|
[ -n "$update" ] || wmakeLnIncludeAll "$parOpt"
|
||||||
|
|
||||||
(
|
(
|
||||||
export WM_COLLECT_DIR=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}/${PWD////_}
|
export WM_COLLECT_DIR=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}/${PWD////_}
|
||||||
@ -385,7 +384,6 @@ then
|
|||||||
case "$targetType" in
|
case "$targetType" in
|
||||||
lib*)
|
lib*)
|
||||||
unset targetType
|
unset targetType
|
||||||
break
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
@ -397,23 +395,23 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
objectsDir=$MakeDir/$WM_OPTIONS
|
objectsDir=$MakeDir/$WM_OPTIONS
|
||||||
if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ]
|
if [[ "$PWD" = *"$WM_PROJECT_DIR"* ]]
|
||||||
then
|
then
|
||||||
platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
|
platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}
|
||||||
objectsDir=$platformPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% )
|
objectsDir=$platformPath${PWD//$WM_PROJECT_DIR/}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
(
|
||||||
unset MAKEFLAGS
|
unset MAKEFLAGS
|
||||||
mkdir -p $objectsDir
|
mkdir -p "$objectsDir"
|
||||||
|
|
||||||
# Pre-build the $WM_OPTIONS/options file
|
# Pre-build the $WM_OPTIONS/options file
|
||||||
# which is included when building the $WM_OPTIONS/files file
|
# which is included when building the $WM_OPTIONS/files file
|
||||||
$make -s -f $WM_DIR/makefiles/files MAKE_DIR=$MakeDir \
|
$make -s -f "$WM_DIR/makefiles/files" MAKE_DIR="$MakeDir" \
|
||||||
OBJECTS_DIR=$objectsDir $objectsDir/options
|
OBJECTS_DIR="$objectsDir" "$objectsDir/options"
|
||||||
|
|
||||||
$make -s -f $WM_DIR/makefiles/files MAKE_DIR=$MakeDir \
|
$make -s -f "$WM_DIR/makefiles/files" MAKE_DIR="$MakeDir" \
|
||||||
OBJECTS_DIR=$objectsDir
|
OBJECTS_DIR="$objectsDir"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -421,7 +419,7 @@ fi
|
|||||||
# Check the $objectsDir/sourceFiles file was created successfully
|
# Check the $objectsDir/sourceFiles file was created successfully
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
[ -r $objectsDir/sourceFiles ] || {
|
[ -r "$objectsDir/sourceFiles" ] || {
|
||||||
echo "$Script error: file '$objectsDir/sourceFiles'" \
|
echo "$Script error: file '$objectsDir/sourceFiles'" \
|
||||||
"could not be created in $PWD" 1>&2
|
"could not be created in $PWD" 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -438,8 +436,8 @@ case "$targetType" in
|
|||||||
# ... but only if 'LIB' is declared in 'Make/files'
|
# ... but only if 'LIB' is declared in 'Make/files'
|
||||||
if grep -e '^ *LIB *=' "$MakeDir/files" >/dev/null 2>&1
|
if grep -e '^ *LIB *=' "$MakeDir/files" >/dev/null 2>&1
|
||||||
then
|
then
|
||||||
$make -s -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
|
$make -s -f "$WM_DIR/makefiles/general" MAKE_DIR="$MakeDir" \
|
||||||
OBJECTS_DIR=$objectsDir lnInclude
|
OBJECTS_DIR="$objectsDir" lnInclude
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -452,8 +450,8 @@ esac
|
|||||||
if [ -n "$WM_UPDATE_DEPENDENCIES" ]
|
if [ -n "$WM_UPDATE_DEPENDENCIES" ]
|
||||||
then
|
then
|
||||||
|
|
||||||
$make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
|
$make -f "$WM_DIR"/makefiles/general MAKE_DIR="$MakeDir" \
|
||||||
OBJECTS_DIR=$objectsDir dep
|
OBJECTS_DIR="$objectsDir" dep
|
||||||
makeExitCode=$?
|
makeExitCode=$?
|
||||||
|
|
||||||
if [ $makeExitCode -ne 0 ]
|
if [ $makeExitCode -ne 0 ]
|
||||||
@ -469,8 +467,9 @@ fi
|
|||||||
# Make the dependency files or object files and link
|
# Make the dependency files or object files and link
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
exec $make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \
|
# shellcheck disable=SC2093,SC2086
|
||||||
OBJECTS_DIR=$objectsDir $targetType
|
exec $make -f "$WM_DIR/makefiles/general" MAKE_DIR="$MakeDir" \
|
||||||
|
OBJECTS_DIR="$objectsDir" $targetType
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -104,7 +104,7 @@ dirName="$1"
|
|||||||
|
|
||||||
# Use /bin/pwd to get the absolute path (could be linked)
|
# Use /bin/pwd to get the absolute path (could be linked)
|
||||||
thisDir=$(/bin/pwd)
|
thisDir=$(/bin/pwd)
|
||||||
target=$(cd $dirName 2>/dev/null && /bin/pwd)
|
target=$(cd "$dirName" 2>/dev/null && /bin/pwd)
|
||||||
|
|
||||||
# Return 0 if this directory is <dir>
|
# Return 0 if this directory is <dir>
|
||||||
[ "$thisDir" = "$target" ] && exit 0
|
[ "$thisDir" = "$target" ] && exit 0
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -98,12 +98,12 @@ fi
|
|||||||
|
|
||||||
[ -e Make/files ] || {
|
[ -e Make/files ] || {
|
||||||
echo "$Script: Creating Make/files"
|
echo "$Script: Creating Make/files"
|
||||||
$WM_DIR/scripts/makeFiles
|
"$WM_DIR/scripts/makeFiles"
|
||||||
}
|
}
|
||||||
|
|
||||||
[ -e Make/options ] || {
|
[ -e Make/options ] || {
|
||||||
echo "$Script: Creating Make/options"
|
echo "$Script: Creating Make/options"
|
||||||
$WM_DIR/scripts/makeOptions
|
"$WM_DIR/scripts/makeOptions"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -70,9 +70,6 @@ error() {
|
|||||||
# Parse arguments and options
|
# Parse arguments and options
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Default 'find' option
|
|
||||||
unset findOpt
|
|
||||||
|
|
||||||
# Default 'ln' option
|
# Default 'ln' option
|
||||||
lnOpt="-s"
|
lnOpt="-s"
|
||||||
|
|
||||||
@ -141,7 +138,7 @@ fi
|
|||||||
|
|
||||||
cd $incDir || exit 1
|
cd $incDir || exit 1
|
||||||
|
|
||||||
if [ "$silentOpt" = true -o -n "$WM_QUIET" ]
|
if [ "$silentOpt" = true ] || [ -n "$WM_QUIET" ]
|
||||||
then
|
then
|
||||||
echo " ln: $incDir" 1>&2
|
echo " ln: $incDir" 1>&2
|
||||||
else
|
else
|
||||||
@ -152,14 +149,14 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Remove any broken links first (this helps when file locations have moved)
|
# Remove any broken links first (this helps when file locations have moved)
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
find -L . -type l | xargs rm -f
|
find -L . -type l -print0 | xargs -0 rm -f
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Create links, avoid recreating links unless necessary
|
# Create links, avoid recreating links unless necessary
|
||||||
# things placed in the 'noLink' directory are skipped
|
# things placed in the 'noLink' directory are skipped
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
find .. $findOpt \
|
find .. \
|
||||||
\( -name lnInclude -o -name Make -o -name config -o -name noLink \) \
|
\( -name lnInclude -o -name Make -o -name config -o -name noLink \) \
|
||||||
-prune \
|
-prune \
|
||||||
-o \( \
|
-o \( \
|
||||||
|
|||||||
@ -62,7 +62,6 @@ error() {
|
|||||||
# Parse arguments and options
|
# Parse arguments and options
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
findName=lnInclude
|
|
||||||
nCores=0
|
nCores=0
|
||||||
|
|
||||||
# Default 'wmakeLnInclude' option
|
# Default 'wmakeLnInclude' option
|
||||||
@ -87,7 +86,7 @@ do
|
|||||||
# Parallel execution on WM_NCOMPPROCS cores
|
# Parallel execution on WM_NCOMPPROCS cores
|
||||||
-j)
|
-j)
|
||||||
nCores=$WM_NCOMPPROCS
|
nCores=$WM_NCOMPPROCS
|
||||||
test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \
|
test $# -ge 2 && (($2 + 1)) > /dev/null 2>&1 \
|
||||||
&& shift && nCores=$1
|
&& shift && nCores=$1
|
||||||
;;
|
;;
|
||||||
# Parallel compilation on specified number of cores
|
# Parallel compilation on specified number of cores
|
||||||
@ -115,8 +114,10 @@ then
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
LIB_SRC="$WM_PROJECT_DIR/src"
|
LIB_SRC="$WM_PROJECT_DIR/src"
|
||||||
|
|
||||||
|
# shellcheck disable=SC2016
|
||||||
includeDirs="
|
includeDirs="
|
||||||
$WM_PROJECT_DIR/src/$WM_PROJECT
|
$WM_PROJECT_DIR/src/$WM_PROJECT
|
||||||
$WM_PROJECT_DIR/src/OSspecific/$WM_OSTYPE
|
$WM_PROJECT_DIR/src/OSspecific/$WM_OSTYPE
|
||||||
@ -126,13 +127,13 @@ then
|
|||||||
printed=
|
printed=
|
||||||
for d in $includeDirs
|
for d in $includeDirs
|
||||||
do [ ! -d "$d" ]
|
do [ ! -d "$d" ]
|
||||||
path=$(eval echo $d)
|
path=$(eval echo "$d")
|
||||||
if [ ! -d $path/lnInclude ]
|
if [ ! -d "$path/lnInclude" ]
|
||||||
then
|
then
|
||||||
[ $printed ] || echo "$Script: running wmakeLnInclude on dependent libraries:"
|
[ $printed ] || echo "$Script: running wmakeLnInclude on dependent libraries:"
|
||||||
printed=true
|
printed=true
|
||||||
echo -n " "
|
echo -n " "
|
||||||
eval wmakeLnInclude $wmLnOpt $d
|
eval wmakeLnInclude $wmLnOpt "$d"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -140,8 +141,6 @@ then
|
|||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
FAIL=0
|
|
||||||
|
|
||||||
if [ "$nCores" -gt 0 ]
|
if [ "$nCores" -gt 0 ]
|
||||||
then
|
then
|
||||||
echo "$Script: starting wmakeLnInclude processes on $nCores cores"
|
echo "$Script: starting wmakeLnInclude processes on $nCores cores"
|
||||||
@ -154,7 +153,7 @@ else
|
|||||||
|
|
||||||
for checkDir
|
for checkDir
|
||||||
do
|
do
|
||||||
if [ -d $checkDir ]
|
if [ -d "$checkDir" ]
|
||||||
then
|
then
|
||||||
echo " searching $checkDir for 'Make' directories"
|
echo " searching $checkDir for 'Make' directories"
|
||||||
else
|
else
|
||||||
@ -162,7 +161,7 @@ else
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $checkDir -depth -type d -name Make -print | while read MakeDir
|
find "$checkDir" -depth -type d -name Make -print | while read -r MakeDir
|
||||||
do
|
do
|
||||||
topDir=${MakeDir%/Make} # trim /Make from the end
|
topDir=${MakeDir%/Make} # trim /Make from the end
|
||||||
if [ -d "$topDir" ]
|
if [ -d "$topDir" ]
|
||||||
@ -173,16 +172,18 @@ else
|
|||||||
# and more as the cores become free
|
# and more as the cores become free
|
||||||
if [ "$nCores" -gt 0 ]
|
if [ "$nCores" -gt 0 ]
|
||||||
then
|
then
|
||||||
|
# shellcheck disable=SC2207
|
||||||
joblist=($(jobs -p))
|
joblist=($(jobs -p))
|
||||||
while (( ${#joblist[*]} > $nCores ))
|
while (( ${#joblist[*]} > "$nCores" ))
|
||||||
do
|
do
|
||||||
# When the job limit is reached wait for a job to finish
|
# When the job limit is reached wait for a job to finish
|
||||||
wait -n
|
wait -n
|
||||||
|
# shellcheck disable=SC2207
|
||||||
joblist=($(jobs -p))
|
joblist=($(jobs -p))
|
||||||
done
|
done
|
||||||
wmakeLnInclude $wmLnOpt $topDir &
|
wmakeLnInclude $wmLnOpt "$topDir" &
|
||||||
else
|
else
|
||||||
wmakeLnInclude $wmLnOpt $topDir
|
wmakeLnInclude $wmLnOpt "$topDir"
|
||||||
fi
|
fi
|
||||||
elif [ -d "$topDir/lnInclude" ]
|
elif [ -d "$topDir/lnInclude" ]
|
||||||
then
|
then
|
||||||
@ -204,7 +205,7 @@ else
|
|||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unset FAIL joblist
|
unset joblist
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -212,7 +213,7 @@ fi
|
|||||||
# Cleanup local variables and functions
|
# Cleanup local variables and functions
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
unset Script usage error findName nCores wmLnOpt depOpt
|
unset Script usage error nCores wmLnOpt depOpt
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -78,7 +78,7 @@ do
|
|||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-major)
|
-major)
|
||||||
echo ${WM_PROJECT_VERSION:-unknown}
|
echo "${WM_PROJECT_VERSION:-unknown}"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-u | -update)
|
-u | -update)
|
||||||
@ -119,10 +119,10 @@ build="$WM_PROJECT_DIR/.build"
|
|||||||
unset oldPackage oldVersion
|
unset oldPackage oldVersion
|
||||||
getOldValues()
|
getOldValues()
|
||||||
{
|
{
|
||||||
set -- $(tail -1 $build 2>/dev/null)
|
set -- "$(tail -1 "$build" 2>/dev/null)"
|
||||||
oldVersion="$1"
|
oldVersion="$1"
|
||||||
[ "$#" -gt 0 ] && shift
|
[ "$#" -gt 0 ] && shift
|
||||||
oldPackage="$@"
|
oldPackage="$*"
|
||||||
[ "${oldPackage:-none}" = none ] && unset oldPackage
|
[ "${oldPackage:-none}" = none ] && unset oldPackage
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ else
|
|||||||
# if there are multiple values (eg, HEAD, origin/HEAD, ...)
|
# if there are multiple values (eg, HEAD, origin/HEAD, ...)
|
||||||
# only take the first one, which is 'HEAD'
|
# only take the first one, which is 'HEAD'
|
||||||
version=$(
|
version=$(
|
||||||
cd $WM_PROJECT_DIR 2>/dev/null && \
|
cd "$WM_PROJECT_DIR" 2>/dev/null && \
|
||||||
git show-ref --hash=12 --head HEAD 2>/dev/null | head -1
|
git show-ref --hash=12 --head HEAD 2>/dev/null | head -1
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -181,11 +181,11 @@ fi
|
|||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Update persistent build tag if possible
|
# Update persistent build tag if possible
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
if [ $rc -eq 0 -a -n "$update" ]
|
if [ $rc -eq 0 ] && [ -n "$update" ]
|
||||||
then
|
then
|
||||||
if [ "$version:$package" != "$oldVersion:$oldPackage" ]
|
if [ "$version:$package" != "$oldVersion:$oldPackage" ]
|
||||||
then
|
then
|
||||||
if [ -w "$build" -o \( -w "$WM_PROJECT_DIR" -a ! -e "$build" \) ]
|
if [ -w "$build" ] || { [ -w "$WM_PROJECT_DIR" ] && [ ! -e "$build" ]; }
|
||||||
then
|
then
|
||||||
printTag >| "$build" 2>/dev/null
|
printTag >| "$build" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -51,24 +51,24 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# csh sets HOST, bash sets HOSTNAME
|
# csh sets HOST, bash sets HOSTNAME
|
||||||
: ${HOST:=$HOSTNAME}
|
: "${HOST:=$HOSTNAME}"
|
||||||
|
|
||||||
lockDir=$HOME/.$WM_PROJECT/.wmake
|
lockDir=$HOME/.$WM_PROJECT/.wmake
|
||||||
|
|
||||||
# Fallback - 1 core on current host
|
# Fallback - 1 core on current host
|
||||||
: ${WM_HOSTS:=$HOST:1}
|
: "${WM_HOSTS:=$HOST:1}"
|
||||||
|
|
||||||
# Count the total number of slots available and exit
|
# Count the total number of slots available and exit
|
||||||
if [ "$1" = "-count" ]
|
if [ "$1" = "-count" ]
|
||||||
then
|
then
|
||||||
expr $(
|
(( $(
|
||||||
for slotGroup in $WM_HOSTS
|
for slotGroup in $WM_HOSTS
|
||||||
do
|
do
|
||||||
n=${slotGroup##*:}
|
n=${slotGroup##*:}
|
||||||
[ "$n" = "${slotGroup%%:*}" ] && n=1 # missing ':'
|
[ "$n" = "${slotGroup%%:*}" ] && n=1 # missing ':'
|
||||||
echo "+ ${n:-1}"
|
echo "+ ${n:-1}"
|
||||||
done
|
done
|
||||||
)
|
) ))
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ case $sourceFoam in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Quote double-quotes for remote command line
|
# Quote double-quotes for remote command line
|
||||||
rcmd=$(echo $* | sed -e s/\"/\'\"\'/g)
|
rcmd=${*//\"/\'\"\'}
|
||||||
# The same, without forking (not ksh, maybe not /bin/sh either)
|
# The same, without forking (not ksh, maybe not /bin/sh either)
|
||||||
# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
|
# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ nColours=0
|
|||||||
for col in $WM_COLOURS
|
for col in $WM_COLOURS
|
||||||
do
|
do
|
||||||
colourList[$nColours]=$col
|
colourList[$nColours]=$col
|
||||||
((nColours = $nColours + 1))
|
((nColours = nColours + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Bashism: make pipe fail early.
|
# Bashism: make pipe fail early.
|
||||||
@ -156,9 +156,9 @@ colourPipe()
|
|||||||
if tty -s <&1 # [ "$1" ]
|
if tty -s <&1 # [ "$1" ]
|
||||||
then
|
then
|
||||||
(
|
(
|
||||||
while read line
|
while read -r line
|
||||||
do
|
do
|
||||||
setterm -foreground $1
|
setterm -foreground "$1"
|
||||||
echo "$line"
|
echo "$line"
|
||||||
done
|
done
|
||||||
setterm -foreground default
|
setterm -foreground default
|
||||||
@ -200,17 +200,17 @@ do
|
|||||||
colour="${colourList[$colourIndex]}"
|
colour="${colourList[$colourIndex]}"
|
||||||
|
|
||||||
if [ "$host" = "$HOST" ]; then
|
if [ "$host" = "$HOST" ]; then
|
||||||
eval $* 2>&1 | colourPipe "$colour"
|
eval "$*" 2>&1 | colourPipe "$colour"
|
||||||
else
|
else
|
||||||
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" \
|
ssh "$host" "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" \
|
||||||
2>&1 | colourPipe "$colour"
|
2>&1 | colourPipe "$colour"
|
||||||
fi
|
fi
|
||||||
retval=$?
|
retval=$?
|
||||||
else
|
else
|
||||||
if [ "$host" = "$HOST" ]; then
|
if [ "$host" = "$HOST" ]; then
|
||||||
eval $* 2>&1
|
eval "$*" 2>&1
|
||||||
else
|
else
|
||||||
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" \
|
ssh "$host" "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" \
|
||||||
2>&1
|
2>&1
|
||||||
fi
|
fi
|
||||||
retval=$?
|
retval=$?
|
||||||
@ -220,10 +220,10 @@ do
|
|||||||
rm -f "$lockFile" 2>/dev/null
|
rm -f "$lockFile" 2>/dev/null
|
||||||
exit $retval
|
exit $retval
|
||||||
fi
|
fi
|
||||||
i=$(expr $i + 1)
|
i=$((i + 1))
|
||||||
|
|
||||||
# Cycle through colours. Note: outside lock clause!
|
# Cycle through colours. Note: outside lock clause!
|
||||||
colourIndex=$(expr $colourIndex + 1)
|
colourIndex=$((colourIndex + 1))
|
||||||
[ "$colourIndex" -lt "$nColours" ] || colourIndex=0
|
[ "$colourIndex" -lt "$nColours" ] || colourIndex=0
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
# ========= |
|
# ========= |
|
||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||||
# \\/ M anipulation |
|
# \\/ M anipulation |
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
@ -67,23 +67,22 @@ error() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# csh sets HOST, bash sets HOSTNAME
|
# csh sets HOST, bash sets HOSTNAME
|
||||||
: ${HOST:=$HOSTNAME}
|
: "${HOST:=$HOSTNAME}"
|
||||||
|
|
||||||
lockDir=$HOME/.$WM_PROJECT/.wmake
|
|
||||||
# Fallback - 1 core on current host
|
# Fallback - 1 core on current host
|
||||||
: ${WM_HOSTS:=$HOST:1}
|
: "${WM_HOSTS:=$HOST:1}"
|
||||||
|
|
||||||
# Count the total number of slots available and exit
|
# Count the total number of slots available and exit
|
||||||
if [ "$1" = "-count" ]
|
if [ "$1" = "-count" ]
|
||||||
then
|
then
|
||||||
expr $(
|
(( $(
|
||||||
for slotGroup in $WM_HOSTS
|
for slotGroup in $WM_HOSTS
|
||||||
do
|
do
|
||||||
n=${slotGroup##*:}
|
n=${slotGroup##*:}
|
||||||
[ "$n" = "${slotGroup%%:*}" ] && n=1 # Missing ':'
|
[ "$n" = "${slotGroup%%:*}" ] && n=1 # Missing ':'
|
||||||
echo "+ ${n:-1}"
|
echo "+ ${n:-1}"
|
||||||
done
|
done
|
||||||
)
|
) ))
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -142,7 +141,7 @@ case $sourceFoam in
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Quote double-quotes for remote command line
|
# Quote double-quotes for remote command line
|
||||||
rcmd=$(echo $* | sed -e s/\"/\'\"\'/g)
|
rcmd=${*//\"/\'\"\'}
|
||||||
# The same, without forking (not ksh, maybe not /bin/sh either)
|
# The same, without forking (not ksh, maybe not /bin/sh either)
|
||||||
# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
|
# rcmd=$(while [ "$#" -gt 0 ]; do echo "${1//\"/'\"'}"; shift; done)
|
||||||
|
|
||||||
@ -153,7 +152,7 @@ nColours=0
|
|||||||
for col in $WM_COLOURS
|
for col in $WM_COLOURS
|
||||||
do
|
do
|
||||||
colourList[$nColours]=$col
|
colourList[$nColours]=$col
|
||||||
((nColours = $nColours + 1))
|
((nColours = nColours + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
# Bashism: make pipe fail early.
|
# Bashism: make pipe fail early.
|
||||||
@ -170,9 +169,9 @@ colourPipe()
|
|||||||
if [ "$1" ]
|
if [ "$1" ]
|
||||||
then
|
then
|
||||||
(
|
(
|
||||||
while read line
|
while read -r line
|
||||||
do
|
do
|
||||||
setterm -foreground $1
|
setterm -foreground "$1"
|
||||||
echo "$line"
|
echo "$line"
|
||||||
done
|
done
|
||||||
setterm -foreground default
|
setterm -foreground default
|
||||||
@ -222,11 +221,11 @@ do
|
|||||||
|
|
||||||
# Determine load
|
# Determine load
|
||||||
if [ "$host" = "$HOST" ]; then
|
if [ "$host" = "$HOST" ]; then
|
||||||
stat=`uptime`
|
stat=$(uptime)
|
||||||
else
|
else
|
||||||
stat=`ssh $host uptime`
|
stat=$(ssh "$host" uptime)
|
||||||
fi
|
fi
|
||||||
load=`echo "$stat" | sed -e 's/.*average:[^0-9.]*\([0-9.]*\).*/\1/'`
|
load=$(echo "$stat" | sed -e 's/.*average:[^0-9.]*\([0-9.]*\).*/\1/')
|
||||||
|
|
||||||
|
|
||||||
#echo "$Script: Machine:$host load:$load allowed:$WM_NCOMPPROCS nprocs:$nprocs"
|
#echo "$Script: Machine:$host load:$load allowed:$WM_NCOMPPROCS nprocs:$nprocs"
|
||||||
@ -242,18 +241,18 @@ do
|
|||||||
echo "$Script: Machine:$host Starting:$*"
|
echo "$Script: Machine:$host Starting:$*"
|
||||||
|
|
||||||
if [ "$host" = "$HOST" ]; then
|
if [ "$host" = "$HOST" ]; then
|
||||||
eval $* 2>&1 | colourPipe "$colour"
|
eval "$*" 2>&1 | colourPipe "$colour"
|
||||||
else
|
else
|
||||||
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 \
|
ssh "$host" "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1 \
|
||||||
| colourPipe "$colour"
|
| colourPipe "$colour"
|
||||||
fi
|
fi
|
||||||
retval=$?
|
retval=$?
|
||||||
else
|
else
|
||||||
echo "$Script: Machine:$host Starting:$*"
|
echo "$Script: Machine:$host Starting:$*"
|
||||||
if [ "$host" = "$HOST" ]; then
|
if [ "$host" = "$HOST" ]; then
|
||||||
eval $* 2>&1
|
eval "$*" 2>&1
|
||||||
else
|
else
|
||||||
ssh $host "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1
|
ssh "$host" "$sourceFoam 2>/dev/null; cd $PWD && $rcmd" 2>&1
|
||||||
fi
|
fi
|
||||||
retval=$?
|
retval=$?
|
||||||
fi
|
fi
|
||||||
@ -262,7 +261,7 @@ do
|
|||||||
|
|
||||||
|
|
||||||
# Cycle through colours. Note: outside lock clause!
|
# Cycle through colours. Note: outside lock clause!
|
||||||
colourIndex=$(expr $colourIndex + 1)
|
colourIndex=$((colourIndex + 1))
|
||||||
[ "$colourIndex" -lt "$nColours" ] || colourIndex=0
|
[ "$colourIndex" -lt "$nColours" ] || colourIndex=0
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
35
wmake/wrmdep
35
wmake/wrmdep
@ -54,6 +54,7 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source the wmake functions
|
||||||
|
# shellcheck source=scripts/wmakeFunctions
|
||||||
. ${0%/*}/scripts/wmakeFunctions
|
. ${0%/*}/scripts/wmakeFunctions
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@ -146,16 +147,16 @@ files)
|
|||||||
# With the -a/-all option replace the current platform with a wildcard
|
# With the -a/-all option replace the current platform with a wildcard
|
||||||
if [ "$all" = "all" ]
|
if [ "$all" = "all" ]
|
||||||
then
|
then
|
||||||
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% )
|
objectsDir=$(echo "$objectsDir" | sed s%"$WM_OPTIONS"%*% )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "removing all .dep files ..."
|
echo "removing all .dep files ..."
|
||||||
find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null
|
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" '{}' \; \
|
find "$objectsDir" -name '*.dep' -exec grep -q "$1" '{}' \; \
|
||||||
-exec rm '{}' \; -print
|
-exec rm '{}' \; -print
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -170,9 +171,9 @@ oldFolders)
|
|||||||
|
|
||||||
for checkDir
|
for checkDir
|
||||||
do
|
do
|
||||||
findObjectDir $checkDir
|
findObjectDir "$checkDir"
|
||||||
|
|
||||||
if [ -d $objectsDir ]
|
if [ -d "$objectsDir" ]
|
||||||
then
|
then
|
||||||
echo " searching: $objectsDir"
|
echo " searching: $objectsDir"
|
||||||
else
|
else
|
||||||
@ -180,15 +181,15 @@ oldFolders)
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $objectsDir -name '*.dep' -print | while read depFile
|
find "$objectsDir" -name '*.dep' -print | while read -r depFile
|
||||||
do
|
do
|
||||||
depToSource $depFile
|
depToSource "$depFile"
|
||||||
|
|
||||||
# Check C++ or Flex source file exists
|
# Check C++ or Flex source file exists
|
||||||
if [ ! -r "$sourceFile" ];
|
if [ ! -r "$sourceFile" ];
|
||||||
then
|
then
|
||||||
echo " rm $depFile"
|
echo " rm $depFile"
|
||||||
rm -f $depFile 2>/dev/null
|
rm -f "$depFile" 2>/dev/null
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
@ -208,19 +209,19 @@ updateMode)
|
|||||||
|
|
||||||
for filePathAndName in $fileNameList
|
for filePathAndName in $fileNameList
|
||||||
do
|
do
|
||||||
fileName=$(basename $filePathAndName)
|
fileName=$(basename "$filePathAndName")
|
||||||
echo " 'src': $fileName"
|
echo " 'src': $fileName"
|
||||||
cd src
|
(
|
||||||
$Script -a $fileName
|
cd src || exit
|
||||||
|
$Script -a "$fileName"
|
||||||
|
|
||||||
echo " 'applications': $fileName"
|
echo " 'applications': $fileName"
|
||||||
cd ../applications
|
cd ../applications || exit
|
||||||
$Script -a $fileName
|
$Script -a "$fileName"
|
||||||
|
)
|
||||||
cd ..
|
|
||||||
|
|
||||||
# Just in case, remove the symbolic link as the last step
|
# Just in case, remove the symbolic link as the last step
|
||||||
unlink $filePathAndName
|
unlink "$filePathAndName"
|
||||||
done
|
done
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|||||||
@ -38,6 +38,7 @@
|
|||||||
Script=${0##*/}
|
Script=${0##*/}
|
||||||
|
|
||||||
# Source the wmake functions
|
# Source the wmake functions
|
||||||
|
# shellcheck source=scripts/wmakeFunctions
|
||||||
. ${0%/*}/scripts/wmakeFunctions
|
. ${0%/*}/scripts/wmakeFunctions
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
@ -100,16 +101,16 @@ findObjectDir .
|
|||||||
# With the -a/-all option replace the current platform with a wildcard
|
# With the -a/-all option replace the current platform with a wildcard
|
||||||
if [ "$all" = "all" ]
|
if [ "$all" = "all" ]
|
||||||
then
|
then
|
||||||
objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% )
|
objectsDir=$(echo "$objectsDir" | sed s%"$WM_OPTIONS"%*% )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$#" -eq 0 ]
|
if [ "$#" -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "removing all .o files ..."
|
echo "removing all .o files ..."
|
||||||
find $objectsDir -name '*.o' -print | xargs -t rm 2>/dev/null
|
find "$objectsDir" -name '*.o' -print0 | xargs -0t rm 2>/dev/null
|
||||||
else
|
else
|
||||||
echo "removing .o files corresponding to $1 ..."
|
echo "removing .o files corresponding to $1 ..."
|
||||||
rm $objectsDir/${1%%.*}.o
|
rm "$objectsDir/${1%%.*}.o"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user