From 418cc9b2686c29b12e53c39b1e105d03317cdee1 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Sun, 22 Jul 2018 18:28:29 +0200 Subject: [PATCH] STYLE: minor adjustments in wmake scripts. - comments - avoid egrep for getting processor count. - wcleanBuild, wcleanPlatform with shorter form '-curr' instead of '-c' to avoid any potential user confusion with '-comp' --- wmake/scripts/{wcleanBuild => wcleanObjects} | 10 +++++----- wmake/wclean | 6 ++---- wmake/wcleanBuild | 2 +- wmake/wcleanPlatform | 2 +- wmake/wdep | 8 +++----- wmake/wmake | 21 +++++++------------- wmake/wmakeLnIncludeAll | 7 ++----- wmake/wmakePrintBuild | 4 +--- wmake/wrmdep | 6 ++---- wmake/wrmo | 6 ++---- 10 files changed, 26 insertions(+), 46 deletions(-) rename wmake/scripts/{wcleanBuild => wcleanObjects} (94%) diff --git a/wmake/scripts/wcleanBuild b/wmake/scripts/wcleanObjects similarity index 94% rename from wmake/scripts/wcleanBuild rename to wmake/scripts/wcleanObjects index b1651db0b1c..a99871ca0a2 100755 --- a/wmake/scripts/wcleanBuild +++ b/wmake/scripts/wcleanObjects @@ -3,7 +3,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------- # License @@ -11,14 +11,14 @@ # <http://www.gnu.org/licenses/>. # # Script -# wcleanBuild +# wcleanBuild, wcleanPlatform # # Usage # wcleanBuild <option | platform> [.. <option | platform>] # # Description # Deletes the specified 'build/' object files directories from the -# the project top-level 'build/' directory $WM_PROJECT_DIR. +# project top-level 'build/' directory $WM_PROJECT_DIR. # # special platforms # - 'all' removes all platforms. @@ -57,7 +57,7 @@ Usage: ${0##*/} <option | platform> [.. <option | platform>] options: -a, -all Same as 'all' - -c, -current Use \$WM_OPTIONS ($WM_OPTIONS) + -curr, -current Use \$WM_OPTIONS ($WM_OPTIONS) -comp, -compiler Use \$WM_ARCH\$WM_COMPILER* ($WM_ARCH$WM_COMPILER) -compiler=NAME Use \$WM_ARCH<NAME>* ($WM_ARCH<NAME>*) -h, -help Print the usage @@ -124,7 +124,7 @@ do echo break # Removed everything - can stop now ;; - -c | -current | current) + -curr | -current | current) name="$WM_OPTIONS" ;; -comp | -compiler | compiler) diff --git a/wmake/wclean b/wmake/wclean index 0a1e0bf696e..e583ea76891 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -34,10 +34,8 @@ # lnInclude directories generated for libraries. # #------------------------------------------------------------------------------ -Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions +Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions +. ${0%/*}/scripts/wmakeFunctions # Source wmake functions usage() { while [ "$#" -ge 1 ]; do echo "$1"; shift; done diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild index a0376ef9764..b0d19ae4ee3 120000 --- a/wmake/wcleanBuild +++ b/wmake/wcleanBuild @@ -1 +1 @@ -scripts/wcleanBuild \ No newline at end of file +scripts/wcleanObjects \ No newline at end of file diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform index a0376ef9764..b0d19ae4ee3 120000 --- a/wmake/wcleanPlatform +++ b/wmake/wcleanPlatform @@ -1 +1 @@ -scripts/wcleanBuild \ No newline at end of file +scripts/wcleanObjects \ No newline at end of file diff --git a/wmake/wdep b/wmake/wdep index 346494d7625..c9670d3b17a 100755 --- a/wmake/wdep +++ b/wmake/wdep @@ -35,10 +35,8 @@ # the first occurrence. # #------------------------------------------------------------------------------ -Script=${0##*/} - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions +Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions +. ${0%/*}/scripts/wmakeFunctions # Source wmake functions usage() { exec 1>&2 @@ -92,7 +90,7 @@ sourceFile=$1 if [ ! -e "$sourceFile" ] then - sourceFile=$(find . -name $sourceFile -print -quit) + sourceFile=$(find . -name "$sourceFile" -print -quit) if [ -z "$sourceFile" ] then echo "$Script: cannot find source file $1" 1>&2 diff --git a/wmake/wmake b/wmake/wmake index 85054ecd542..c462e95824e 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -53,10 +53,8 @@ # wclean, wcleanPlatform, wcleanLnIncludeAll # #------------------------------------------------------------------------------ -Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions +Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions +. ${0%/*}/scripts/wmakeFunctions # Source wmake functions usage() { exec 1>&2 @@ -106,13 +104,11 @@ make="make" #------------------------------------------------------------------------------ -# Set nCores to the number of cores on the local machine +# Set nCores to the number of cores on the machine nCores=0 allCores() { - nCores=$(egrep -c "^processor" /proc/cpuinfo 2>/dev/null) || \ - nCores=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \ - nCores=1 + nCores=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || nCores=1 : ${nCores:=1} } @@ -132,7 +128,7 @@ do usage ;; -s | -silent) - export WM_QUIET=1 + export WM_QUIET=true ;; -a | -all | all) all=all @@ -146,10 +142,7 @@ do test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \ && shift && nCores=$1 - if [ "$nCores" = 0 ] - then - allCores - fi + [ "$nCores" = 0 ] && allCores export WM_NCOMPPROCS=$nCores echo "Compiling enabled on $WM_NCOMPPROCS cores" ;; diff --git a/wmake/wmakeLnIncludeAll b/wmake/wmakeLnIncludeAll index 369f2d10be8..bfb4fe3d485 100755 --- a/wmake/wmakeLnIncludeAll +++ b/wmake/wmakeLnIncludeAll @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | +# \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -79,10 +79,7 @@ do test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \ && shift && nCores=$1 - if [ "$nCores" = 0 ] - then - nCores=1 - fi + [ "$nCores" = 0 ] && nCores=1 ;; # Parallel compilation on specified number of cores -j[1-9]*) diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 4e727a74384..c6b21dbaabd 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -17,14 +17,12 @@ # Print the version used when building the project # #------------------------------------------------------------------------------ -Script=${0##*/} - usage() { exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<<USAGE -Usage: $Script [OPTION] +Usage: ${0##*/} [OPTION] options: -check check the git head commit vs. \$WM_PROJECT_DIR/.build (exit code 0 for no changes) diff --git a/wmake/wrmdep b/wmake/wrmdep index 119aecc86d2..692f20fd0d9 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -52,10 +52,8 @@ # $WM_PROJECT_DIR. # #------------------------------------------------------------------------------ -Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions +Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions +. ${0%/*}/scripts/wmakeFunctions # Source wmake functions usage() { exec 1>&2 diff --git a/wmake/wrmo b/wmake/wrmo index 517cdee9253..71d2b4ca71a 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -35,10 +35,8 @@ # are removed for all platforms rather than just the current platform. # #------------------------------------------------------------------------------ -Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions +Script=${0##*/} # Use 'Script' for error messages in wmakeFunctions +. ${0%/*}/scripts/wmakeFunctions # Source wmake functions usage() { exec 1>&2 -- GitLab