From 6343e1e3b3a3f457d196c70d6deeeacd2f587a64 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Feb 2017 10:33:50 +0100 Subject: [PATCH 01/18] ENH: have wmake and wclean do something sensible with a filename as target - For convenience, let "wmake some/path/filename.C" behave similar to "wmake some/path" and trace back for the Make directory. --- wmake/wclean | 5 ++++- wmake/wmake | 8 ++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/wmake/wclean b/wmake/wclean index e2f6a3142c..de9bd6c58d 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -100,10 +100,13 @@ MakeDir=Make if [ $# -ge 1 ] then - if [ -d "$1" ] then dir=$1 + elif [ -f "$1" ] + then + dir="${1%/*}" + : ${dir:=.} else targetType=$1 fi diff --git a/wmake/wmake b/wmake/wmake index 38f3d3ff6e..1c3ad99fa6 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 | +# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -250,7 +250,11 @@ if [ $# -ge 1 ] then if [ -d "$1" ] then - dir=$1 + dir="$1" + elif [ -f "$1" ] + then + dir="${1%/*}" + : ${dir:=.} else targetType=$1 fi From 46ecad8f7ad6393873a2f2b2a6ec9397401aea22 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Feb 2017 11:38:12 +0100 Subject: [PATCH 02/18] STYLE: make wmake scripts look more POSIX-like - also add some comments about the side-effects --- bin/foamUpdateCaseFileHeader | 10 +-- wmake/scripts/wmakeFunctions | 73 ++++++++++++++++-- wmake/wclean | 29 +++---- wmake/wcleanLnIncludeAll | 43 +++-------- wmake/wcleanPlatform | 25 ++----- wmake/wdep | 27 +++---- wmake/wmake | 141 +++++++++++++++-------------------- wmake/wmakeCheckPwd | 11 +-- wmake/wmakeCollect | 40 ++++------ wmake/wmakeFilesAndOptions | 9 +-- wmake/wmakeLnInclude | 10 +-- wmake/wmakeLnIncludeAll | 23 ++---- wmake/wmakeScheduler | 8 +- wmake/wmakeSchedulerUptime | 8 +- wmake/wrmdep | 114 +++++++++++++--------------- wmake/wrmo | 44 +++++------ 16 files changed, 276 insertions(+), 339 deletions(-) diff --git a/bin/foamUpdateCaseFileHeader b/bin/foamUpdateCaseFileHeader index a905107653..37d4e6d498 100755 --- a/bin/foamUpdateCaseFileHeader +++ b/bin/foamUpdateCaseFileHeader @@ -28,8 +28,8 @@ # Description # Updates the header of application files. # By default, writes current version in the header. -# Alternatively version can be specified with -v option. -# Also removes consecutive blank lines from file. +# The version can alternatively be specified with the -v option. +# Also removes consecutive blank lines from the file. # #------------------------------------------------------------------------------ usage() { @@ -66,7 +66,7 @@ do shift 2 ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -118,7 +118,7 @@ FoamFileAttribute() tmpFile=FoamFile.tmp$$ for caseFile do - if grep FoamFile $caseFile >/dev/null 2>&1 + if grep -q FoamFile $caseFile 2>/dev/null then echo "Updating case file: $caseFile" sed -n '/FoamFile/,/}/p' $caseFile > $tmpFile @@ -137,7 +137,7 @@ do [ -s $tmpFile ] && cat $tmpFile >| $caseFile rm -f $tmpFile 2>/dev/null else - echo " Invalid case file: $caseFile" 1>&2 + echo "Invalid case file: $caseFile" 1>&2 fi done diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions index 7a12ad0545..4ed0b7b0f3 100644 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -48,6 +48,12 @@ checkEnv() # Search up directories tree for the Make sub-directory #------------------------------------------------------------------------------ +# Return the absolute path for a directory or a file's parent directory +# expandPath dirName +# expandPath fileName +# +# Sets: +# - exPath expandPath() { if [ -d "$1" ] @@ -58,6 +64,19 @@ expandPath() fi } +# Find the target directory +# findTarget dirName +# findTarget fileName +# +# Sets: +# - dir +# +# Side-effect variables: +# - sets exPath +# - sets wmpdir +# +# Global variables used: +# - WM_PROJECT_DIR, HOME findTarget() { expandPath $WM_PROJECT_DIR @@ -65,28 +84,38 @@ findTarget() expandPath $1 if [ "$exPath" = "$wmpdir" \ - -o "$exPath" = "$HOME" \ - -o "$exPath" = "/" \ - ] + -o "$exPath" = "$HOME" \ + -o "$exPath" = "/" \ + ] then echo "$Script error: could not find Make directory" 1>&2 exit 1 - elif [ -d "$1/Make" ]; then + elif [ -d "$1/Make" ] + then dir=$1 else findTarget "$1/.." fi } +# Change to 'MakeDir' +# - 'MakeDir' for its input +# +# Sets: +# - dir +# +# Side-effect variables: +# - sets exPath +# - unsets targetType cdSource() { if [ ! -d $MakeDir ] then echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2 - echo " Searching up directories tree for Make directory" + echo " Searching up directories tree for Make directory" 1>&2 + unset targetType findTarget . - targetType= if [ "$dir" ] then @@ -97,13 +126,30 @@ cdSource() fi fi - [ -r $MakeDir/files ] || { echo "$Script error: file '$MakeDir/files' does not exist in $PWD" 1>&2 exit 1 } } + +# Find the object directory +# findObjectDir dirName +# findObjectDir fileName +# +# Sets: +# - dir +# - path +# - appDir +# - objectsDir +# +# Side-effect variables: +# - sets exPath +# - sets wmpdir +# - set platformPath +# +# Global variables used: +# - WM_PROJECT_DIR, WM_OPTIONS findObjectDir() { expandPath $WM_PROJECT_DIR @@ -127,7 +173,18 @@ findObjectDir() fi } -if [ -n "$BASH_VERSION" ]; then + +# depToSource +# - uses 'depFile' for its input +# +# Sets: +# - sourceFile +# +# Global variables used: +# - WM_OPTIONS +# - WM_MPLIB +if [ -n "$BASH_VERSION" ] +then depToSource() { sourceFile=${depFile%.dep} diff --git a/wmake/wclean b/wmake/wclean index de9bd6c58d..42209bc2bb 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -34,7 +34,7 @@ # lnInclude directories generated for libraries. # #------------------------------------------------------------------------------ -Script=${0##*/} +Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions @@ -82,7 +82,7 @@ do shift ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -117,7 +117,7 @@ then # Specified alternative name for the Make sub-directory: [ $# -ge 3 ] && MakeDir=$3 - if [ "$dir" ] + if [ -n "$dir" ] then cd $dir 2>/dev/null || { echo "$Script error: could not change to directory '$dir'" 1>&2 @@ -126,8 +126,7 @@ then fi # Print command - [ -z "$targetType" ] || targetSpace=" " - echo "$Script $targetType$targetSpace${dir:-.}" + echo "$Script $targetType${targetType:+ }${dir:-.}" fi @@ -147,7 +146,6 @@ fi if [ "$targetType" = empty ] then # First pass: clean up empty source code directories - echo "Removing empty directories..." # Get sub-directories avoiding particular directories @@ -259,8 +257,8 @@ then objectsDir=$MakeDir/$WM_OPTIONS if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] then - platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$platformPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) + buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) fi rm -rf $objectsDir 2>/dev/null fi @@ -270,17 +268,8 @@ fi # Remove the lnInclude directory if present #------------------------------------------------------------------------------ -if [ -d lnInclude ] -then - rm -rf lnInclude 2>/dev/null -fi - - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage MakeDir +[ -d lnInclude ] && rm -rf lnInclude 2>/dev/null +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll index 2a4a434485..4ac19b6816 100755 --- a/wmake/wcleanLnIncludeAll +++ b/wmake/wcleanLnIncludeAll @@ -26,46 +26,29 @@ # wcleanLnIncludeAll # # Usage -# wcleanLnIncludeAll [dir1] .. [dirN] +# wcleanLnIncludeAll [dir1 [..dirN]] # # Description # Delete all the lnInclude directories in the tree. # -##------------------------------------------------------------------------------ -Script=${0##*/} - -# Source the wmake functions -. ${0%/*}/scripts/wmakeFunctions - -#------------------------------------------------------------------------------ -# Parse arguments and options #------------------------------------------------------------------------------ -# Default to the CWD if [ "$#" -eq 0 ] then - # Add the CWD to the arguments + # Default is to search the CWD set -- . elif [ "$1" = "-h" -o "$1" = "-help" ] then - echo "Usage: $Script [dir1] .. [dirN]" - echo - echo " Delete all the lnInclude directories in the tree" - echo + exec 1>&2 + cat<&2 + exit 1 +fi + # Check environment variables checkEnv +sourceFile=$1 #------------------------------------------------------------------------------ -# Check is is the current directory, +# Check is in the current directory, # otherwise search tree for first occurrance #------------------------------------------------------------------------------ -sourceFile=$1 - -if [ ! -e $1 ] +if [ ! -e "$sourceFile" ] then sourceFile=$(find . -name $sourceFile -print -quit) if [ -z "$sourceFile" ] @@ -95,24 +100,14 @@ then fi fi - #------------------------------------------------------------------------------ # Search up directories tree for the Make sub-directory containing dep files # and echo path for the dep file corresponding to the specified source file #------------------------------------------------------------------------------ findObjectDir $sourceFile +echo "$objectsDir/${sourceFile##*/}.dep" -fileName=${1##*/} - -echo $objectsDir/$fileName.dep - - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmake b/wmake/wmake index 1c3ad99fa6..e251b1e9f4 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -53,7 +53,7 @@ # wclean, wcleanPlatform, wcleanLnIncludeAll # #------------------------------------------------------------------------------ -Script=${0##*/} +Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions @@ -127,8 +127,7 @@ useAllCores() #------------------------------------------------------------------------------ # Default to compiling the local target only -all= -update= +unset all update while [ "$#" -gt 0 ] do @@ -141,10 +140,10 @@ do export WM_QUIET=1 ;; -a | -all | all) - all="all" + all=all ;; -q | -queue | queue) - all="queue" + all=queue ;; # Parallel compilation on all cores of local machine -j) @@ -154,13 +153,13 @@ do echo "Compiling enabled on $WM_NCOMPPROCS cores" ;; # Parallel compilation on specified number of cores - -j*) + -j[1-9]*) export WM_NCOMPPROCS=${1#-j} echo "Compiling enabled on $WM_NCOMPPROCS cores" ;; # Non-stop compilation, ignoring errors -k | -non-stop) - export WM_CONTINUE_ON_ERROR=1 + export WM_CONTINUE_ON_ERROR=true ;; # Disable scheduled parallel compilation -no-scheduler) @@ -173,15 +172,15 @@ do # - remove empty directories, along with deprecated object directories # and respective binaries. -update) - update="true" - [ -z "$all" ] && all="all" + update=true + : ${all:=all} # implies 'all', unless previous set to 'queue' etc. ;; --) shift break ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -200,10 +199,10 @@ checkEnv # When compiling anything but a standalone exe WM_PROJECT and WM_PROJECT_DIR # must be set [ "$1" = exe -o \( "$WM_PROJECT" -a "$WM_PROJECT_DIR" \) ] || { - echo "$Script error:" 1>&2 - echo " environment variable \$WM_PROJECT or " \ - "\$WM_PROJECT_DIR not set" 1>&2 - echo " while building project library" 1>&2 + exec 1>&2 + echo "$Script error:" + echo " environment variable \$WM_PROJECT or \$WM_PROJECT_DIR not set" + echo " while building project library" exit 1 } @@ -219,11 +218,11 @@ then [ $? -eq 0 ] || unset WM_NCOMPPROCS fi -if [ "$WM_NCOMPPROCS" ] +if [ -n "$WM_NCOMPPROCS" ] then parOpt="-j $WM_NCOMPPROCS" - if [ "$WM_NCOMPPROCS" -gt 1 -a ! "$MAKEFLAGS" ] + if [ "$WM_NCOMPPROCS" -gt 1 -a -z "$MAKEFLAGS" ] then lockDir=$HOME/.$WM_PROJECT/.wmake @@ -265,7 +264,7 @@ then # Specified alternative name for the Make sub-directory: [ $# -ge 3 ] && MakeDir=$3 - if [ "$dir" ] + if [ -n "$dir" ] then cd $dir 2>/dev/null || { echo "$Script error: could not change to directory '$dir'" 1>&2 @@ -274,16 +273,15 @@ then fi # Print command - [ -z "$targetType" ] || targetSpace=" " - echo "$Script $targetType$targetSpace${dir:-.}" + echo "$Script $targetType${targetType:+ }${dir:-.}" fi #------------------------------------------------------------------------------ -# Recurse the source tree to compile "all" targets +# Recurse the source tree to update all #------------------------------------------------------------------------------ -if [ -n "$update" ] +if [ "$update" = true ] then wrmdep -update wrmdep -old @@ -297,40 +295,37 @@ fi # Recurse the source tree to compile "all" targets #------------------------------------------------------------------------------ -if [ "$all" = "all" ] +if [ "$all" = all ] then if [ -e Allwmake ] then ./Allwmake -fromWmake $targetType exit $? + fi + + # Find all the sub-directories containing a 'Make' directory + # (xargs is just used to flatten the list) + FOAM_APPS=$( + for d in * + do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] && echo "$d" + done | xargs) + + if [ -n "$FOAM_APPS" ] + then + # Compile all applications in sub-directories + $make ${WM_CONTINUE_ON_ERROR:+-k} \ + -f $WM_DIR/makefiles/apps \ + TARGET="$targetType" FOAM_APPS="$FOAM_APPS" + makeExitCode=$? else - # Have to keep track of the main exit code for the call to "make" - makeExitCode=0 + makeExitCode=0 # For fall-through + fi - # Find all the sub-directories containing a 'Make' directory - FOAM_APPS=$(\ - for d in *; \ - do [ -d "$d" -a "$d" != Optional -a "$d" != Make ] \ - && echo "$d"; \ - done | xargs \ - ) - if [ ! "$FOAM_APPS" = "" ] - then - # Compile all applications in sub-directories - $make ${WM_CONTINUE_ON_ERROR:+-k} \ - -f $WM_DIR/makefiles/apps \ - TARGET="$targetType" FOAM_APPS="$FOAM_APPS" - makeExitCode=$? - fi - # If the current directory contains a 'Make' directory continue - # otherwise exit, or always exit in case of error - if [ ! -d $MakeDir -o $makeExitCode -ne 0 ] - then - exit $makeExitCode - fi - - # Clean up tracking variable - unset makeExitCode + # Exit if current directory does not contains a 'Make' directory or + # an error was previously encountered + if [ ! -d "$MakeDir" -o $makeExitCode -ne 0 ] + then + exit $makeExitCode fi fi @@ -339,9 +334,9 @@ fi # Recurse the source tree to compile "all" targets using wmakeQueue #------------------------------------------------------------------------------ -if [ "$all" = "queue" ] +if [ "$all" = queue ] then - [ -n "$update" ] || wmakeLnIncludeAll $parOpt + [ "$update" = true ] || wmakeLnIncludeAll $parOpt ( export WM_COLLECT_DIR=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}/${PWD////_} @@ -369,20 +364,18 @@ cdSource # Transform no option to "libso" if that looks appropriate or remove it # so that the call to make builds the application -if [ "$targetType" = "" ] +if [ -z "$targetType" ] then - unset targetType - if grep -e '^ *LIB *=' "$MakeDir/files" >/dev/null 2>&1 + if grep -qe '^ *LIB *=' "$MakeDir/files" 2>/dev/null then targetType=libso fi -elif grep -e '^ *EXE *=' "$MakeDir/files" >/dev/null 2>&1 +elif grep -qe '^ *EXE *=' "$MakeDir/files" 2>/dev/null then # Application. Remove any nonsense targetType case "$targetType" in - lib*) + lib*) unset targetType - break ;; esac fi @@ -396,8 +389,8 @@ fi objectsDir=$MakeDir/$WM_OPTIONS if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] then - platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$platformPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) + buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) fi ( @@ -429,16 +422,15 @@ fi # Make the dependency files #------------------------------------------------------------------------------ -# For libraries create lnInclude ... +# For libraries create lnInclude, but only if 'LIB' is declared in 'Make/files' case "$targetType" in - lib | libo | libso | dep ) - # ... but only if 'LIB' is declared in 'Make/files' - if grep -e '^ *LIB *=' "$MakeDir/files" >/dev/null 2>&1 - then - $make -s -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \ - OBJECTS_DIR=$objectsDir lnInclude - fi - ;; +(lib | libo | libso | dep) + if grep -qe '^ *LIB *=' "$MakeDir/files" 2>/dev/null + then + $make -s -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \ + OBJECTS_DIR=$objectsDir lnInclude + fi + ;; esac @@ -453,12 +445,7 @@ then OBJECTS_DIR=$objectsDir updatedep makeExitCode=$? - if [ $makeExitCode -ne 0 ] - then - exit $makeExitCode - fi - - unset makeExitCode + [ $makeExitCode -eq 0 ] || exit $makeExitCode fi @@ -469,12 +456,6 @@ fi exec $make -f $WM_DIR/makefiles/general MAKE_DIR=$MakeDir \ OBJECTS_DIR=$objectsDir $targetType - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage useAllCores update expandPath findTarget - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeCheckPwd b/wmake/wmakeCheckPwd index f10b6d2339..d21318778b 100755 --- a/wmake/wmakeCheckPwd +++ b/wmake/wmakeCheckPwd @@ -89,7 +89,7 @@ dirName="$1" # Simple check against $PWD [ "$PWD" = "$dirName" ] && exit 0 -# Check existance of +# Check existence of [ -d "$dirName" ] || { [ "$quietOpt" = true ] || { echo "$Script error: Directory does not exist $dirName" @@ -108,14 +108,7 @@ target=$(cd $dirName 2>/dev/null && /bin/pwd) [ "$quietOpt" = true ] || { echo "$Script error: Current directory is not $dirName" } + exit 1 - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - - #------------------------------------------------------------------------------ diff --git a/wmake/wmakeCollect b/wmake/wmakeCollect index 2aaa2c6eef..014256df52 100755 --- a/wmake/wmakeCollect +++ b/wmake/wmakeCollect @@ -68,8 +68,8 @@ USAGE exit 1 } -# Set true to clean-up file if interupted -cleanup= +# Set true to clean-up file if interrupted +unset cleanup while [ "$#" -gt 0 ] do @@ -78,7 +78,7 @@ do usage ;; -kill | -clean) - cleanup="true" + cleanup=true shift ;; -*) @@ -110,7 +110,7 @@ makefile="$WM_COLLECT_DIR.Makefile" # Clean-up files and exit -if [ -n "$cleanup" ] +if [ "$cleanup" = true ] then rm -rf $WM_COLLECT_DIR rm -f $makefile @@ -142,31 +142,23 @@ then echo -e "\t$E cd $PWD && \\" >> $file echo -e "\t${@:1:($#-1)} $object" >> $file echo >> $file -else - if [ -d $WM_COLLECT_DIR ] - then - # Collect all the makefiles into a single makefiles for this build - (cd $WM_COLLECT_DIR && ls -1rt | xargs cat > $makefile) +elif [ -d $WM_COLLECT_DIR ] +then + # Collect all the makefiles into a single makefiles for this build + (cd $WM_COLLECT_DIR && ls -1rt | xargs cat > $makefile) - # Add a build rule for all of the targets - echo 'all: $(OBJECTS)' >> $makefile + # Add a build rule for all of the targets + echo 'all: $(OBJECTS)' >> $makefile - # Clear out all of the target makefiles - rm -rf $WM_COLLECT_DIR + # Clear out all of the target makefiles + rm -rf $WM_COLLECT_DIR - # Run make on the collected makefile - make -j $WM_NCOMPPROCS -f $makefile all + # Run make on the collected makefile + make -j $WM_NCOMPPROCS -f $makefile all - rm -f $makefile - fi + rm -f $makefile fi - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeFilesAndOptions b/wmake/wmakeFilesAndOptions index 488c211ab4..8519006ef0 100755 --- a/wmake/wmakeFilesAndOptions +++ b/wmake/wmakeFilesAndOptions @@ -60,7 +60,7 @@ do usage ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -102,11 +102,6 @@ fi } -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeLnInclude b/wmake/wmakeLnInclude index 3db3802de4..0b338ac742 100755 --- a/wmake/wmakeLnInclude +++ b/wmake/wmakeLnInclude @@ -91,7 +91,7 @@ do shift ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -167,12 +167,6 @@ find .. $findOpt \ \) \ -exec ln $lnOpt {} . \; - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeLnIncludeAll b/wmake/wmakeLnIncludeAll index 73cd5798cf..03a8930963 100755 --- a/wmake/wmakeLnIncludeAll +++ b/wmake/wmakeLnIncludeAll @@ -62,12 +62,12 @@ findName=lnInclude nCores=0 # Default 'wmakeLnInclude' option -wmLnOpt= +unset wmLnOpt while [ "$#" -gt 0 ] do case "$1" in - -h | -help) # Provide immediate help + -h | -help) usage ;; -u | -update) @@ -75,16 +75,16 @@ do ;; # Parallel execution on WM_NCOMPPROCS cores -j) - nCores=$WM_NCOMPPROCS + nCores=${WM_NCOMPPROCS:-0} test $# -ge 2 && expr $2 + 1 > /dev/null 2>&1 \ && shift && nCores=$1 ;; # Parallel compilation on specified number of cores - -j*) + -j[1-9]*) nCores=${1#-j} ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -93,9 +93,6 @@ do shift done - -FAIL=0 - if [ "$nCores" -gt 0 ] then echo "$Script: starting wmakeLnInclude processes on $nCores cores" @@ -122,7 +119,7 @@ do topDir=${MakeDir%/Make} # trim /Make from the end if [ -d "$topDir" ] then - if grep -e '^ *LIB *=' "$MakeDir/files" >/dev/null 2>&1 + if grep -qe '^ *LIB *=' "$MakeDir/files" 2>/dev/null then # If running in parallel start wmakeLnInclude on nCores # and more as the cores become free @@ -159,12 +156,6 @@ then sleep 2 fi - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeScheduler b/wmake/wmakeScheduler index a927af7a37..98e645baf3 100755 --- a/wmake/wmakeScheduler +++ b/wmake/wmakeScheduler @@ -237,12 +237,6 @@ then setterm -foreground default fi - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wmakeSchedulerUptime b/wmake/wmakeSchedulerUptime index 6239f9e65c..19a346a809 100755 --- a/wmake/wmakeSchedulerUptime +++ b/wmake/wmakeSchedulerUptime @@ -252,12 +252,6 @@ do sleep 1 done - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wrmdep b/wmake/wrmdep index 790d6ed906..c2f648e74e 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation -# \\/ M anipulation | +# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -25,21 +25,21 @@ # Script wrmdep # # Usage -# wrmdep [-a | -all | all] [file] -# wrmdep [-o | -old] [dir1 .. dirN] +# wrmdep [-a | -all | all] [file1 [..fileN]] +# wrmdep [-o | -old] [[dir1 [..dirN]] # wrmdep -update # # Description # This is a catch-all script for pruning .dep files, depending on the # provided arguments. # -# [-a | -all | all] [file]: +# [-a | -all | all] [file1 [.. fileN]]: # Remove all .dep files from the object directory tree corresponding to the -# current source derectory or remove only the .dep files referring to the -# optionally specified [file]. With the -a/-all/all option the .dep files +# current source directory or remove only the .dep files referring to the +# optionally specified file(s). With the -a/-all/all option the .dep files # are removed for all platforms rather than just the current platform. # -# [-o | -old] [dir1 .. dirN]: +# [-o | -old] [dir1 [.. dirN]]: # Remove *.dep files that are without a corresponding .C or .L source file. # This occurs when a directory has been moved. # - prints the questionable directory and *.dep file @@ -48,10 +48,11 @@ # Search all the "src" and "application" directories of the project for # broken symbolic links for source code files and then remove all .dep # files that relate to files that no longer exist. -# Must be executed in the project top-level directory: $WM_PROJECT_DIR. +# Must be executed in the project top-level directory: +# $WM_PROJECT_DIR. # #------------------------------------------------------------------------------ -Script=${0##*/} +Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions @@ -62,26 +63,27 @@ usage() { cat< - With the -a/-all/all option the .dep files are removed for all - platform rather than just the current platform. + Remove all .dep files or remove .dep files referring to + With the -a/-all/all option the .dep files are removed for all + platforms rather than just the current platform ($WM_OPTIONS). - $Script [-o | -old] [dir1 .. dirN] +$Script [-o | -old] [dir1 [..dirN]] - Remove *.dep files that are without a corresponding .C or .L file. - This occurs when a directory has been moved. - - prints the questionable directory and *.dep file + Remove *.dep files that are without a corresponding .C or .L file. + This occurs when a directory has been moved. + - prints the questionable directory and *.dep file - Note: to remove empty directories, run: wclean empty + Note: to remove empty directories, run: wclean empty - $Script -update +$Script -update - Search all the "src" and "application" directories of the project for - broken symbolic links for source code files and then remove all .dep - files that relate to files that no longer exist. - Must be executed in the project top-level directory: $WM_PROJECT_DIR + Search all the "src" and "application" directories of the project for + broken symbolic links for source code files and then remove all .dep + files that relate to files that no longer exist. + Must be executed in the project top-level directory: + $WM_PROJECT_DIR USAGE exit 1 @@ -93,10 +95,10 @@ USAGE #------------------------------------------------------------------------------ # Default is for removing all .dep files in the current directory -rmdepMode="files" +rmdepMode=files # Default to processing only the current platform -all= +unset all while [ "$#" -gt 0 ] do @@ -105,27 +107,28 @@ do -h | -help) usage ;; - # Non-stop compilation, ignoring errors + # All platforms -a | -all | all) - all="all" + all=all shift ;; -o | -old) - rmdepMode="oldFolders" + rmdepMode=oldFolders shift ;; -update) - rmdepMode="updateMode" + rmdepMode=updateMode shift ;; -*) - usage "unknown option: '$*'" - ;; + usage "unknown option: '$1'" + ;; *) - break - ;; + break + ;; esac done +#------------------------------------------------------------------------------ # Check environment variables checkEnv @@ -141,7 +144,7 @@ files) findObjectDir . # With the -a/-all option replace the current platform with a wildcard - if [ "$all" = "all" ] + if [ "$all" = all ] then objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) fi @@ -151,19 +154,21 @@ files) echo "removing all .dep files ..." find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null else - echo "removing .dep files referring to $1 ..." - find $objectsDir -name '*.dep' -exec grep -q "$1" '{}' \; \ - -exec rm '{}' \; -print + echo "removing .o files corresponding to" + echo " $@ ..." + for file + do + find $objectsDir -name '*.dep' -exec grep -q "$file" '{}' \; \ + -exec rm '{}' \; -print + done fi - ;; oldFolders) - # Default is the current directory [ "$#" -gt 0 ] || set -- . - echo "Removing dep files that refer to sources files that no longer exist..." + echo "Removing dep files that refer to source files that no longer exist..." for checkDir do @@ -182,21 +187,19 @@ oldFolders) depToSource $depFile # Check C++ or Flex source file exists - if [ ! -r "$sourceFile" ]; + if [ ! -r "$sourceFile" ] then echo " rm $depFile" rm -f $depFile 2>/dev/null fi done done - ;; updateMode) - if [ "$PWD" != "$WM_PROJECT_DIR" ] then - echo "Cannot 'update', not in the project top-level directory" + echo "Cannot 'update', not in the project top-level directory" 1>&2 exit 1 fi @@ -206,30 +209,19 @@ updateMode) for filePathAndName in $fileNameList do fileName=$(basename $filePathAndName) - echo " 'src': $fileName" - cd src - $Script -a $fileName - - echo " 'applications': $fileName" - cd ../applications - $Script -a $fileName - - cd .. + for subdir in src applications + do + echo " '$subdir': $fileName" + (cd $subdir && $Script -a $fileName) + done # Just in case, remove the symbolic link as the last step unlink $filePathAndName done - ;; esac - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage rmdepMode all - +exit 0 # clean exit #------------------------------------------------------------------------------ diff --git a/wmake/wrmo b/wmake/wrmo index b7cab9bf98..01610c0f10 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation -# \\/ M anipulation | +# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -26,7 +26,7 @@ # wrmo # # Usage -# wrmo [-a | -all | all] [file] +# wrmo [-a | -all | all] [file1 [... fileN]] # # Description # Remove all .o files from the object directory tree corresponding to the @@ -35,7 +35,7 @@ # are removed for all platforms rather than just the current platform. # #------------------------------------------------------------------------------ -Script=${0##*/} +Script=${0##*/} # Note: need 'Script' for some functions in wmakeFunctions # Source the wmake functions . ${0%/*}/scripts/wmakeFunctions @@ -44,7 +44,11 @@ usage() { exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< @@ -58,7 +62,7 @@ USAGE #------------------------------------------------------------------------------ # Default to processing only the current platform -all= +unset all while [ "$#" -gt 0 ] do @@ -66,17 +70,17 @@ do -h | -help) usage ;; - # Non-stop compilation, ignoring errors + # All platforms -a | -all | all) - all="all" + all=all shift ;; -*) - usage "unknown option: '$*'" - ;; + usage "unknown option: '$1'" + ;; *) - break - ;; + break + ;; esac done @@ -91,7 +95,7 @@ checkEnv findObjectDir . # With the -a/-all option replace the current platform with a wildcard -if [ "$all" = "all" ] +if [ "$all" = all ] then objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) fi @@ -101,16 +105,14 @@ then echo "removing all .o files ..." find $objectsDir -name '*.o' -print | xargs -t rm 2>/dev/null else - echo "removing .o files corresponding to $1 ..." - rm $objectsDir/${1%%.*}.o + echo "removing .o files corresponding to" + echo " $@ ..." + for file + do + rm $objectsDir/${file%%.*}.o + done fi - -#------------------------------------------------------------------------------ -# Cleanup local variables and functions -#------------------------------------------------------------------------------ - -unset Script usage - +exit 0 # clean exit #------------------------------------------------------------------------------ From e82a02945365ef4165d660c79804a7445242083b Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 10 Feb 2017 14:10:00 +0100 Subject: [PATCH 03/18] ENH: add help/usage for dirToString, wmkdep. Add dirToString -strip option. - The dirToString -strip option is simple, but reduces effort for the caller. --- wmake/scripts/makeFiles | 28 +++++++++------------- wmake/scripts/makeOptions | 2 +- wmake/src/dirToString.c | 50 ++++++++++++++++++++++++++++++++++----- wmake/src/wmkdep.l | 37 ++++++++++++++++++++++------- 4 files changed, 84 insertions(+), 33 deletions(-) diff --git a/wmake/scripts/makeFiles b/wmake/scripts/makeFiles index 8d5a2c76f3..78b7fffed3 100755 --- a/wmake/scripts/makeFiles +++ b/wmake/scripts/makeFiles @@ -34,7 +34,7 @@ if [ -r Make/files ] then - echo "Error: Make/files already exists - exiting" + echo "Error: Make/files already exists - exiting" 1>&2 exit 1 fi @@ -43,38 +43,32 @@ dirToString=$WM_DIR/platforms/$WM_ARCH$WM_COMPILER/dirToString [ -d Make ] || mkdir Make rm -f Make/files -for dir in `find . -type d -print` +for dir in $(find . -mindepth 1 -type d -print) do case "$dir" in . | ./Make | ./lnInclude ) # Skip special directories ;; *) - baseDir=`echo $dir | sed 's%^\./%%'` - baseDirName=`echo $baseDir | $dirToString` - - echo $baseDirName " = " $baseDir >> Make/files + echo "$(echo $dir | $dirToString -strip) = ${dir#./}" ;; esac -done +done >> Make/files +[ -s Make/files ] && echo >> Make/files -echo >> Make/files - -for file in `find . -name "*.[cCylLfF]" -type f -print` +for file in $(find . -type f -name "*.[cCylLfF]" -print) do - fileName=${file##*/} - pathName=`echo ${file%/*} | sed -e 's%^\.%%' -e 's%^/%%' | $dirToString` + pathName=$(echo ${file%/*} | $dirToString -strip) if [ -n "$pathName" ] then - echo '$('$pathName')/'$fileName >> Make/files + echo '$('$pathName')/'"${file##*/}" else - echo $fileName >> Make/files + echo "${file##*/}" fi -done +done >> Make/files echo >> Make/files - -echo 'EXE = $(FOAM_APPBIN)/'${PWD##*/} >> Make/files +echo 'EXE = $(FOAM_APPBIN)/'"${PWD##*/}" >> Make/files #------------------------------------------------------------------------------ diff --git a/wmake/scripts/makeOptions b/wmake/scripts/makeOptions index 56ba6009ce..62f7e88e5e 100755 --- a/wmake/scripts/makeOptions +++ b/wmake/scripts/makeOptions @@ -34,7 +34,7 @@ if [ -r Make/options ] then - echo "Error: Make/options already exists - exiting" + echo "Error: Make/options already exists - exiting" 1>&2 exit 1 fi diff --git a/wmake/src/dirToString.c b/wmake/src/dirToString.c index 4200fd89d8..1ce3e9455f 100644 --- a/wmake/src/dirToString.c +++ b/wmake/src/dirToString.c @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -33,22 +33,61 @@ Usage e.g. using sh - baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString` + baseDirName=$(echo $dir | $bin/dirToString -strip) using csh - set baseDirName=`echo $dir | sed 's%^\./%%' | $bin/dirToString` + set baseDirName=`echo $dir | $bin/dirToString -strip` \*----------------------------------------------------------------------------*/ #include #include +#include #include -int main() +int main(int argc, char* argv[]) { int c; int nextupper = 0; + if (argc > 1) + { + if (!strncmp(argv[1], "-h", 2)) /* -h, -help */ + { + fprintf + ( + stderr, + "\nUsage: %s [-strip]\n\n", + "dirToString" + ); + + fprintf + ( + stderr, + " -strip ignore leading [./] characters.\n\n" + "Transform dir1/dir2 to camel-case dir1Dir2\n\n" + ); + + return 0; + } + + if (!strcmp(argv[1], "-s") || !strcmp(argv[1], "-strip")) /* -s, -strip */ + { + while ((c=getchar()) != EOF && (c == '.' || c == '/')) + { + /* nop */ + } + + if (c == EOF) + { + return 0; + } + + putchar(c); + } + } + + while ((c=getchar()) != EOF) { if (c == '/') @@ -60,13 +99,12 @@ int main() if (nextupper) { putchar(toupper(c)); + nextupper = 0; } else { putchar(c); } - - nextupper = 0; } } diff --git a/wmake/src/wmkdep.l b/wmake/src/wmkdep.l index b0b48d1055..4b0aeaa85a 100644 --- a/wmake/src/wmkdep.l +++ b/wmake/src/wmkdep.l @@ -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) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------ License This file is part of OpenFOAM. @@ -147,10 +147,29 @@ int main(int argc, char* argv[]) char *basePos, *dotPos; int i, silent; - if (argc == 1) + if (argc < 2) { fprintf(stderr, "input file not supplied\n"); - exit(1); + return 1; + } + else if (!strncmp(argv[1], "-h", 2)) /* -h, -help */ + { + fprintf + ( + stderr, + "\nUsage: %s [-Idir ... -Idir] [-iheader .. -iheader] filename\n\n", + "wmkdep" + ); + + fprintf + ( + stderr, + " -Idir Directories to be searched for headers.\n" + " -iheader Headers to be ignored.\n\n" + "Dependency list generator, similar to 'cpp -M'\n\n" + ); + + return 0; } sourceFile = strdup(argv[argc-1]); @@ -161,7 +180,7 @@ int main(int argc, char* argv[]) } else { - basePos++; + ++basePos; } if @@ -176,18 +195,18 @@ int main(int argc, char* argv[]) "cannot find extension in source file name %s\n", sourceFile ); - exit(1); + return 1; } /* count number of -I directories */ nDirectories = 0; - for (i = 1; i < argc; i++) + for (i = 1; i < argc; ++i) { if (strncmp(argv[i], "-I", 2) == 0) { if (strlen(argv[i]) > 2) { - nDirectories++; + ++nDirectories; } } } @@ -196,7 +215,7 @@ int main(int argc, char* argv[]) /* build list of -I directories and add -i ignores */ nDirectories = 0; - for (i = 1; i < argc; i++) + for (i = 1; i < argc; ++i) { if (strncmp(argv[i], "-I", 2) == 0) { @@ -240,7 +259,7 @@ int main(int argc, char* argv[]) puts("\n"); - for (i = 0; i < nDirectories; i++) + for (i = 0; i < nDirectories; ++i) { free(directories[i]); } From 3d02c8a5305aaf0cfafecfcc712404807fdb9477 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Feb 2017 16:13:54 +0100 Subject: [PATCH 04/18] ENH: improve isolation of shell variables in wmake scripts - reduces unexpected interactions between various make elements --- .../graphics/PVReaders/PVFoamReader/Allwclean | 5 +- .../PVReaders/PVblockMeshReader/Allwclean | 5 +- src/Pstream/Allwmake | 7 +- .../graphics/runTimePostProcessing/Allwclean | 5 +- src/parallel/decompose/Allwclean | 2 - src/parallel/decompose/Allwmake | 9 +- wmake/scripts/cmakeFunctions | 46 ++--- wmake/scripts/wmakeFunctions | 184 ++++++++++-------- wmake/wclean | 71 ++++--- wmake/wcleanPlatform | 4 +- wmake/wdep | 5 +- wmake/wmake | 14 +- wmake/wrmdep | 19 +- wmake/wrmo | 10 +- 14 files changed, 201 insertions(+), 185 deletions(-) diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean index 4df5195cb1..9b1370c3ff 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVFoamReader/Allwclean @@ -10,8 +10,7 @@ rm -f $FOAM_LIBBIN/libPVFoamReader* 2>/dev/null rm -rf PVFoamReader/Make # safety: old build location wclean libso vtkPVFoam -# Cleanup generated files -findObjectDir $PWD # remove entire top-level -rm -rf "$objectsDir" > /dev/null 2>&1 +# Cleanup generated files - remove entire top-level +removeObjectDir $PWD #------------------------------------------------------------------------------ diff --git a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean index 8e0fd1a41a..b49fed7d2d 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PVReaders/PVblockMeshReader/Allwclean @@ -10,8 +10,7 @@ rm -f $FOAM_LIBBIN/libPVblockMeshReader* 2>/dev/null rm -rf PVblockMeshReader/Make # safety: old build location wclean libso vtkPVblockMesh -# Cleanup generated files -findObjectDir $PWD # remove entire top-level -rm -rf "$objectsDir" > /dev/null 2>&1 +# Cleanup generated files - remove entire top-level +removeObjectDir $PWD #------------------------------------------------------------------------------ diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index d32bc5503d..c752d8220f 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -10,16 +10,17 @@ cd ${0%/*} || exit 1 # Run from this directory # use sentinel file to handle version changes wmakeMpiLib() { + local objectsDir for libName do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - libDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName" - whichmpi="$libDir/using:$FOAM_MPI" + objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName" + whichmpi="$objectsDir/using:$FOAM_MPI" [ -e "$whichmpi" ] || wclean $libName echo "wmake $targetType $libName" wmake $targetType $libName - mkdir -p "$libDir" + mkdir -p "$objectsDir" touch "$whichmpi" ) done diff --git a/src/functionObjects/graphics/runTimePostProcessing/Allwclean b/src/functionObjects/graphics/runTimePostProcessing/Allwclean index 00ff12fadb..7a118a4349 100755 --- a/src/functionObjects/graphics/runTimePostProcessing/Allwclean +++ b/src/functionObjects/graphics/runTimePostProcessing/Allwclean @@ -7,8 +7,7 @@ cd ${0%/*} || exit 1 # Run from this directory # Cleanup library rm -f $FOAM_LIBBIN/librunTimePostProcessing* 2>/dev/null -# Cleanup generated files -findObjectDir $PWD # remove entire top-level -rm -rf "$objectsDir" > /dev/null 2>&1 +# Cleanup generated files - remove entire top-level +removeObjectDir $PWD #------------------------------------------------------------------------------ diff --git a/src/parallel/decompose/Allwclean b/src/parallel/decompose/Allwclean index e0acdabc15..ef6dc41212 100755 --- a/src/parallel/decompose/Allwclean +++ b/src/parallel/decompose/Allwclean @@ -20,8 +20,6 @@ wcleanMpiLib() do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - whichmpi="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName/using:$FOAM_MPI" - whichscotch="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName/using:$SCOTCH_VERSION" wclean $libName ) done diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 6bddc475ea..82e965e79c 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -126,18 +126,19 @@ hasScotch() wmakeMpiLib() { local decompName="$1" + local objectsDir shift for libName do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - libDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName" - whichmpi="$libDir/using:$FOAM_MPI" - whichdecomp="$libDir/using:$decompName" + objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName" + whichmpi="$objectsDir/using:$FOAM_MPI" + whichdecomp="$objectsDir/using:$decompName" [ -e "$whichmpi" -a -e "$whichdecomp" ] || wclean $libName echo "wmake $targetType $libName" wmake $targetType $libName - mkdir -p "$libDir" + mkdir -p "$objectsDir" touch "$whichdecomp" "$whichmpi" ) done diff --git a/wmake/scripts/cmakeFunctions b/wmake/scripts/cmakeFunctions index a95e686aea..b78d7c34aa 100644 --- a/wmake/scripts/cmakeFunctions +++ b/wmake/scripts/cmakeFunctions @@ -44,12 +44,15 @@ sameDependency() { local depend="$1" - findObjectDir "$2" # Where generated files are stored - local sentinel="$objectsDir/ThirdParty" + local sourceDir="$2" + local objectsDir sentinel prev + + # Where generated files are stored + objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal + sentinel="$objectsDir/ThirdParty" echo $sentinel - local prev if read -r prev 2>/dev/null < $sentinel then if [ "$prev" = "$depend" ] @@ -70,35 +73,24 @@ sameDependency() # CMake into objectsDir with external dependency +# - use sentinel file(s) to handle paraview/vtk version changes cmakeVersioned() { local depend="$1" local sourceDir="$2" - findObjectDir $sourceDir # Where are generated files stored? + local objectsDir sentinel - local sentinel + # Where generated files are stored + objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal - # version changed - sentinel=$(sameDependency "$depend" "$sourceDir") \ - || rm -rf "$objectsDir" > /dev/null 2>&1 - - test -f "$objectsDir/CMakeCache.txt" - retry=$? # Additional attempt if sources moved + # Version changed + sentinel=$(sameDependency "$depend" "$sourceDir") || \ + rm -rf "$objectsDir" > /dev/null 2>&1 mkdir -p $objectsDir && \ ( - cd $objectsDir || exit 1 - - cmake $sourceDir || { - if [ $retry -eq 0 ] - then - echo "Removing CMakeCache.txt and attempt again" 1>&2 - rm -f CMakeCache.txt - cmake $sourceDir - else - exit 1 - fi - } && make && { echo "$depend" > $sentinel; } + cd $objectsDir && cmake $sourceDir && make \ + && echo "$depend" > ${sentinel:-/dev/null} ) } @@ -127,9 +119,11 @@ wmakeLibPv() for libName do - # version changed - sentinel=$(sameDependency "$depend" $libName) || wclean $libName - wmake $targetType $libName && { echo "$depend" > $sentinel; } + sentinel=$(sameDependency "$depend" $libName) || \ + wclean $libName + + wmake $targetType $libName \ + && echo "$depend" > ${sentinel:-/dev/null} done } diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions index 4ed0b7b0f3..ee9a2067bd 100644 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -28,6 +28,11 @@ # Functions to check wmake environment and find .dep and .o files #------------------------------------------------------------------------------ +# Ensure these variables are always defined +MakeDir=Make +: ${Script:=wmakeFunctions} + + #------------------------------------------------------------------------------ # Check environment variables #------------------------------------------------------------------------------ @@ -52,78 +57,83 @@ checkEnv() # expandPath dirName # expandPath fileName # -# Sets: -# - exPath +# Output: +# - the expanded path name expandPath() { if [ -d "$1" ] then - exPath=$(cd "$1" && pwd -P) + (cd "$1" && pwd -P) + elif [ -n "$1" ] + then + (cd $(dirname "$1") && pwd -P) else - exPath=$(cd $(dirname "$1") && pwd -P) + pwd -P fi } -# Find the target directory +# Find the target directory, which contains a Make/ directory +# search upwards in its parent directories, but stopping +# when it hits the project root, home, or the file-system root +# # findTarget dirName -# findTarget fileName # -# Sets: -# - dir -# -# Side-effect variables: -# - sets exPath -# - sets wmpdir +# Output: +# - the relative target directory # # Global variables used: # - WM_PROJECT_DIR, HOME findTarget() { - expandPath $WM_PROJECT_DIR - wmpdir=$exPath - expandPath $1 + local wmpdir=$(expandPath $WM_PROJECT_DIR) + local home=$(expandPath $HOME) + local reldir="${1:-.}" + local absdir=$(expandPath $reldir) - if [ "$exPath" = "$wmpdir" \ - -o "$exPath" = "$HOME" \ - -o "$exPath" = "/" \ - ] - then - echo "$Script error: could not find Make directory" 1>&2 - exit 1 - elif [ -d "$1/Make" ] - then - dir=$1 - else - findTarget "$1/.." - fi + while [ -n "$absdir" ] + do + case "$absdir" in + ($wmpdir | $home | /) + break + ;; + esac + + if [ -d "$reldir/Make" ] + then + echo "$reldir" + return 0 + else + # Check parent directory + absdir="${absdir%/*}" + reldir="$reldir/.." + fi + done + + echo "Error: no Make directory for $(expandPath $1)" 1>&2 + echo 1>&2 + return 1 } -# Change to 'MakeDir' -# - 'MakeDir' for its input + +# Change to 'MakeDir' parent +# - uses 'MakeDir' for its input # -# Sets: -# - dir -# -# Side-effect variables: -# - sets exPath +# Side-effects: # - unsets targetType cdSource() { - if [ ! -d $MakeDir ] + local dir + if [ ! -d "$MakeDir" ] then echo "$Script: '$MakeDir' directory does not exist in $PWD" 1>&2 echo " Searching up directories tree for Make directory" 1>&2 + + dir=$(findTarget .) || exit 1 # Fatal + cd $dir 2>/dev/null || { + echo "$Script error: could not change to directory '$dir'" 1>&2 + exit 1 + } unset targetType - - findTarget . - - if [ "$dir" ] - then - cd $dir 2>/dev/null || { - echo "$Script error: could not change to directory '$dir'" 1>&2 - exit 1 - } - fi fi [ -r $MakeDir/files ] || { @@ -137,48 +147,58 @@ cdSource() # findObjectDir dirName # findObjectDir fileName # -# Sets: -# - dir -# - path -# - appDir -# - objectsDir -# -# Side-effect variables: -# - sets exPath -# - sets wmpdir -# - set platformPath +# Output: +# - the objectsDir # # Global variables used: # - WM_PROJECT_DIR, WM_OPTIONS findObjectDir() { - expandPath $WM_PROJECT_DIR - wmpdir=$exPath - expandPath $1 + local wmpdir=$(expandPath $WM_PROJECT_DIR) + local exPath=$(expandPath ${1:-.}) + local objectsDir - if echo $exPath | grep "$wmpdir" > /dev/null - then - platformPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$platformPath$(echo $exPath | sed s%$wmpdir%% ) - else - path=$exPath - dir=. - if [ ! -d Make ] - then - findTarget . - fi - appDir=$dir - expandPath $appDir/. + case "$exPath" in + ("$wmpdir"/*) + local buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + objectsDir=$buildPath$(echo $exPath | sed s%$wmpdir%% ) + ;; + (*) + local path=$exPath + local appDir=. + [ -d Make ] || appDir=$(findTarget .) || exit 1 # Fatal + exPath=$(expandPath $appDir/.) objectsDir=$appDir/Make/${WM_OPTIONS}$(echo $path | sed s%$exPath%% ) + ;; + esac + + echo "$objectsDir" +} + + +# Find the object directory and remove it +# removeObjectDir dirName +# removeObjectDir fileName +# +# Output: +# - NONE +# +# Global variables used: +# - WM_PROJECT_DIR, WM_OPTIONS +removeObjectDir() +{ + local objectsDir=$(findObjectDir ${1:-.}) + if [ -d "$objectsDir" ] + then + rm -rf "$objectsDir" > /dev/null 2>&1 fi } -# depToSource -# - uses 'depFile' for its input +# depToSource depFile # -# Sets: -# - sourceFile +# Output: +# - the sourceFile corresponding to depFile # # Global variables used: # - WM_OPTIONS @@ -187,20 +207,24 @@ if [ -n "$BASH_VERSION" ] then depToSource() { - sourceFile=${depFile%.dep} + local sourceFile=${1%.dep} sourceFile="${sourceFile/platforms\/${WM_OPTIONS}\//}" - sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}" sourceFile="${sourceFile/platforms\/${WM_OPTIONS}${WM_MPLIB}\//}" + sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}" sourceFile="${sourceFile/Make\/${WM_OPTIONS}${WM_MPLIB}\//}" + + echo "$sourceFile" } else depToSource() { - sourceFile=$(echo ${depFile%.dep} | \ + local sourceFile=$(echo ${1%.dep} | \ sed -e s%platforms/${WM_OPTIONS}/%% \ - -e s%Make/${WM_OPTIONS}/%% \ -e s%platforms/${WM_OPTIONS}${WM_MPLIB}/%% \ + -e s%Make/${WM_OPTIONS}/%% \ -e s%Make/${WM_OPTIONS}${WM_MPLIB}/%% ) + + echo "$sourceFile" } fi diff --git a/wmake/wclean b/wmake/wclean index 42209bc2bb..c41f82c2b6 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -47,6 +47,7 @@ Usage: $Script [OPTION] [dir] $Script [OPTION] target [dir [MakeDir]] options: + -a | -all Same as the 'all' target -s | -silent Ignored - for compatibility with wmake -help Print the usage @@ -67,19 +68,23 @@ USAGE exit 1 } - #------------------------------------------------------------------------------ # Parse arguments and options #------------------------------------------------------------------------------ +unset dir targetType +MakeDir=Make + while [ "$#" -gt 0 ] do case "$1" in -h | -help) usage ;; + -a | -all | all) + targetType=all + ;; -s | -silent) # Ignored - for compatibility with wmake - shift ;; -*) usage "unknown option: '$1'" @@ -88,16 +93,14 @@ do break ;; esac + shift done - #------------------------------------------------------------------------------ -# Check arguments and change to the directory in which to run wclean +# Check arguments and change to the directory in which to run wclean. +# The variables 'targetType' and 'MakeDir' are considered global #------------------------------------------------------------------------------ -unset dir targetType -MakeDir=Make - if [ $# -ge 1 ] then if [ -d "$1" ] @@ -132,7 +135,7 @@ fi #------------------------------------------------------------------------------ # If target not specified search up the directory tree for the Make -# sub-directory, check the existance of the 'files' file and clean there if +# sub-directory, check the existence of the 'files' file and clean there if # present # ------------------------------------------------------------------------------ @@ -159,12 +162,11 @@ then # Second pass: clean up object directories with WM_PROJECT_DIR that don't # have respective source code folders, along with the respective binaries - expandPath $PWD - if [ "$exPath" = "$WM_PROJECT_DIR" ] + if [ "$(expandPath $PWD)" = "$WM_PROJECT_DIR" ] then - findObjectDir $PWD + objectsDir=$(findObjectDir $PWD) || exit 1 # Fatal - if [ -d $objectsDir ] + if [ -d "$objectsDir" ] then echo " Removing redundant object directories in $objectsDir" @@ -173,7 +175,7 @@ then do # Hack'ish way of getting the original source code path depFile=$(dirname $variablesFile) - depToSource $depFile + sourceFile=$(depToSource $depFile) # Check if the original source code directory exists if [ ! -r "$sourceFile" ] @@ -227,43 +229,40 @@ then then ./Allclean exit $? - else - # For all the sub-directories containing a 'Make' directory - for dir in `find . \( -type d -a -name Make \)` - do - dir=${dir%/Make} # Parent directory - trim /Make from the end - - # If Allwclean exists execute otherwise wclean - if [ -e "$dir/Allwclean" ] - then - $dir/Allwclean - else - $0 $dir - fi - done fi -fi -# targetType is not needed beyond this point -unset targetType + # For all sub-directories containing a 'Make' directory + for dir in $(find . -type d -name Make) + do + dir=${dir%/*} # Parent directory containing the Make directory + + # Use Allwclean if it exists, otherwise wclean + if [ -e "$dir/Allwclean" ] + then + $dir/Allwclean + else + $0 $dir + fi + done +fi #------------------------------------------------------------------------------ # Clean the 'Make' directory if present #------------------------------------------------------------------------------ -if [ -d $MakeDir ] +if [ -d "$MakeDir" ] then objectsDir=$MakeDir/$WM_OPTIONS - if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] - then + case "$PWD" in + ("$WM_PROJECT_DIR"/*) buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) - fi + objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) + ;; + esac rm -rf $objectsDir 2>/dev/null fi - #------------------------------------------------------------------------------ # Remove the lnInclude directory if present #------------------------------------------------------------------------------ diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform index 36605bdf55..18b4d5b2c3 100755 --- a/wmake/wcleanPlatform +++ b/wmake/wcleanPlatform @@ -103,10 +103,10 @@ else [ -n "$platform" ] || continue fi - if [ -d platforms/${platform} ] + if [ -d "platforms/$platform" ] then echo "Cleaning platform $platform" - rm -rf platforms/${platform}* + rm -rf "platforms/$platform"* else echo "Platform $platform not built" fi diff --git a/wmake/wdep b/wmake/wdep index dd20f21a97..c7aaa47df7 100755 --- a/wmake/wdep +++ b/wmake/wdep @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2014-2015 OpenFOAM Foundation -# \\/ M anipulation | +# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -105,8 +105,7 @@ fi # and echo path for the dep file corresponding to the specified source file #------------------------------------------------------------------------------ -findObjectDir $sourceFile -echo "$objectsDir/${sourceFile##*/}.dep" +echo "$(findObjectDir $sourceFile)/${sourceFile##*/}.dep" exit 0 # clean exit diff --git a/wmake/wmake b/wmake/wmake index e251b1e9f4..219bbf454e 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -239,7 +239,8 @@ fi #------------------------------------------------------------------------------ -# Check arguments and change to the directory in which to run wmake +# Check arguments and change to the directory in which to run wmake. +# The variables 'targetType' and 'MakeDir' are considered global #------------------------------------------------------------------------------ unset dir targetType @@ -352,7 +353,7 @@ fi #------------------------------------------------------------------------------ # Search up the directory tree for the Make sub-directory, -# check the existance of the 'files' file and build there if present +# check the existence of the 'files' file and build there if present #------------------------------------------------------------------------------ cdSource @@ -387,11 +388,12 @@ fi #------------------------------------------------------------------------------ objectsDir=$MakeDir/$WM_OPTIONS -if [ $(echo $PWD | grep "$WM_PROJECT_DIR") ] -then +case "$PWD" in +("$WM_PROJECT_DIR"/*) buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} - objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%%) -fi + objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) + ;; +esac ( unset MAKEFLAGS diff --git a/wmake/wrmdep b/wmake/wrmdep index c2f648e74e..1d37a1564c 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -141,7 +141,7 @@ files) # Remove the selected .dep files from the object tree #------------------------------------------------------------------------- - findObjectDir . + objectsDir=$(findObjectDir .) || exit 1 # Fatal # With the -a/-all option replace the current platform with a wildcard if [ "$all" = all ] @@ -152,14 +152,15 @@ files) if [ "$#" -eq 0 ] then echo "removing all .dep files ..." - find $objectsDir -name '*.dep' -print | xargs -t rm 2>/dev/null + find $objectsDir -type f -name '*.dep' -print | xargs -t rm 2>/dev/null else echo "removing .o files corresponding to" echo " $@ ..." for file do - find $objectsDir -name '*.dep' -exec grep -q "$file" '{}' \; \ - -exec rm '{}' \; -print + find $objectsDir -type f -name '*.dep' \ + -exec grep -q "$file" '{}' \; \ + -exec rm '{}' \; -print done fi ;; @@ -172,9 +173,9 @@ oldFolders) for checkDir do - findObjectDir $checkDir + objectsDir=$(findObjectDir $checkDir) - if [ -d $objectsDir ] + if [ -d "$objectsDir" ] then echo " searching: $objectsDir" else @@ -182,9 +183,9 @@ oldFolders) continue fi - find $objectsDir -name '*.dep' -print | while read depFile + find $objectsDir -type f -name '*.dep' -print | while read depFile do - depToSource $depFile + sourceFile=$(depToSource $depFile) # Check C++ or Flex source file exists if [ ! -r "$sourceFile" ] @@ -204,7 +205,7 @@ updateMode) fi echo "Removing dep files corresponding to source files that no longer exist..." - fileNameList=$(find -L src applications -name '*.[CHL]' -type l) + fileNameList=$(find -L src applications -type l -name '*.[CHL]') for filePathAndName in $fileNameList do diff --git a/wmake/wrmo b/wmake/wrmo index 01610c0f10..489e179736 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -62,7 +62,7 @@ USAGE #------------------------------------------------------------------------------ # Default to processing only the current platform -unset all +unset platform while [ "$#" -gt 0 ] do @@ -72,7 +72,7 @@ do ;; # All platforms -a | -all | all) - all=all + platform=all shift ;; -*) @@ -92,10 +92,10 @@ checkEnv # Remove the selected .o files from the object tree #------------------------------------------------------------------------------ -findObjectDir . +objectsDir=$(findObjectDir .) || exit 1 # Fatal # With the -a/-all option replace the current platform with a wildcard -if [ "$all" = all ] +if [ "$platform" = all ] then objectsDir=$(echo $objectsDir | sed s%$WM_OPTIONS%*% ) fi @@ -103,7 +103,7 @@ fi if [ "$#" -eq 0 ] then echo "removing all .o files ..." - find $objectsDir -name '*.o' -print | xargs -t rm 2>/dev/null + find $objectsDir -type f -name '*.o' -print | xargs -t rm 2>/dev/null else echo "removing .o files corresponding to" echo " $@ ..." From 957635200af3e2dd2d80e1550064a399974b5feb Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 10 Feb 2017 20:30:15 +0100 Subject: [PATCH 05/18] ENH: build into build/ directory instead of platforms/ (issue #312) - makes it slightly easier when packaging various binaries, or when building packages for installation via modules etc. --- bin/tools/foamListSourceFiles | 1 + src/Pstream/Allwmake | 2 +- src/parallel/decompose/Allwmake | 2 +- wmake/scripts/wmakeFunctions | 14 +++++++------- wmake/wclean | 2 +- wmake/wmake | 4 ++-- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/bin/tools/foamListSourceFiles b/bin/tools/foamListSourceFiles index 0f02cc99b7..4cc449980e 100755 --- a/bin/tools/foamListSourceFiles +++ b/bin/tools/foamListSourceFiles @@ -78,6 +78,7 @@ find -H $packDir \ | sed \ -e '\@/\.git/@d' \ -e '\@/\.tags/@d' \ + -e '\@/build/@d' \ -e '\@/platforms/@d' \ -e '\@/t/@d' \ -e '\@/Make[.A-Za-z]*/[^/]*/@d' \ diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index c752d8220f..e69310f341 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -15,7 +15,7 @@ wmakeMpiLib() do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/Pstream/$libName" + objectsDir="$WM_PROJECT_DIR/build/$WM_OPTIONS/src/Pstream/$libName" whichmpi="$objectsDir/using:$FOAM_MPI" [ -e "$whichmpi" ] || wclean $libName echo "wmake $targetType $libName" diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 82e965e79c..4c61250b6a 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -132,7 +132,7 @@ wmakeMpiLib() do ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - objectsDir="$WM_PROJECT_DIR/platforms/$WM_OPTIONS/src/parallel/decompose/$libName" + objectsDir="$WM_PROJECT_DIR/build/$WM_OPTIONS/src/parallel/decompose/$libName" whichmpi="$objectsDir/using:$FOAM_MPI" whichdecomp="$objectsDir/using:$decompName" [ -e "$whichmpi" -a -e "$whichdecomp" ] || wclean $libName diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions index ee9a2067bd..827fda9885 100644 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -160,7 +160,7 @@ findObjectDir() case "$exPath" in ("$wmpdir"/*) - local buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + local buildPath=$WM_PROJECT_DIR/build/${WM_OPTIONS} objectsDir=$buildPath$(echo $exPath | sed s%$wmpdir%% ) ;; (*) @@ -208,8 +208,8 @@ then depToSource() { local sourceFile=${1%.dep} - sourceFile="${sourceFile/platforms\/${WM_OPTIONS}\//}" - sourceFile="${sourceFile/platforms\/${WM_OPTIONS}${WM_MPLIB}\//}" + sourceFile="${sourceFile/build\/${WM_OPTIONS}\//}" + sourceFile="${sourceFile/build\/${WM_OPTIONS}${WM_MPLIB}\//}" sourceFile="${sourceFile/Make\/${WM_OPTIONS}\//}" sourceFile="${sourceFile/Make\/${WM_OPTIONS}${WM_MPLIB}\//}" @@ -218,10 +218,10 @@ then else depToSource() { - local sourceFile=$(echo ${1%.dep} | \ - sed -e s%platforms/${WM_OPTIONS}/%% \ - -e s%platforms/${WM_OPTIONS}${WM_MPLIB}/%% \ - -e s%Make/${WM_OPTIONS}/%% \ + local sourceFile=$(echo ${1%.dep} | \ + sed -e s%build/${WM_OPTIONS}/%% \ + -e s%build/${WM_OPTIONS}${WM_MPLIB}/%% \ + -e s%Make/${WM_OPTIONS}/%% \ -e s%Make/${WM_OPTIONS}${WM_MPLIB}/%% ) echo "$sourceFile" diff --git a/wmake/wclean b/wmake/wclean index c41f82c2b6..71c8cd096a 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -256,7 +256,7 @@ then objectsDir=$MakeDir/$WM_OPTIONS case "$PWD" in ("$WM_PROJECT_DIR"/*) - buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + buildPath=$WM_PROJECT_DIR/build/${WM_OPTIONS} objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) ;; esac diff --git a/wmake/wmake b/wmake/wmake index 219bbf454e..11dd888968 100755 --- a/wmake/wmake +++ b/wmake/wmake @@ -340,7 +340,7 @@ then [ "$update" = true ] || wmakeLnIncludeAll $parOpt ( - export WM_COLLECT_DIR=$WM_PROJECT_DIR/platforms/${WM_OPTIONS}/${PWD////_} + export WM_COLLECT_DIR=$WM_PROJECT_DIR/build/${WM_OPTIONS}/${PWD////_} export WM_SCHEDULER=wmakeCollect trap '$WM_SCHEDULER -kill' TERM INT $WM_SCHEDULER -clean \ @@ -390,7 +390,7 @@ fi objectsDir=$MakeDir/$WM_OPTIONS case "$PWD" in ("$WM_PROJECT_DIR"/*) - buildPath=$WM_PROJECT_DIR/platforms/${WM_OPTIONS} + buildPath=$WM_PROJECT_DIR/build/${WM_OPTIONS} objectsDir=$buildPath$(echo $PWD | sed s%$WM_PROJECT_DIR%% ) ;; esac From d3911dd16726ca05c24fca8979b85682495ac37e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 20 Feb 2017 09:30:58 +0100 Subject: [PATCH 06/18] STYLE: avoid old-style shell backticks in various places --- bin/foamEtcFile | 2 +- bin/foamPack | 2 +- bin/foamRunTutorials | 4 +- etc/bashrc | 36 ++++---- etc/config.csh/ensight | 4 +- etc/config.csh/settings | 20 +++-- etc/config.sh/ensight | 12 +-- etc/config.sh/functions | 2 +- etc/config.sh/mpi | 8 +- etc/config.sh/settings | 37 ++++----- etc/config.sh/unset | 9 +- etc/cshrc | 4 +- etc/templates/axisymmetricJet/Allrun | 4 +- .../biconic25-55Run35/sampleCone | 6 +- .../buoyantCavity/validation/createGraphs | 2 +- .../externalSolver | 2 +- .../boundaryWallFunctionsProfile/Allrun | 4 +- .../hotBoxes/patchifyObstacles | 82 +++++++++---------- .../interFoam/RAS/waterChannel/Allmesh | 7 +- 19 files changed, 117 insertions(+), 130 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 3d3d01864e..5e21978b0e 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -34,7 +34,7 @@ # # For example, within the user ~/.OpenFOAM//prefs.sh: # \code -# foamPrefs=`$WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh` \ +# foamPrefs=$($WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh) \ # && _foamSource $foamPrefs # \endcode # diff --git a/bin/foamPack b/bin/foamPack index e3d090e2f2..212d0d5e5a 100755 --- a/bin/foamPack +++ b/bin/foamPack @@ -119,7 +119,7 @@ else ( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar && echo "add in time-stamp and lnInclude directories" 1>&2 && - tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build `find -H $packDir -type d -name lnInclude` && + tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build $(find -H $packDir -type d -name lnInclude) && tar Af $packBase.tar $packBase.tar2 && echo "gzip tar file" 1>&2 && diff --git a/bin/foamRunTutorials b/bin/foamRunTutorials index 7aabb6c480..dac6fc894f 100755 --- a/bin/foamRunTutorials +++ b/bin/foamRunTutorials @@ -71,8 +71,8 @@ then elif [ -d system ] then # Run normal case. - parentDir=`dirname $PWD` - application=`getApplication` + parentDir=$(dirname $PWD) + application=$(getApplication) runApplication blockMesh runApplication $application else diff --git a/etc/bashrc b/etc/bashrc index 3f5d04e83b..7eeb3c209a 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -3,7 +3,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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -136,7 +136,7 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION . $WM_PROJECT_DIR/etc/config.sh/functions # Add in preset user or site preferences: -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile prefs.sh) # Evaluate command-line parameters and record settings for later # these can be used to set/unset values, or specify alternative pref files @@ -148,14 +148,14 @@ _foamEval $@ foamClean=$WM_PROJECT_DIR/bin/foamCleanPath #- Clean PATH -cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned" +cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" #- Clean LD_LIBRARY_PATH -cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` \ +cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") \ && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH -cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned" +cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH @@ -168,35 +168,35 @@ _foamSource $WM_PROJECT_DIR/etc/config.sh/aliases # Source user setup files for optional packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools` +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools) -##_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW` +##_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW) # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #- Clean PATH -cleaned=`$foamClean "$PATH"` && PATH="$cleaned" +cleaned=$($foamClean "$PATH") && PATH="$cleaned" #- Clean LD_LIBRARY_PATH -cleaned=`$foamClean "$LD_LIBRARY_PATH"` && LD_LIBRARY_PATH="$cleaned" +cleaned=$($foamClean "$LD_LIBRARY_PATH") && LD_LIBRARY_PATH="$cleaned" #- Clean MANPATH (trailing ':' to find system pages) -cleaned=`$foamClean "$MANPATH"`: && MANPATH="$cleaned" +cleaned=$($foamClean "$MANPATH") && MANPATH="${cleaned}:" export PATH LD_LIBRARY_PATH MANPATH #- Clean LD_PRELOAD if [ -n "$LD_PRELOAD" ] then - cleaned=`$foamClean "$LD_PRELOAD"` && LD_PRELOAD="$cleaned" + cleaned=$($foamClean "$LD_PRELOAD") && LD_PRELOAD="$cleaned" export LD_PRELOAD fi diff --git a/etc/config.csh/ensight b/etc/config.csh/ensight index 44f8a42ddf..1eb65ffc1d 100644 --- a/etc/config.csh/ensight +++ b/etc/config.csh/ensight @@ -38,9 +38,7 @@ endif if ( -r $CEI_HOME ) then # Special treatment for 32bit OpenFOAM and 64bit Ensight - if ($WM_ARCH == linux && `uname -m` == x86_64) then - setenv CEI_ARCH linux_2.6_32 - endif + if ($WM_ARCH-`uname -m` == linux-x86_64) setenv CEI_ARCH linux_2.6_32 # Add to path setenv PATH ${CEI_HOME}/bin:${PATH} diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 659b4c5ae2..74da787d22 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -75,7 +75,7 @@ case Linux: breaksw default: - echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64" + echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" breaksw endsw @@ -124,11 +124,13 @@ case SunOS: setenv WM_LDFLAGS '-mabi=64 -G0' breaksw -default: - echo - echo "Your '$WM_ARCH' operating system is not supported by this release" - echo "of OpenFOAM. For further assistance, please contact www.OpenFOAM.com" - echo +default: # An unsupported operating system + /bin/cat <&2 + echo Unknown processor type $(uname -m) 1>&2 ;; esac ;; diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 4e457c15c0..f395db6207 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -31,21 +31,21 @@ #------------------------------------------------------------------------------ # Set environment variables according to system type -export WM_ARCH=`uname -s` +export WM_ARCH=$(uname -s) case "$WM_ARCH" in Linux) WM_ARCH=linux # Compiler specifics - case `uname -m` in - i686) - export WM_ARCH_OPTION=32 - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-fPIC' - export WM_CXXFLAGS='-fPIC -std=c++0x' - export WM_LDFLAGS= + case $(uname -m) in + i686) + export WM_ARCH_OPTION=32 + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-fPIC' + export WM_CXXFLAGS='-fPIC -std=c++0x' + export WM_LDFLAGS= ;; x86_64) @@ -68,8 +68,7 @@ Linux) export WM_LDFLAGS='-m64' ;; *) - echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64"\ - 1>&2 + echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32|64" 1>&2 ;; esac ;; @@ -111,7 +110,7 @@ Linux) ;; *) - echo Unknown processor type `uname -m` for Linux 1>&2 + echo Unknown processor type $(uname -m) for Linux 1>&2 ;; esac ;; @@ -127,11 +126,11 @@ SunOS) export WM_LDFLAGS='-mabi=64 -G0' ;; -*) # An unsupported operating system +*) # An unsupported operating system /bin/cat <&2 - Your "$WM_ARCH" operating system is not supported by this release - of OpenFOAM. For further assistance, please contact www.OpenFOAM.com +Your "$WM_ARCH" operating system is unsupported by this OpenFOAM release. +For further assistance, please contact www.OpenFOAM.com USAGE ;; @@ -212,7 +211,7 @@ unset GMP_ARCH_PATH MPFR_ARCH_PATH # Load configured compiler versions, regardless of the compiler type # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler` +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler) case "$WM_COMPILER_TYPE" in system) @@ -227,7 +226,7 @@ OpenFOAM | ThirdParty) mpcDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/${mpc_version:-mpc-system} # Check that the compiler directory can be found - [ -d "$gccDir" ] || cat << GCC_NOT_FOUND 1>&2 + [ -d "$gccDir" ] || /bin/cat << GCC_NOT_FOUND 1>&2 =============================================================================== Warning in $WM_PROJECT_DIR/etc/config.sh/settings: Cannot find '$WM_COMPILER' compiler installation @@ -272,7 +271,7 @@ GCC_NOT_FOUND clangDir=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER_ARCH/$clang_version # Check that the compiler directory can be found - [ -d "$clangDir" ] || cat << CLANG_NOT_FOUND 1>&2 + [ -d "$clangDir" ] || /bin/cat << CLANG_NOT_FOUND 1>&2 =============================================================================== Warning in $WM_PROJECT_DIR/etc/config.sh/settings: Cannot find '$WM_COMPILER' compiler installation diff --git a/etc/config.sh/unset b/etc/config.sh/unset index a636b94a81..2fa155d8c7 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -143,9 +143,9 @@ unset SCOTCH_ARCH_PATH if [ -n "$foamClean" ] then - cleaned=`$foamClean "$PATH" "$foamOldDirs"` && PATH="$cleaned" - cleaned=`$foamClean "$LD_LIBRARY_PATH" "$foamOldDirs"` && LD_LIBRARY_PATH="$cleaned" - cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` && MANPATH="$cleaned" + cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned" + cleaned=$($foamClean "$LD_LIBRARY_PATH" "$foamOldDirs") && LD_LIBRARY_PATH="$cleaned" + cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned" fi @@ -153,7 +153,6 @@ fi [ -n "$MANPATH" ] || unset MANPATH [ -n "$LD_PRELOAD" ] || unset LD_PRELOAD - unset cleaned foamClean foamOldDirs diff --git a/etc/cshrc b/etc/cshrc index d5f315ee16..0352fe8a6d 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -234,8 +234,8 @@ set cleaned=`$foamClean "$LD_LIBRARY_PATH"` if ( $status == 0 ) setenv LD_LIBRARY_PATH $cleaned #- Clean MANPATH (trailing ':' to find system pages) -set cleaned=`$foamClean "$MANPATH"`: -if ( $status == 0 ) setenv MANPATH "$cleaned" +set cleaned=`$foamClean "$MANPATH"` +if ( $status == 0 ) setenv MANPATH "${cleaned}:" #- Clean LD_PRELOAD if ( $?LD_PRELOAD ) then diff --git a/etc/templates/axisymmetricJet/Allrun b/etc/templates/axisymmetricJet/Allrun index 411484a5bf..c5a0b2cea6 100755 --- a/etc/templates/axisymmetricJet/Allrun +++ b/etc/templates/axisymmetricJet/Allrun @@ -4,11 +4,9 @@ cd ${0%/*} || exit 1 # run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -application=`getApplication` - runApplication blockMesh runApplication extrudeMesh -runApplication $application +runApplication $(getApplication) #------------------------------------------------------------------------------ diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/sampleCone b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/sampleCone index e201d5bdc0..a07cffaf68 100755 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/sampleCone +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/sampleCone @@ -44,9 +44,9 @@ done sample $timeOpt SDIR=sets -LSDIR=`ls $SDIR | head -1` -EXAMPLE_FILE=`ls -1 $SDIR/${LSDIR}/* | head -1` -FS=`basename $EXAMPLE_FILE | cut -d_ -f2-` +LSDIR=$(ls $SDIR | head -1) +EXAMPLE_FILE=$(ls -1 $SDIR/${LSDIR}/* | head -1) +FS=$(basename $EXAMPLE_FILE | cut -d_ -f2-) for d in $SDIR/* do diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs index 5566e9f677..6874fa26ef 100755 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/validation/createGraphs @@ -95,7 +95,7 @@ then fi # paths to data -LATESTTIME=`ls $SETSDIR` +LATESTTIME=$(ls $SETSDIR) OFDATAROOT=$SETSDIR/$LATESTTIME EXPTDATAROOT=./exptData diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/externalSolver b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/externalSolver index 201bc16682..040a5a5d66 100755 --- a/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/externalSolver +++ b/tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/externalSolver @@ -82,7 +82,7 @@ do break elif [ -s $lockFile ] then - log "found lock file ${lockFile} containing '$(cat $lockFile)' - waiting" + log "found lock file ${lockFile} containing '$(< $lockFile)' - waiting" else log "found lock file ${lockFile} - waiting" fi diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun index 02e0ed6085..ae838574d9 100755 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allrun @@ -25,8 +25,8 @@ do if [ -e logs/yPlus_0 ] then - yPlus=`awk < logs/yPlus_0 'END{print $2}'` - uPlus=`awk < logs/uPlus_0 'END{print $2}'` + yPlus=$(awk < logs/yPlus_0 'END{print $2}') + uPlus=$(awk < logs/uPlus_0 'END{print $2}') echo "$yPlus $uPlus" >> yPlus_vs_uPlus fi diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles index 0a651b82d4..be3c7aded1 100755 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/patchifyObstacles @@ -1,5 +1,5 @@ #!/bin/sh -#--------------------------------*- C++ -*------------------------------------# +#-----------------------------------------------------------------------------# # ========= | # # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # # \\ / O peration | Version: plus # @@ -77,80 +77,80 @@ for xi in $(seq 1 1 $nx); do # side 1 side=1 - x1=`echo $x $tol | awk '{print $1 - $2}'` - x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'` - y1=`echo $y $tol | awk '{print $1 - $2}'` - y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'` - z1=`echo $z $l $tol | awk '{print $1 + $2 - $3}'` - z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'` + x1=$(echo $x $tol | awk '{print $1 - $2}') + x2=$(echo $x $l $tol | awk '{print $1 + $2 + $3}') + y1=$(echo $y $tol | awk '{print $1 - $2}') + y2=$(echo $y $l $tol | awk '{print $1 + $2 + $3}') + z1=$(echo $z $l $tol | awk '{print $1 + $2 - $3}') + z2=$(echo $z $l $tol | awk '{print $1 + $2 + $3}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 # side 2 side=2 - x1=`echo $x $l $tol | awk '{print $1 + $2 - $3}'` - x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'` - y1=`echo $y $tol | awk '{print $1 - $2}'` - y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'` - z1=`echo $z $tol | awk '{print $1 - $2}'` - z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'` + x1=$(echo $x $l $tol | awk '{print $1 + $2 - $3}') + x2=$(echo $x $l $tol | awk '{print $1 + $2 + $3}') + y1=$(echo $y $tol | awk '{print $1 - $2}') + y2=$(echo $y $l $tol | awk '{print $1 + $2 + $3}') + z1=$(echo $z $tol | awk '{print $1 - $2}') + z2=$(echo $z $l $tol | awk '{print $1 + $2 + $3}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 # side 3 side=3 - x1=`echo $x $tol | awk '{print $1 - $2}'` - x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'` - y1=`echo $y $tol | awk '{print $1 - $2}'` - y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'` - z1=`echo $z $tol | awk '{print $1 - $2}'` - z2=`echo $z $tol | awk '{print $1 + $2}'` + x1=$(echo $x $tol | awk '{print $1 - $2}') + x2=$(echo $x $l $tol | awk '{print $1 + $2 + $3}') + y1=$(echo $y $tol | awk '{print $1 - $2}') + y2=$(echo $y $l $tol | awk '{print $1 + $2 + $3}') + z1=$(echo $z $tol | awk '{print $1 - $2}') + z2=$(echo $z $tol | awk '{print $1 + $2}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 # side 4 side=4 - x1=`echo $x $tol | awk '{print $1 - $2}'` - x2=`echo $x $tol | awk '{print $1 + $2}'` - y1=`echo $y $tol | awk '{print $1 - $2}'` - y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'` - z1=`echo $z $tol | awk '{print $1 - $2}'` - z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'` + x1=$(echo $x $tol | awk '{print $1 - $2}') + x2=$(echo $x $tol | awk '{print $1 + $2}') + y1=$(echo $y $tol | awk '{print $1 - $2}') + y2=$(echo $y $l $tol | awk '{print $1 + $2 + $3}') + z1=$(echo $z $tol | awk '{print $1 - $2}') + z2=$(echo $z $l $tol | awk '{print $1 + $2 + $3}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 # side 5 side=5 - x1=`echo $x $tol | awk '{print $1 - $2}'` - x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'` - y1=`echo $y $l $tol | awk '{print $1 + $2 - $3}'` - y2=`echo $y $l $tol | awk '{print $1 + $2 + $3}'` - z1=`echo $z $tol | awk '{print $1 - $2}'` - z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'` + x1=$(echo $x $tol | awk '{print $1 - $2}') + x2=$(echo $x $l $tol | awk '{print $1 + $2 + $3}') + y1=$(echo $y $l $tol | awk '{print $1 + $2 - $3}') + y2=$(echo $y $l $tol | awk '{print $1 + $2 + $3}') + z1=$(echo $z $tol | awk '{print $1 - $2}') + z2=$(echo $z $l $tol | awk '{print $1 + $2 + $3}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 # side 6 side=6 - x1=`echo $x $tol | awk '{print $1 - $2}'` - x2=`echo $x $l $tol | awk '{print $1 + $2 + $3}'` - y1=`echo $y $tol | awk '{print $1 - $2}'` - y2=`echo $y $tol | awk '{print $1 + $2}'` - z1=`echo $z $tol | awk '{print $1 - $2}'` - z2=`echo $z $l $tol | awk '{print $1 + $2 + $3}'` + x1=$(echo $x $tol | awk '{print $1 - $2}') + x2=$(echo $x $l $tol | awk '{print $1 + $2 + $3}') + y1=$(echo $y $tol | awk '{print $1 - $2}') + y2=$(echo $y $tol | awk '{print $1 + $2}') + z1=$(echo $z $tol | awk '{print $1 - $2}') + z2=$(echo $z $l $tol | awk '{print $1 + $2 + $3}') addToFaceSet cube${pad}${n}_side${side} $x1 $x2 $y1 $y2 $z1 $z2 n=$((n+1)) - z=`echo $z $offset | awk '{print $1 + $2}'` + z=$(echo $z $offset | awk '{print $1 + $2}') done - y=`echo $y $offset | awk '{print $1 + $2}'` + y=$(echo $y $offset | awk '{print $1 + $2}') done - x=`echo $x $offset | awk '{print $1 + $2}'` + x=$(echo $x $offset | awk '{print $1 + $2}') done echo "cellSet cubeFacesCells new faceToCell cubeFaceSet owner" >> $tmpSetSet echo "faceZoneSet cubeFaces new setsToFaceZone cubeFaceSet cubeFacesCells" >> $tmpSetSet echo "processing floor" -floorMax=`echo 1 $tol | awk '{print $1 + $2}'` +floorMax=$(echo 1 $tol | awk '{print $1 + $2}') createSetsAndZone Floor -$tol $floorMax -$tol $floorMax -$tol $tol echo "cellSet floorCells new faceToCell FloorFaces owner" >> $tmpSetSet echo "faceZoneSet floorFaces new setsToFaceZone FloorFaces floorCells" >> $tmpSetSet diff --git a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh index f476661eb3..92d09ceaef 100755 --- a/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh +++ b/tutorials/multiphase/interFoam/RAS/waterChannel/Allmesh @@ -4,17 +4,14 @@ cd ${0%/*} || exit 1 # Run from this directory # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions -application=$(getApplication) - runApplication blockMesh echo "Creating channel" -i=1 -while [ "$i" -lt 3 ] ; do +for i in 1 2 +do cp system/extrudeMeshDict.${i} system/extrudeMeshDict echo "Running extrudeMesh, instance" ${i} extrudeMesh > log.extrudeMesh.${i} - i=`expr $i + 1` done #------------------------------------------------------------------------------ From 1ed5b35049ba7d3ac059eba851d7287ff50a2df0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 20 Feb 2017 10:47:45 +0100 Subject: [PATCH 07/18] CONFIG: pass-through icc compiler choice for KNL, add gcc 6.3.0 - bump ADIOS version to 1.11.1 --- etc/bashrc | 4 ++-- etc/config.csh/ADIOS | 4 ++-- etc/config.csh/compiler | 7 +++++-- etc/config.sh/ADIOS | 4 ++-- etc/config.sh/compiler | 7 +++++-- etc/cshrc | 4 ++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 7eeb3c209a..94e01d6a18 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -3,7 +3,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) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -61,7 +61,7 @@ export FOAM_INST_DIR export WM_COMPILER_TYPE=system #- Compiler: -# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc +# WM_COMPILER= Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | Clang | Icc | IccKNL export WM_COMPILER=Gcc unset WM_COMPILER_ARCH WM_COMPILER_LIB_ARCH diff --git a/etc/config.csh/ADIOS b/etc/config.csh/ADIOS index c53511fd8e..efec3f760f 100644 --- a/etc/config.csh/ADIOS +++ b/etc/config.csh/ADIOS @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -48,7 +48,7 @@ # #------------------------------------------------------------------------------ -set adios_version=ADIOS-1.11.0 +set adios_version=ADIOS-1.11.1 setenv ADIOS_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version #------------------------------------------------------------------------------ diff --git a/etc/config.csh/compiler b/etc/config.csh/compiler index 751c5bada4..18b2f226c8 100644 --- a/etc/config.csh/compiler +++ b/etc/config.csh/compiler @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -63,6 +63,9 @@ case ThirdParty: case Gcc62: set gcc_version=gcc-6.2.0 breaksw + case Gcc63: + set gcc_version=gcc-6.3.0 + breaksw case Clang: set clang_version=llvm-3.7.0 # set clang_version=llvm-3.8.0 @@ -84,7 +87,7 @@ case Clang: setenv WM_CC 'clang' setenv WM_CXX 'clang++' breaksw -case Icc: +case Icc*: setenv WM_CC 'icc' setenv WM_CXX 'icpc' breaksw diff --git a/etc/config.sh/ADIOS b/etc/config.sh/ADIOS index 898a2bc28d..db7b3534a6 100644 --- a/etc/config.sh/ADIOS +++ b/etc/config.sh/ADIOS @@ -2,7 +2,7 @@ # ========= | # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | -# \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. +# \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. # \\/ M anipulation | #------------------------------------------------------------------------------ # License @@ -47,7 +47,7 @@ # #------------------------------------------------------------------------------ -adios_version=ADIOS-1.11.0 +adios_version=ADIOS-1.11.1 export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version #------------------------------------------------------------------------------ diff --git a/etc/config.sh/compiler b/etc/config.sh/compiler index de903a0767..1f9907710b 100644 --- a/etc/config.sh/compiler +++ b/etc/config.sh/compiler @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -62,6 +62,9 @@ ThirdParty) Gcc62) gcc_version=gcc-6.2.0 ;; + Gcc63) + gcc_version=gcc-6.3.0 + ;; Clang) clang_version=llvm-3.7.0 # clang_version=llvm-3.8.0 @@ -84,7 +87,7 @@ Clang) export WM_CC='clang' export WM_CXX='clang++' ;; -Icc) +Icc*) export WM_CC='icc' export WM_CXX='icpc' ;; diff --git a/etc/cshrc b/etc/cshrc index 0352fe8a6d..3e644242c2 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -60,7 +60,7 @@ setenv FOAM_INST_DIR `lsof +p $$ |& grep -oE '/.*'$WM_PROJECT'[^/]*/etc/cshrc' | setenv WM_COMPILER_TYPE system #- Compiler: -# WM_COMPILER = Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-2] | Clang | Icc +# WM_COMPILER= Gcc | Gcc4[8-9] | Gcc5[1-4] | Gcc6[1-3] | Clang | Icc | IccKNL setenv WM_COMPILER Gcc setenv WM_COMPILER_ARCH # defined but empty unsetenv WM_COMPILER_LIB_ARCH From 403520cee5cd1595eaba6a4eb47def6844b02a8e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 20 Feb 2017 10:57:30 +0100 Subject: [PATCH 08/18] ENH: add tags marking user configuration sections - as per bashrc,cshrc delimit with "# USER EDITABLE PART" "# END OF (NORMAL) USER EDITABLE PART" this can help simplify any patching for system-building scripts etc. --- etc/config.csh/ADIOS | 2 ++ etc/config.csh/CGAL | 2 ++ etc/config.csh/FFTW | 3 ++- etc/config.csh/paraview | 3 ++- etc/config.csh/vtk | 2 ++ etc/config.sh/ADIOS | 2 ++ etc/config.sh/CGAL | 2 ++ etc/config.sh/FFTW | 3 ++- etc/config.sh/ccmio | 2 ++ etc/config.sh/gperftools | 3 ++- etc/config.sh/metis | 3 ++- etc/config.sh/paraview | 3 ++- etc/config.sh/scotch | 3 ++- etc/config.sh/vtk | 2 ++ 14 files changed, 28 insertions(+), 7 deletions(-) diff --git a/etc/config.csh/ADIOS b/etc/config.csh/ADIOS index efec3f760f..64dce79c5a 100644 --- a/etc/config.csh/ADIOS +++ b/etc/config.csh/ADIOS @@ -47,10 +47,12 @@ # be used during the build process. See further notes there. # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade set adios_version=ADIOS-1.11.1 setenv ADIOS_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if ($?FOAM_VERBOSE && $?prompt) then echo "Using adios ($adios_version) -> $ADIOS_ARCH_PATH" diff --git a/etc/config.csh/CGAL b/etc/config.csh/CGAL index 0caa0c51d7..aab320bcab 100644 --- a/etc/config.csh/CGAL +++ b/etc/config.csh/CGAL @@ -49,6 +49,7 @@ # be used during the build process. # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade set boost_version=boost_1_62_0 set cgal_version=CGAL-4.9 @@ -56,6 +57,7 @@ set cgal_version=CGAL-4.9 setenv BOOST_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version setenv CGAL_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if ($?FOAM_VERBOSE && $?prompt) then echo "Using boost ($boost_version) -> $BOOST_ARCH_PATH" diff --git a/etc/config.csh/FFTW b/etc/config.csh/FFTW index 515c429e66..d2e2c82529 100644 --- a/etc/config.csh/FFTW +++ b/etc/config.csh/FFTW @@ -47,11 +47,12 @@ # be used during the build process. # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade set fftw_version=fftw-3.3.5 - setenv FFTW_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if ($?FOAM_VERBOSE && $?prompt) then echo "Using fftw ($fftw_version) -> $FFTW_ARCH_PATH" diff --git a/etc/config.csh/paraview b/etc/config.csh/paraview index b215811798..d1e306c522 100644 --- a/etc/config.csh/paraview +++ b/etc/config.csh/paraview @@ -50,12 +50,13 @@ # unsetenv ParaView_VERSION # avoid using ThirdParty settings # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade setenv ParaView_VERSION 5.0.1 setenv ParaView_MAJOR detect # Automatically determine major version - set cmake_version=cmake-system +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if ( ! $?ParaView_DIR ) setenv ParaView_DIR diff --git a/etc/config.csh/vtk b/etc/config.csh/vtk index e09a045570..27421c4090 100644 --- a/etc/config.csh/vtk +++ b/etc/config.csh/vtk @@ -41,6 +41,7 @@ # See the BuildIssues.txt about problems that can be encountered when using # the 'plain' VTK sources. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade set vtk_version=VTK-7.1.0 set mesa_version=mesa-13.0.1 @@ -48,6 +49,7 @@ set mesa_version=mesa-13.0.1 setenv VTK_DIR $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$vtk_version setenv MESA_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mesa_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if ($?FOAM_VERBOSE && $?prompt) then echo "Using vtk ($vtk_version) -> $VTK_DIR" diff --git a/etc/config.sh/ADIOS b/etc/config.sh/ADIOS index db7b3534a6..15fd0169f2 100644 --- a/etc/config.sh/ADIOS +++ b/etc/config.sh/ADIOS @@ -46,10 +46,12 @@ # for the appropriate MPI. Eg, libadios_openmpi-system # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade adios_version=ADIOS-1.11.1 export ADIOS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$adios_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/etc/config.sh/CGAL b/etc/config.sh/CGAL index 5f9c64b1b9..837d0e438d 100644 --- a/etc/config.sh/CGAL +++ b/etc/config.sh/CGAL @@ -48,6 +48,7 @@ # - boost_version / cgal_version variables are retained. # - the LD_LIBRARY_PATH is not adjusted. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade boost_version=boost_1_62_0 cgal_version=CGAL-4.9 @@ -55,6 +56,7 @@ cgal_version=CGAL-4.9 export BOOST_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$boost_version export CGAL_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cgal_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/etc/config.sh/FFTW b/etc/config.sh/FFTW index e3a6fee2fd..73b99534a3 100644 --- a/etc/config.sh/FFTW +++ b/etc/config.sh/FFTW @@ -46,11 +46,12 @@ # - fftw_version variable is retained. # - the LD_LIBRARY_PATH is not adjusted. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade fftw_version=fftw-3.3.5 - export FFTW_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$fftw_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/etc/config.sh/ccmio b/etc/config.sh/ccmio index 6bd6aa42ac..28e7334e8e 100644 --- a/etc/config.sh/ccmio +++ b/etc/config.sh/ccmio @@ -35,8 +35,10 @@ # A csh version is not needed, since the values here are only sourced # during the wmake process #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade ccmio_version=libccmio-2.6.1 export CCMIO_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$ccmio_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/etc/config.sh/gperftools b/etc/config.sh/gperftools index d42b46df21..da49c76167 100644 --- a/etc/config.sh/gperftools +++ b/etc/config.sh/gperftools @@ -46,11 +46,12 @@ # - gperftools_version variable are retained. # - the LD_LIBRARY_PATH and PATH are not adjusted. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade gperftools_version=gperftools-2.5 - GPERFTOOLS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$gperftools_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/etc/config.sh/metis b/etc/config.sh/metis index 54ecba0466..403730b1bf 100644 --- a/etc/config.sh/metis +++ b/etc/config.sh/metis @@ -52,9 +52,10 @@ # by creating an empty one with the same name at a user or site location. # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade METIS_VERSION=metis-5.1.0 - export METIS_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$METIS_VERSION +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/etc/config.sh/paraview b/etc/config.sh/paraview index 3db9b49cf7..b1a4f245a8 100644 --- a/etc/config.sh/paraview +++ b/etc/config.sh/paraview @@ -53,12 +53,13 @@ # When _foamAddLib is unset (eg, called from makeParaView or from foamPV): # - the ParaView_VERSION variable is retained. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade ParaView_VERSION=5.0.1 ParaView_MAJOR=detect # Automatically determine major version - cmake_version=cmake-system +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ # Clean PATH and LD_LIBRARY_PATH diff --git a/etc/config.sh/scotch b/etc/config.sh/scotch index bb5e12bced..7c8cb13587 100644 --- a/etc/config.sh/scotch +++ b/etc/config.sh/scotch @@ -52,9 +52,10 @@ # by creating an empty one with the same name at a user or site location. # #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade SCOTCH_VERSION=scotch_6.0.3 - export SCOTCH_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/$SCOTCH_VERSION +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ diff --git a/etc/config.sh/vtk b/etc/config.sh/vtk index e4295df927..e4dc84c90f 100644 --- a/etc/config.sh/vtk +++ b/etc/config.sh/vtk @@ -41,6 +41,7 @@ # See the BuildIssues.txt about problems that can be encountered when using # the 'plain' VTK sources. #------------------------------------------------------------------------------ +# USER EDITABLE PART: Changes made here may be lost with the next upgrade vtk_version=VTK-7.1.0 mesa_version=mesa-13.0.1 @@ -48,6 +49,7 @@ mesa_version=mesa-13.0.1 export VTK_DIR=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$vtk_version export MESA_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$mesa_version +# END OF (NORMAL) USER EDITABLE PART #------------------------------------------------------------------------------ if [ "$FOAM_VERBOSE" -a "$PS1" ] then From a6d37e5728bb121d222706fb0f6d59a1d5d1df0b Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 21 Feb 2017 12:56:27 +0100 Subject: [PATCH 09/18] COMP: silence some compiler warnings - remove some spurious regExp includes --- BuildIssues.txt | 2 +- .../containers/Lists/FixedList/FixedListIO.C | 2 +- src/OpenFOAM/db/dictionary/dictionaryIO.C | 1 - src/OpenFOAM/global/profiling/profiling.H | 8 ++++++-- .../derived/turbulentDFSEMInlet/eddy/eddy.H | 12 ++++++++++++ .../writers/ensight/ensightSurfaceWriterTemplates.C | 1 - src/triSurface/triSurface/triSurface.H | 2 +- 7 files changed, 21 insertions(+), 7 deletions(-) diff --git a/BuildIssues.txt b/BuildIssues.txt index 7c5e80d956..2cd8ff0124 100644 --- a/BuildIssues.txt +++ b/BuildIssues.txt @@ -22,7 +22,7 @@ VTK --- If using the runTimePostProcessing to create on-the-fly images, you -can either simply just compile ParaView-5.0.1 and these libraries will +can simply just compile ParaView-5.0.1 and these libraries will be used. If you elect to use a separate VTK compilation (for example for diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C index cac3177014..895e373488 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListIO.C @@ -100,7 +100,7 @@ Foam::Ostream& Foam::FixedList::writeList else if ( Size <= 1 || !shortListLen - || (Size <= shortListLen && contiguous()) + || (Size <= unsigned(shortListLen) && contiguous()) ) { // Write start delimiter diff --git a/src/OpenFOAM/db/dictionary/dictionaryIO.C b/src/OpenFOAM/db/dictionary/dictionaryIO.C index 081068488f..231e3bc44b 100644 --- a/src/OpenFOAM/db/dictionary/dictionaryIO.C +++ b/src/OpenFOAM/db/dictionary/dictionaryIO.C @@ -26,7 +26,6 @@ License #include "dictionary.H" #include "IFstream.H" #include "inputModeEntry.H" -#include "regExp.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/profiling/profiling.H b/src/OpenFOAM/global/profiling/profiling.H index c6872f8e2b..0bb29a7f42 100644 --- a/src/OpenFOAM/global/profiling/profiling.H +++ b/src/OpenFOAM/global/profiling/profiling.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2009-2016 Bernhard Gschaider - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2107 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -225,6 +225,10 @@ public: }; +// Forward declaration of friend functions and operators +Ostream& operator<<(Ostream& os, const profiling::Information& info); + + /*---------------------------------------------------------------------------*\ Class profiling::Information Declaration \*---------------------------------------------------------------------------*/ @@ -385,7 +389,7 @@ public: // IOstream Operators - friend Ostream& operator<<(Ostream&, const Information&); + friend Ostream& operator<<(Ostream& os, const Information& info); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H index e2f6be1405..5bd0feb0f1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/eddy/eddy.H @@ -49,6 +49,18 @@ SourceFiles namespace Foam { +// Forward declaration of classes +class Istream; +class Ostream; + +// Forward declaration of friend functions and operators +class eddy; +bool operator==(const eddy& a, const eddy& b); +bool operator!=(const eddy& a, const eddy& b); +Istream& operator>>(Istream& is, eddy& e); +Ostream& operator<<(Ostream& os, const eddy& e); + + /*---------------------------------------------------------------------------*\ Class eddy Declaration \*---------------------------------------------------------------------------*/ diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C index 34d218dac8..660920dd42 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterTemplates.C @@ -31,7 +31,6 @@ License #include "ensightSerialOutput.H" #include "ensightPTraits.H" #include "OStringStream.H" -#include "regExp.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/triSurface/triSurface/triSurface.H b/src/triSurface/triSurface/triSurface.H index d6debc7b3a..e320bbfdfd 100644 --- a/src/triSurface/triSurface/triSurface.H +++ b/src/triSurface/triSurface/triSurface.H @@ -55,7 +55,7 @@ class surfZone; // Forward declaration of friend functions and operators class triSurface; - +Istream& operator>>(Istream&, triSurface&); Ostream& operator<<(Ostream&, const triSurface&); From 9e2e111518eaeb726bba5e2908a37b315c8ca3f8 Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 21 Feb 2017 19:19:04 +0100 Subject: [PATCH 10/18] STYLE: adjust ordering of 'find' command arguments - use -name test before -type test to avoid calling stat(2) on every file. - use -delete instead of -exec rm to avoid forking --- bin/foamAllHC | 2 +- bin/foamPack | 2 +- bin/foamSequenceVTKFiles | 2 +- bin/rmcore | 5 +++-- bin/rm~all | 5 +++-- tutorials/Allclean | 12 ++++++++---- tutorials/Allrun | 2 +- tutorials/Alltest | 6 +++--- .../pisoFoam/LES/motorBike/motorBike/Allrun | 2 +- .../incompressible/simpleFoam/turbineSiting/Allrun | 2 +- wmake/scripts/makeFiles | 2 +- wmake/wclean | 4 ++-- wmake/wcleanLnIncludeAll | 2 +- wmake/wcleanPlatform | 2 +- wmake/wmakeLnInclude | 2 +- wmake/wrmdep | 11 +++++------ wmake/wrmo | 2 +- 17 files changed, 35 insertions(+), 30 deletions(-) diff --git a/bin/foamAllHC b/bin/foamAllHC index e6ebd3ac90..5c6797d52e 100755 --- a/bin/foamAllHC +++ b/bin/foamAllHC @@ -32,7 +32,7 @@ if [ "$#" -gt 0 ] then - find . -name "*.[CHL]" -exec $1 {} \; -print + find . -name "*.[CHL]" -type f -exec $1 {} \; -print fi #------------------------------------------------------------------------------ diff --git a/bin/foamPack b/bin/foamPack index 212d0d5e5a..3e0a994e68 100755 --- a/bin/foamPack +++ b/bin/foamPack @@ -119,7 +119,7 @@ else ( cd $packDir && git archive --format=tar --prefix=$packDir/ HEAD) > $packBase.tar && echo "add in time-stamp and lnInclude directories" 1>&2 && - tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build $(find -H $packDir -type d -name lnInclude) && + tar cf $packBase.tar2 $packDir/.timeStamp $packDir/.build $(find -H $packDir -name lnInclude -type d) && tar Af $packBase.tar $packBase.tar2 && echo "gzip tar file" 1>&2 && diff --git a/bin/foamSequenceVTKFiles b/bin/foamSequenceVTKFiles index 86e5122283..8ebb755ace 100755 --- a/bin/foamSequenceVTKFiles +++ b/bin/foamSequenceVTKFiles @@ -93,7 +93,7 @@ if [ ! -d $DIR ]; then exit 0 fi -FILES=$(find $DIR -type f -name *vtk) +FILES=$(find $DIR -name '*.vtk' -type f) NAMES=$(for f in $FILES; do basename $f .vtk; done | sort -u) if [ -d $OUT ]; then diff --git a/bin/rmcore b/bin/rmcore index 046758cd75..8dde81b3cc 100755 --- a/bin/rmcore +++ b/bin/rmcore @@ -35,6 +35,7 @@ then set -- . elif [ "$1" = "-h" -o "$1" = "-help" ] then + exec 1>&2 echo "Usage: ${0##*/} [dir1] .. [dirN]" echo " remove all core files" exit 1 @@ -45,8 +46,8 @@ for i do if [ -d "$i" ] then - echo "removing all core files: $i" - find $i \( -type f -name 'core' -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -print | xargs -t rm 2>/dev/null + echo "removing all core files: $i" 1>&2 + find $i \( -name core -o -name 'core.[1-9]*' -o -name 'vgcore.*' \) -type f -delete else echo "no directory: $i" 1>&2 fi diff --git a/bin/rm~all b/bin/rm~all index adbd5c6601..c4fa742f89 100755 --- a/bin/rm~all +++ b/bin/rm~all @@ -35,6 +35,7 @@ then set -- . elif [ "$1" = "-h" -o "$1" = "-help" ] then + exec 1>&2 echo "Usage: ${0##*/} [dir1] .. [dirN]" echo " remove all *~ files" exit 1 @@ -45,8 +46,8 @@ for i do if [ -d "$i" ] then - echo "removing all *~ files: $i" - find $i \( -name '*~' -o -name '.*~' \) -print | xargs -t rm 2>/dev/null + echo "removing all *~ files: $i" 1>&2 + find $i \( -name '*~' -o -name '.*~' \) -type f -delete -print else echo "no directory: $i" 1>&2 fi diff --git a/tutorials/Allclean b/tutorials/Allclean index b66c19975f..0eea9fb549 100755 --- a/tutorials/Allclean +++ b/tutorials/Allclean @@ -4,10 +4,14 @@ cd ${0%/*} || exit 1 # Run from this directory echo "--------" echo "Cleaning tutorials ..." echo "Removing backup files" -find . -type f \( -name "*~" -o -name "*.bak" \) -exec rm {} \; -find . \( -name core -o -name 'core.[1-9]*' \) -exec rm {} \; -find . \( -name '*.pvs' -o -name '*.OpenFOAM' \) -exec rm {} \; -rm logs testLoopReport > /dev/null 2>&1 + +find . \( \ + -name '*~' -o -name '*.bak' \ + -name core -o -name 'core.[1-9]*' \ + -name '*.pvs' -o -name '*.OpenFOAM' \ + \) -type f -delete + +rm -f logs testLoopReport > /dev/null 2>&1 foamCleanTutorials cases diff --git a/tutorials/Allrun b/tutorials/Allrun index 8ecef75019..28e4fe6a45 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -138,7 +138,7 @@ do [ -d $appDir ] || continue echo -n " $appDir..." 1>&2 - logs=$(find -L $appDir -type f -name 'log.*') + logs=$(find -L $appDir -name 'log.*' -type f) if [ -n "$logs" ] then echo 1>&2 diff --git a/tutorials/Alltest b/tutorials/Alltest index ac39728960..d122fd25e8 100755 --- a/tutorials/Alltest +++ b/tutorials/Alltest @@ -211,7 +211,7 @@ fi echo "Modifying the controlDicts to run only one time step" 1>&2 cd ${TEST_RUN_DIR} || exit 1 -for CD in $(find . -type f -name "controlDict*") +for CD in $(find . -name "controlDict*" -type f) do mv ${CD} ${CD}.orig sed \ @@ -225,7 +225,7 @@ done if [ "$DEFAULT_SCHEMES" = true ] then echo "Modifying the fvSchemes to contain only default schemes" 1>&2 - for FV_SC in $(find . -type f -name fvSchemes) + for FV_SC in $(find . -name fvSchemes -type f) do for S in $FV_SCHEMES do @@ -253,7 +253,7 @@ do do rm $SCHEMES_TEMP $SOLVERS_TEMP > /dev/null 2>&1 echo " ${ST}" >> $SCHEMES_FILE - for LOG in $(find ${APP} -type f -name "log.${APP}") + for LOG in $(find ${APP} -name "log.${APP}" -type f) do for S in $(grep ${ST} ${LOG} | cut -d" " -f4) do diff --git a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun index 43ab19017d..b3fbef3291 100755 --- a/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun +++ b/tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/Allrun @@ -17,7 +17,7 @@ runApplication decomposePar -decomposeParDict system/decomposeParDict.hierarchic # \cp system/decomposeParDict.ptscotch system/decomposeParDict runParallel snappyHexMesh -decomposeParDict system/decomposeParDict.ptscotch -profiling -overwrite -find . -type f -iname "*level*" -exec rm {} \; +find . -iname '*level*' -type f -delete #- Set the initial fields restore0Dir -processor diff --git a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun index 9f85d96372..fd62abc0fa 100755 --- a/tutorials/incompressible/simpleFoam/turbineSiting/Allrun +++ b/tutorials/incompressible/simpleFoam/turbineSiting/Allrun @@ -14,7 +14,7 @@ runApplication decomposePar \cp system/decomposeParDict.ptscotch system/decomposeParDict runParallel snappyHexMesh -overwrite -find . -type f -iname "*level*" -exec rm {} \; +find . -iname '*level*' -type f -delete # - Set the initial fields restore0Dir -processor diff --git a/wmake/scripts/makeFiles b/wmake/scripts/makeFiles index 78b7fffed3..09b487219a 100755 --- a/wmake/scripts/makeFiles +++ b/wmake/scripts/makeFiles @@ -56,7 +56,7 @@ do done >> Make/files [ -s Make/files ] && echo >> Make/files -for file in $(find . -type f -name "*.[cCylLfF]" -print) +for file in $(find . -name "*.[cCylLfF]" -type f -print) do pathName=$(echo ${file%/*} | $dirToString -strip) diff --git a/wmake/wclean b/wmake/wclean index 71c8cd096a..1ed0cf21ac 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -153,10 +153,10 @@ then # Get sub-directories avoiding particular directories for dir in $(find . -mindepth 1 -maxdepth 1 \ - -type d \( -name .git -prune -o -print \) ) + -name .git -prune -o -type d -print) do echo " searching: $dir" - find $dir -depth -type d -empty -exec rmdir {} \; -print + find $dir -depth -empty -type d -delete -print done # Second pass: clean up object directories with WM_PROJECT_DIR that don't diff --git a/wmake/wcleanLnIncludeAll b/wmake/wcleanLnIncludeAll index 4ac19b6816..3a4510874a 100755 --- a/wmake/wcleanLnIncludeAll +++ b/wmake/wcleanLnIncludeAll @@ -58,7 +58,7 @@ do if [ -d "$dir" ] then echo "removing lnInclude directories: $dir" - find $dir -depth -type d -name lnInclude -exec rm -rf {} \; + find $dir -depth -name lnInclude -type d -delete else echo "no directory: $dir" 1>&2 fi diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform index 18b4d5b2c3..34767739b7 100755 --- a/wmake/wcleanPlatform +++ b/wmake/wcleanPlatform @@ -89,7 +89,7 @@ then rm -rf platforms/* echo "Removing lnInclude directories" - find . -depth -type d \( -name lnInclude \) | xargs rm -rf + find . -depth -name lnInclude -type d -delete tutorials/Allclean else diff --git a/wmake/wmakeLnInclude b/wmake/wmakeLnInclude index 0b338ac742..edfeb540e1 100755 --- a/wmake/wmakeLnInclude +++ b/wmake/wmakeLnInclude @@ -149,7 +149,7 @@ fi #------------------------------------------------------------------------------ # Remove any broken links first (this helps when file locations have moved) #------------------------------------------------------------------------------ -find -L . -type l | xargs rm -f +find -L . -type l -delete #------------------------------------------------------------------------------ diff --git a/wmake/wrmdep b/wmake/wrmdep index 1d37a1564c..55cddd68c6 100755 --- a/wmake/wrmdep +++ b/wmake/wrmdep @@ -152,15 +152,14 @@ files) if [ "$#" -eq 0 ] then echo "removing all .dep files ..." - find $objectsDir -type f -name '*.dep' -print | xargs -t rm 2>/dev/null + find $objectsDir -name '*.dep' -type f -delete -print else echo "removing .o files corresponding to" echo " $@ ..." for file do - find $objectsDir -type f -name '*.dep' \ - -exec grep -q "$file" '{}' \; \ - -exec rm '{}' \; -print + find $objectsDir -name '*.dep' -type f \ + -exec grep -q "$file" {} \; -delete -print done fi ;; @@ -183,7 +182,7 @@ oldFolders) continue fi - find $objectsDir -type f -name '*.dep' -print | while read depFile + find $objectsDir -name '*.dep' -type f -print | while read depFile do sourceFile=$(depToSource $depFile) @@ -205,7 +204,7 @@ updateMode) fi echo "Removing dep files corresponding to source files that no longer exist..." - fileNameList=$(find -L src applications -type l -name '*.[CHL]') + fileNameList=$(find -L src applications -name '*.[CHL]' -type l) for filePathAndName in $fileNameList do diff --git a/wmake/wrmo b/wmake/wrmo index 489e179736..ee4e1ce523 100755 --- a/wmake/wrmo +++ b/wmake/wrmo @@ -103,7 +103,7 @@ fi if [ "$#" -eq 0 ] then echo "removing all .o files ..." - find $objectsDir -type f -name '*.o' -print | xargs -t rm 2>/dev/null + find $objectsDir -name '*.o' -type f -delete else echo "removing .o files corresponding to" echo " $@ ..." From 32a78d12e267a6ddf2d9d0c273e13879ecf4707a Mon Sep 17 00:00:00 2001 From: mark Date: Tue, 21 Feb 2017 19:40:35 +0100 Subject: [PATCH 11/18] ENH: wclean all now finds Allwclean files too (issue #408) - this may still need more testing, but the basic idea is to find directories with 'Allwclean' or 'Make' and process them (once!) --- wmake/wclean | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wmake/wclean b/wmake/wclean index 1ed0cf21ac..0f3e5eb8de 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -231,16 +231,18 @@ then exit $? fi - # For all sub-directories containing a 'Make' directory - for dir in $(find . -type d -name Make) + # For all directories containing a 'Make' directory, or an 'Allwclean' file + for dir in $(find . -name Allwclean -o -name Make) + do + echo ${dir%/*} + done | sort | uniq | while read dir do - dir=${dir%/*} # Parent directory containing the Make directory - # Use Allwclean if it exists, otherwise wclean if [ -e "$dir/Allwclean" ] then $dir/Allwclean - else + elif [ -d "$dir/Make" ] + then $0 $dir fi done From c1ca2f4a381384db3b4b15343ea93093cda27638 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 01:07:10 +0100 Subject: [PATCH 12/18] BUG: missing chdir in Allwclean for wallFunctionTable STYLE: improve consistency in Allwclean scripts --- .../solvers/lagrangian/DPMFoam/Allwclean | 5 ++- .../solvers/lagrangian/DPMFoam/Allwmake | 2 + .../multiphase/MPPICInterFoam/Allwclean | 2 +- .../miscellaneous/foamHelp/Allwclean | 1 - .../graphics/PVReaders/Allwclean | 3 -- .../graphics/PVReaders/Allwmake | 4 -- .../preProcessing/wallFunctionTable/Allwclean | 2 + src/Pstream/Allwclean | 23 +++++------ src/parallel/decompose/Allwclean | 38 +++++-------------- src/regionModels/Allwclean | 11 +++--- wmake/wclean | 15 ++++---- 11 files changed, 40 insertions(+), 66 deletions(-) diff --git a/applications/solvers/lagrangian/DPMFoam/Allwclean b/applications/solvers/lagrangian/DPMFoam/Allwclean index 158a56c8f3..f953f59874 100755 --- a/applications/solvers/lagrangian/DPMFoam/Allwclean +++ b/applications/solvers/lagrangian/DPMFoam/Allwclean @@ -1,7 +1,8 @@ #!/bin/sh - -cd ${0%/*} || exit 1 +cd ${0%/*} || exit 1 # Run from this directory wclean libso DPMTurbulenceModels wclean wclean MPPICFoam + +#------------------------------------------------------------------------------ diff --git a/applications/solvers/lagrangian/DPMFoam/Allwmake b/applications/solvers/lagrangian/DPMFoam/Allwmake index 1f021bfc2f..2af858f6bb 100755 --- a/applications/solvers/lagrangian/DPMFoam/Allwmake +++ b/applications/solvers/lagrangian/DPMFoam/Allwmake @@ -8,3 +8,5 @@ wmake $targetType DPMTurbulenceModels wmake $targetType wmake $targetType MPPICFoam + +#------------------------------------------------------------------------------ diff --git a/applications/solvers/multiphase/MPPICInterFoam/Allwclean b/applications/solvers/multiphase/MPPICInterFoam/Allwclean index 12d384e356..79ee0feb22 100755 --- a/applications/solvers/multiphase/MPPICInterFoam/Allwclean +++ b/applications/solvers/multiphase/MPPICInterFoam/Allwclean @@ -1,5 +1,5 @@ #!/bin/sh -cd ${0%/*} || exit 1 # run from this directory +cd ${0%/*} || exit 1 # Run from this directory wclean libso CompressibleTwoPhaseMixtureTurbulenceModels wclean diff --git a/applications/utilities/miscellaneous/foamHelp/Allwclean b/applications/utilities/miscellaneous/foamHelp/Allwclean index 68cf4d8151..b34d18b24a 100755 --- a/applications/utilities/miscellaneous/foamHelp/Allwclean +++ b/applications/utilities/miscellaneous/foamHelp/Allwclean @@ -4,5 +4,4 @@ cd ${0%/*} || exit 1 # Run from this directory wclean libso helpTypes wclean - #------------------------------------------------------------------------------ diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwclean b/applications/utilities/postProcessing/graphics/PVReaders/Allwclean index 6614154374..54808b94b1 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwclean +++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwclean @@ -5,7 +5,4 @@ wclean libso foamPv PVblockMeshReader/Allwclean PVFoamReader/Allwclean -# remove dummy directory (see Allwmake) -rmdir Make 2>/dev/null - #------------------------------------------------------------------------------ diff --git a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake index 13eb3a9470..d80b89f34d 100755 --- a/applications/utilities/postProcessing/graphics/PVReaders/Allwmake +++ b/applications/utilities/postProcessing/graphics/PVReaders/Allwmake @@ -24,10 +24,6 @@ case "$major" in wmakeLibPv foamPv PVblockMeshReader/Allwmake $targetType $* PVFoamReader/Allwmake $targetType $* - - # Dummy directory to trigger proper 'wclean all' behaviour - # - the Allwclean will otherwise not be used - mkdir -p Make ) fi ;; diff --git a/applications/utilities/preProcessing/wallFunctionTable/Allwclean b/applications/utilities/preProcessing/wallFunctionTable/Allwclean index bf93e1c06b..d2a7ff3af9 100755 --- a/applications/utilities/preProcessing/wallFunctionTable/Allwclean +++ b/applications/utilities/preProcessing/wallFunctionTable/Allwclean @@ -1,5 +1,7 @@ #!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory wclean libso tabulatedWallFunction wclean +#------------------------------------------------------------------------------ diff --git a/src/Pstream/Allwclean b/src/Pstream/Allwclean index 2650e4e38a..29ce00baa0 100755 --- a/src/Pstream/Allwclean +++ b/src/Pstream/Allwclean @@ -1,26 +1,23 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -# Define how an mpi-versioned library is created -# clean the qualified directory +# Clean an mpi-versioned library wcleanMpiLib() { - for libName - do + case "$WM_MPLIB" in (*MPI*) ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - wclean $libName + for libName + do + wclean $libName + done ) - done + ;; + esac } + wclean dummy - -case "$WM_MPLIB" in -*MPI*) - wcleanMpiLib mpi - ;; -esac - +wcleanMpiLib mpi #------------------------------------------------------------------------------ diff --git a/src/parallel/decompose/Allwclean b/src/parallel/decompose/Allwclean index ef6dc41212..88c606b523 100755 --- a/src/parallel/decompose/Allwclean +++ b/src/parallel/decompose/Allwclean @@ -1,44 +1,26 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -# get SCOTCH_VERSION, SCOTCH_ARCH_PATH -if settings=`$WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch` -then - . $settings - echo " using SCOTCH_ARCH_PATH=$SCOTCH_ARCH_PATH" -else - echo - echo " Error: no config.sh/scotch settings" - echo -fi - - -# Define how to clean an mpi-versioned library +# Clean an mpi-versioned library wcleanMpiLib() { - for libName - do + case "$WM_MPLIB" in (*MPI*) ( WM_OPTIONS="$WM_OPTIONS$WM_MPLIB" - wclean $libName + for libName + do + wclean $libName + done ) - done + ;; + esac } -if [ -n "$SCOTCH_ARCH_PATH" ] -then - wclean scotchDecomp - - if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ] - then - wcleanMpiLib ptscotchDecomp - fi -else - echo " skipping scotchDecomp (ptscotchDecomp)" -fi +wclean scotchDecomp wclean metisDecomp wclean decompositionMethods wclean decompose +wcleanMpiLib ptscotchDecomp #------------------------------------------------------------------------------ diff --git a/src/regionModels/Allwclean b/src/regionModels/Allwclean index 2996d85d61..7ba2cd3e51 100755 --- a/src/regionModels/Allwclean +++ b/src/regionModels/Allwclean @@ -1,11 +1,10 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -makeType=${1:-libso} -wclean $makeType regionModel -wclean $makeType pyrolysisModels -wclean $makeType surfaceFilmModels -wclean $makeType thermalBaffleModels -wclean $makeType regionCoupling +wclean libso regionModel +wclean libso pyrolysisModels +wclean libso surfaceFilmModels +wclean libso thermalBaffleModels +wclean libso regionCoupling #------------------------------------------------------------------------------ diff --git a/wmake/wclean b/wmake/wclean index 0f3e5eb8de..426dd18a8c 100755 --- a/wmake/wclean +++ b/wmake/wclean @@ -128,8 +128,8 @@ then } fi - # Print command - echo "$Script $targetType${targetType:+ }${dir:-.}" + # Print command, trim off leading './' for readability + echo "$Script $targetType${targetType:+ }${dir#./}" fi @@ -152,19 +152,18 @@ then echo "Removing empty directories..." # Get sub-directories avoiding particular directories - for dir in $(find . -mindepth 1 -maxdepth 1 \ - -name .git -prune -o -type d -print) + for d in $(find . -mindepth 1 -maxdepth 1 \ + -name .git -prune -o -type d -print) do - echo " searching: $dir" - find $dir -depth -empty -type d -delete -print + echo " searching: ${d#./}" + find $d -depth -empty -type d -delete -print done # Second pass: clean up object directories with WM_PROJECT_DIR that don't # have respective source code folders, along with the respective binaries - if [ "$(expandPath $PWD)" = "$WM_PROJECT_DIR" ] then - objectsDir=$(findObjectDir $PWD) || exit 1 # Fatal + objectsDir=$(findObjectDir $PWD 2>/dev/null) || exit 1 # Fatal if [ -d "$objectsDir" ] then From cc51def1fd779aa4254d51cdc6c8ae3e94accc3d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 09:17:46 +0100 Subject: [PATCH 13/18] STYLE: minor cleanup of foamEtcFile --- bin/foamEtcFile | 142 +++++++++++++++++++++--------------------- wmake/wmakePrintBuild | 2 +- 2 files changed, 73 insertions(+), 71 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 5e21978b0e..70fdb6caf8 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------- # License # This file is part of OpenFOAM. @@ -34,8 +34,7 @@ # # For example, within the user ~/.OpenFOAM//prefs.sh: # \code -# foamPrefs=$($WM_PROJECT_DIR/bin/foamEtcFile -m go prefs.sh) \ -# && _foamSource $foamPrefs +# foamFile=$(foamEtcFile -mode go prefs.sh) && . $foamFile # \endcode # # Note @@ -43,6 +42,7 @@ # or $FOAM_INST_DIR/openfoam/bin/ (for the debian version) # #------------------------------------------------------------------------------- +unset optQuiet optSilent usage() { [ "${optQuiet:-$optSilent}" = true ] && exit 1 @@ -53,21 +53,19 @@ usage() { Usage: ${0##*/} [OPTION] fileName ${0##*/} [OPTION] -list options: - -all return all files (otherwise stop after the first match) - -list list the directories to be searched - -mode any combination of u(user), g(group), o(other) - -prefix specify an alternative installation prefix - -quiet suppress all normal output - -silent suppress all stderr output - -version specify an alternative OpenFOAM version - in the form Maj.Min.Rev (eg, 1.7.0) + -a, -all return all files (otherwise stop after the first match) + -l, -list list the directories to be searched + -m, -mode MODE any combination of u(user), g(group), o(other) + -p, -prefix DIR specify an alternative installation prefix + -q, -quiet suppress all normal output + -s, -silent suppress all stderr output + -v, -version VER specify an alternative OpenFOAM version (eg, 3.0, 1612, ...) -help print the usage Locate user/group/shipped file with semantics similar to the ~OpenFOAM/fileName expansion. - The options can also be specified as a single character - (eg, '-q' instead of '-quiet'), but must not be grouped. + Many options can be specified as a single character, but must not be grouped. Exit status 0 when the file is found. Print resolved path to stdout. @@ -77,60 +75,56 @@ options: USAGE exit 1 } - #------------------------------------------------------------------------------- -# the bin dir: +# The bin dir: binDir="${0%/*}" -# the project dir: +# The project dir: projectDir="${binDir%/bin}" -# the prefix dir (same as $FOAM_INST_DIR): +# The prefix dir (same as $FOAM_INST_DIR): prefixDir="${projectDir%/*}" -# the name used for the project directory +# The name used for the project directory projectDirName="${projectDir##*/}" -# version number used for debian packaging -unset versionNum +# versionNum used for debian packaging +unset version versionNum # -# handle standard and debian naming convention +# Handle standard and debian naming conventions +# - set version (always) and versionNum (debian only) # case "$projectDirName" in -OpenFOAM-*) # standard naming convention OpenFOAM- +OpenFOAM-*) # standard naming: OpenFOAM- version="${projectDirName##OpenFOAM-}" ;; -openfoam[0-9]* | openfoam-dev) # debian naming convention 'openfoam' +openfoam[0-9]* | openfoam-dev) # debian naming: openfoam versionNum="${projectDirName##openfoam}" - case "$versionNum" in - ??) # convert 2 digit version number to decimal delineated - version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)@\1.\2@') + case "${#versionNum}" in + (2|3|4) # Convert digits version number to decimal delineated + version=$(echo "$versionNum" | sed -e 's@\([0-9]\)@\1.@g') + version="${version%.}" ;; - ???) # convert 3 digit version number to decimal delineated - version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)@\1.\2.\3@') - ;; - ????) # convert 4 digit version number to decimal delineated - version=$(echo "$versionNum" | sed -e 's@\(.\)\(.\)\(.\)\(.\)@\1.\2.\3.\4@') - ;; - *) # failback - use current environment setting + + (*) # Fallback - use current environment setting version="$WM_PROJECT_VERSION" ;; esac ;; *) - echo "Error : unknown/unsupported naming convention" + echo "${0##*/} Error : unknown/unsupported naming convention" 1>&2 exit 1 ;; esac -# default mode is 'ugo' +# Default mode is always 'ugo' mode=ugo -unset optAll optList optQuiet optSilent +unset optAll optList # parse options while [ "$#" -gt 0 ] @@ -145,23 +139,36 @@ do -l | -list) optList=true ;; + -mode=[ugo]*) + mode="${1#-mode=}" + ;; + -prefix=/*) + prefixDir="${1#-prefix=}" + prefixDir="${prefixDir%/}" + ;; + -version=*) + version="${1#-version=}" + # convert x.y.z -> xyz version (if installation looked like debian) + if [ -n "$versionNum" ] + then + versionNum=$(echo "$version" | sed -e 's@\.@@g') + fi + ;; -m | -mode) - [ "$#" -ge 2 ] || usage "'$1' option requires an argument" mode="$2" - - # sanity check: + # Sanity check. Handles missing argument too. case "$mode" in - *u* | *g* | *o* ) - ;; + [ugo]*) + ;; *) - usage "'$1' option with invalid mode '$mode'" - ;; + usage "invalid mode '$mode'" + ;; esac shift ;; -p | -prefix) [ "$#" -ge 2 ] || usage "'$1' option requires an argument" - prefixDir="$2" + prefixDir="${2%/}" shift ;; -q | -quiet) @@ -185,7 +192,7 @@ do break ;; -*) - usage "unknown option: '$*'" + usage "unknown option: '$1'" ;; *) break @@ -194,6 +201,14 @@ do shift done +# Update projectDir accordingly +if [ -n "$versionNum" ] +then + projectDir="$prefixDir/openfoam$versionNum" # debian +else + projectDir="$prefixDir/${WM_PROJECT:-OpenFOAM}-$version" # standard +fi + # debugging: # echo "Installed locations:" @@ -210,30 +225,20 @@ fileName="${1#~OpenFOAM/}" # Define the various places to be searched: unset dirList -case "$mode" in -*u*) # user - userDir="$HOME/.${WM_PROJECT:-OpenFOAM}" - dirList="$dirList $userDir/$version $userDir" +case "$mode" in (*u*) # user + dir="$HOME/.${WM_PROJECT:-OpenFOAM}" + dirList="$dirList $dir/$version $dir" ;; esac -case "$mode" in -*g*) # group (site) - siteDir="${WM_PROJECT_SITE:-$prefixDir/site}" - dirList="$dirList $siteDir/$version $siteDir" +case "$mode" in (*g*) # group (site) + dir="${WM_PROJECT_SITE:-$prefixDir/site}" + dirList="$dirList $dir/$version $dir" ;; esac -case "$mode" in -*o*) # other (shipped) - if [ -n "$versionNum" ] - then - # debian packaging - dirList="$dirList $prefixDir/openfoam$versionNum/etc" - else - # standard packaging - dirList="$dirList $prefixDir/${WM_PROJECT:-OpenFOAM}-$version/etc" - fi +case "$mode" in (*o*) # other (shipped) + dirList="$dirList $projectDir/etc" ;; esac set -- $dirList @@ -275,13 +280,10 @@ else if [ -f "$dir/$fileName" ] then exitCode=0 - if [ "$optQuiet" = true ] - then - break - else - echo "$dir/$fileName" - [ "$optAll" = true ] || break - fi + [ "$optQuiet" = true ] && break + + echo "$dir/$fileName" + [ "$optAll" = true ] || break fi done diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 42c7181448..91d0061cf1 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -161,7 +161,7 @@ then # Retrieve OPENFOAM_PLUS= from $WM_DIR/rules/General/general version=$( sed -ne 's@^.*OPENFOAM_PLUS=\([0-9][0-9]*\).*@\1@p' \ - $WM_DIR/rules/General/general 2>/dev/null | tail -1 + $WM_DIR/rules/General/general 2>/dev/null ) if [ -n "$version" ] From 07ec2b3abdebfb30c99a995a64eef45896a11230 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 10:58:55 +0100 Subject: [PATCH 14/18] STYLE: eliminate most use of _foamSource outside of the etc/ hierarchy --- .../mesh/conversion/Optional/Allwmake | 23 +++++++++++++------ etc/config.sh/example/compiler | 11 +++++---- etc/config.sh/functions | 2 +- src/conversion/ccm/Allwmake | 19 +++++++++------ 4 files changed, 35 insertions(+), 20 deletions(-) diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake index 6e64d2c834..428e8712a6 100755 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ b/applications/utilities/mesh/conversion/Optional/Allwmake @@ -1,24 +1,33 @@ #!/bin/sh -# -# Build optional components (eg, may depend on third-party libraries) #------------------------------------------------------------------------------ cd ${0%/*} || exit 1 # Run from this directory +# Optional component: continue-on-error +# - may not have third-party installed +export WM_CONTINUE_ON_ERROR=true + # Parse arguments for compilation (at least for error catching) . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -# Get version info and arch-path -. $WM_PROJECT_DIR/etc/config.sh/functions -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) +warning="==> skip ccmio" +if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) +then + . $settings +else + echo "$warning (no config.sh/ccmio settings)" + exit +fi -# Build libccmio (.a|.so) -$WM_THIRD_PARTY_DIR/makeCCMIO lib # libso +# Build libccmio (.a|.so) - use static linkage for fewer issues +$WM_THIRD_PARTY_DIR/makeCCMIO lib if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \ -a \( -e $CCMIO_ARCH_PATH/lib/libccmio.a -o $FOAM_EXT_LIBBIN/libccmio.so \) ] then wmake $targetType ccm26ToFoam +else + echo $warning fi #------------------------------------------------------------------------------ diff --git a/etc/config.sh/example/compiler b/etc/config.sh/example/compiler index 493cafb56e..96a9ba3382 100644 --- a/etc/config.sh/example/compiler +++ b/etc/config.sh/example/compiler @@ -3,7 +3,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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -31,9 +31,10 @@ #------------------------------------------------------------------------------ # First load the standard versions, if necessary -foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o config.sh/compiler \ - 2>/dev/null) -[ $? -eq 0 ] && _foamSource $foamFile +if foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o config.sh/compiler) +then + . $foamFile +fi unset foamFile @@ -57,7 +58,7 @@ Gcc48u) export WM_CC='gcc-4.8' export WM_CXX='g++-4.8' ;; -Icc) +Icc*) # Example for ensuring that 3rd software uses the Icc compilers export WM_CC='icc' export WM_CXX='icpc' diff --git a/etc/config.sh/functions b/etc/config.sh/functions index 20b30f697d..cf025c4023 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -43,7 +43,7 @@ then do [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2 . $1 - shift + shift done } diff --git a/src/conversion/ccm/Allwmake b/src/conversion/ccm/Allwmake index 72914aaf4d..768101d601 100755 --- a/src/conversion/ccm/Allwmake +++ b/src/conversion/ccm/Allwmake @@ -1,18 +1,23 @@ #!/bin/sh -# Build optional components (eg, may depend on third-party libraries) -#------------------------------------------------------------------------------ cd ${0%/*} || exit 1 # Run from this directory +# Optional component: (eg, may depend on third-party libraries) + # Parse arguments for compilation (at least for error catching) . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -. $WM_PROJECT_DIR/etc/config.sh/functions -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) - -# Link with static libccmio only (possibly fewer issues) - warning="==> skip optional libccm adapter" +if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) +then + . $settings +else + echo "$warning (no config.sh/ccmio settings)" + exit +fi + + +# Link with static libccmio only (possibly fewer issues) if [ -e $CCMIO_ARCH_PATH/include/libccmio/ccmio.h \ -a -e $CCMIO_ARCH_PATH/lib/libccmio.a ] then From c9e4fd77fd78671ff8b634e678e8b08f5393e065 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 12:48:43 +0100 Subject: [PATCH 15/18] ENH: add options for foamEtcFile and shell evaluation - Eg, instead if file=$(foamEtcFile filename) then . $file fi can write eval "$(foamEtcFile -sh filename)" Also supports -verbose reporting, which is especially useful for csh, since it allows simplification of aliases and allows the message to land on stderr instead of stdout. eval `foamEtcFile -csh -verbose filename` --- bin/foamEtcFile | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 70fdb6caf8..9ea5b73f7d 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -58,8 +58,12 @@ options: -m, -mode MODE any combination of u(user), g(group), o(other) -p, -prefix DIR specify an alternative installation prefix -q, -quiet suppress all normal output - -s, -silent suppress all stderr output - -v, -version VER specify an alternative OpenFOAM version (eg, 3.0, 1612, ...) + -s, -silent suppress stderr output, except for things that are emitted + by -csh-verbose, -sh-verbose. + -v, -version VER specify alternative OpenFOAM version (eg, 3.0, 1612, ...) + -csh | -sh produce output suitable for a csh or sh 'eval' + -csh-verbose, + -sh-verbose with additional verbosity -help print the usage Locate user/group/shipped file with semantics similar to the @@ -124,7 +128,7 @@ esac # Default mode is always 'ugo' mode=ugo -unset optAll optList +unset optAll optList optShell # parse options while [ "$#" -gt 0 ] @@ -135,9 +139,15 @@ do ;; -a | -all) optAll=true + unset optShell ;; -l | -list) optList=true + unset optShell + ;; + -csh | -sh | -csh-verbose | -sh-verbose) + optShell="${1#-}" + unset optAll ;; -mode=[ugo]*) mode="${1#-mode=}" @@ -209,7 +219,6 @@ else projectDir="$prefixDir/${WM_PROJECT:-OpenFOAM}-$version" # standard fi - # debugging: # echo "Installed locations:" # for i in projectDir prefixDir projectDirName version versionNum @@ -256,7 +265,7 @@ then [ "$nArgs" -le 1 ] || usage # a silly combination, but -quiet does have precedence - [ "$optQuiet" = true ] && exit 0 + [ -n "$optQuiet" ] && exit 0 for dir do @@ -280,10 +289,28 @@ else if [ -f "$dir/$fileName" ] then exitCode=0 - [ "$optQuiet" = true ] && break + [ -n "$optQuiet" ] && break - echo "$dir/$fileName" - [ "$optAll" = true ] || break + case "$optShell" in + (*verbose) + echo "Using: $dir/$fileName" 1>&2 + ;; + esac + + case "$optShell" in + csh*) + echo "source $dir/$fileName" + break + ;; + sh*) + echo ". $dir/$fileName" + break + ;; + *) + echo "$dir/$fileName" + [ -n "$optAll" ] || break + ;; + esac fi done From c84b9aaac666d83f38865e9d4e66276ab0e07ded Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 15:55:38 +0100 Subject: [PATCH 16/18] ENH: use new foamEtcFile options to simplify syntax when sourcing files Can now use this: _foamSourceEtc config.sh/scotch _foamSourceEtc config.csh/scotch instead of this: _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/scotch` In the bash/sh version, leave the _foamSource function for now, since ThirdParty is still relying on it. STYLE: elminate while-loop for _foamAddPath etc since this type of construct isn't readily possible for csh and isn't being used anywhere. --- etc/bashrc | 28 +++++++++++----------- etc/config.csh/mpi | 2 +- etc/config.csh/settings | 2 +- etc/config.sh/functions | 53 ++++++++++++++++++++++------------------- etc/config.sh/mpi | 2 +- etc/config.sh/settings | 2 +- etc/cshrc | 44 ++++++++++++++++++---------------- 7 files changed, 70 insertions(+), 63 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 94e01d6a18..91da6b9e1b 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -136,10 +136,10 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION . $WM_PROJECT_DIR/etc/config.sh/functions # Add in preset user or site preferences: -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile prefs.sh) +_foamSourceEtc prefs.sh -# Evaluate command-line parameters and record settings for later -# these can be used to set/unset values, or specify alternative pref files +# Evaluate command-line parameters and record settings for later. +# These can be used to set/unset values, or specify alternative pref files. export FOAM_SETTINGS="$@" _foamEval $@ @@ -162,22 +162,22 @@ export PATH LD_LIBRARY_PATH MANPATH # Source project setup files # ~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource $WM_PROJECT_DIR/etc/config.sh/settings -_foamSource $WM_PROJECT_DIR/etc/config.sh/aliases +_foamSourceEtc config.sh/settings +_foamSourceEtc config.sh/aliases # Source user setup files for optional packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mpi) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/paraview) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/vtk) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ensight) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/gperftools) +_foamSourceEtc config.sh/mpi +_foamSourceEtc config.sh/paraview +_foamSourceEtc config.sh/vtk +_foamSourceEtc config.sh/ensight +_foamSourceEtc config.sh/gperftools -##_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ADIOS) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/CGAL) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch) -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/FFTW) +#_foamSourceEtc config.sh/ADIOS +_foamSourceEtc config.sh/CGAL +_foamSourceEtc config.sh/scotch +_foamSourceEtc config.sh/FFTW # Clean environment paths again. Only remove duplicates diff --git a/etc/config.csh/mpi b/etc/config.csh/mpi index c56bbab3f9..dca6ff23f7 100644 --- a/etc/config.csh/mpi +++ b/etc/config.csh/mpi @@ -53,7 +53,7 @@ case SYSTEMOPENMPI: case OPENMPI: setenv FOAM_MPI openmpi-1.10.4 # Optional configuration tweaks: - _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/openmpi` + _foamSourceEtc config.csh/openmpi setenv MPI_ARCH_PATH $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 74da787d22..3a668acf2d 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -212,7 +212,7 @@ if ( ! $?WM_COMPILER_TYPE ) setenv WM_COMPILER_TYPE system # Load configured compiler versions, regardless of the compiler type # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/compiler` +_foamSourceEtc config.csh/compiler switch ("$WM_COMPILER_TYPE") case system: diff --git a/etc/config.sh/functions b/etc/config.sh/functions index cf025c4023..edc3165288 100644 --- a/etc/config.sh/functions +++ b/etc/config.sh/functions @@ -3,7 +3,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) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -36,20 +36,31 @@ then # Temporary environment variable for automatically (un)loading functions WM_BASH_FUNCTIONS=loaded - # Source files, possibly with some verbosity + # Source a file, possibly with some verbosity _foamSource() { - while [ $# -ge 1 ] - do - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" 1>&2 + if [ $# -gt 0 -a -f "$1" ] + then + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 . $1 - shift - done + fi + } + + # Source an etc file, possibly with some verbosity + _foamSourceEtc() + { + local file + if [ $# -gt 0 ] && file=$($WM_PROJECT_DIR/bin/foamEtcFile "$@") + then + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $file" 1>&2 + . $file + fi } # Evaluate command-line parameters _foamEval() { + local file while [ $# -gt 0 ] do case "$1" in @@ -71,9 +82,10 @@ then # Filename: source it if [ -f "$1" ] then - _foamSource "$1" + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Using: $1" 1>&2 + . "$1" else - _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile -silent "$1") + _foamSourceEtc -silent "$1" fi ;; esac @@ -84,31 +96,19 @@ then # Prefix to PATH _foamAddPath() { - while [ $# -ge 1 ] - do - export PATH=$1:$PATH - shift - done + [ $# -gt 0 ] && export PATH=$1:$PATH; } # Prefix to LD_LIBRARY_PATH _foamAddLib() { - while [ $# -ge 1 ] - do - export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH - shift - done + [ $# -gt 0 ] && export LD_LIBRARY_PATH=$1:$LD_LIBRARY_PATH } # Prefix to MANPATH _foamAddMan() { - while [ $# -ge 1 ] - do - export MANPATH=$1:$MANPATH - shift - done + [ $# -gt 0 ] && export MANPATH=$1:$MANPATH } else @@ -117,6 +117,9 @@ else # ~~~~~~~~~~~~~~~~~~~~ unset WM_BASH_FUNCTIONS unset -f _foamAddPath _foamAddLib _foamAddMan - unset -f _foamSource _foamEval + unset -f _foamSourceEtc _foamEval + unset -f _foamSource fi + +#------------------------------------------------------------------------------ diff --git a/etc/config.sh/mpi b/etc/config.sh/mpi index 8f01dc20fa..d26e5eefb0 100644 --- a/etc/config.sh/mpi +++ b/etc/config.sh/mpi @@ -56,7 +56,7 @@ SYSTEMOPENMPI) OPENMPI) export FOAM_MPI=openmpi-1.10.4 # Optional configuration tweaks: - _foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/openmpi) + _foamSourceEtc config.sh/openmpi export MPI_ARCH_PATH=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$FOAM_MPI diff --git a/etc/config.sh/settings b/etc/config.sh/settings index f395db6207..d342ed47e4 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -211,7 +211,7 @@ unset GMP_ARCH_PATH MPFR_ARCH_PATH # Load configured compiler versions, regardless of the compiler type # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/compiler) +_foamSourceEtc config.sh/compiler case "$WM_COMPILER_TYPE" in system) diff --git a/etc/cshrc b/etc/cshrc index 3e644242c2..e8319d258c 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -144,20 +144,23 @@ endif # ~~~~~~~~~~~~~~~~~~~~~~ setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION - -# Source files, possibly with some verbosity -alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*' +# Source etc files, possibly with some verbosity +if ($?FOAM_VERBOSE && $?prompt) then + alias _foamSourceEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`' +else + alias _foamSourceEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`' +endif # Add in preset user or site preferences: -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.csh` +_foamSourceEtc prefs.csh -# Evaluate command-line parameters and record settings for later -# these can be used to set/unset values, or specify alternative pref files +# Evaluate command-line parameters and record settings for later. +# These can be used to set/unset values, or specify alternative pref files. setenv FOAM_SETTINGS "${*}" while ( $#argv > 0 ) switch ($argv[1]) case -*: - # stray option (not meant for us here) -> get out + # Stray option (not meant for us here) -> get out break breaksw case *=: @@ -171,11 +174,12 @@ while ( $#argv > 0 ) eval "setenv $argv[1]:s/=/ /" breaksw default: - # filename: source it + # Filename: source it if ( -f "$1" ) then - _foamSource "$1" + if ($?FOAM_VERBOSE && $?prompt) echo "Using: $1" + source "$1" else - _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile -silent "$1"` + _foamSourceEtc -silent "$1" endif breaksw endsw @@ -208,19 +212,19 @@ if ( $status == 0 ) setenv MANPATH $cleaned # Source project setup files # ~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource $WM_PROJECT_DIR/etc/config.csh/settings -_foamSource $WM_PROJECT_DIR/etc/config.csh/aliases +_foamSourceEtc config.csh/settings +_foamSourceEtc config.csh/aliases # Source user setup files for optional packages # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/mpi` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/paraview` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/vtk` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ensight` +_foamSourceEtc config.csh/mpi +_foamSourceEtc config.csh/paraview +_foamSourceEtc config.csh/vtk +_foamSourceEtc config.csh/ensight -##_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/ADIOS` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/CGAL` -_foamSource `$WM_PROJECT_DIR/bin/foamEtcFile config.csh/FFTW` +#_foamSourceEtc config.csh/ADIOS +_foamSourceEtc config.csh/CGAL +_foamSourceEtc config.csh/FFTW # Clean environment paths again. Only remove duplicates @@ -247,6 +251,6 @@ endif # Cleanup environment: # ~~~~~~~~~~~~~~~~~~~~ unset cleaned foamClean foamOldDirs -unalias _foamSource +unalias _foamSourceEtc #------------------------------------------------------------------------------ From a748ce1eaf1c14046d6bb67996d6ccfbf6e532ef Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Feb 2017 16:25:38 +0100 Subject: [PATCH 17/18] STYLE: resolve COMP_FLAGS, COMPILE_FLAGS mismash in favour of COMP_FLAGS --- .../utilities/mesh/manipulation/renumberMesh/Allwmake | 9 ++++----- .../mesh/manipulation/renumberMesh/Make/options | 2 +- .../utilities/surface/surfaceBooleanFeatures/Allwmake | 6 +++--- .../surface/surfaceBooleanFeatures/Make/options | 2 +- src/OSspecific/POSIX/Allwmake | 2 -- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake index ee135cc373..4115f79c23 100755 --- a/applications/utilities/mesh/manipulation/renumberMesh/Allwmake +++ b/applications/utilities/mesh/manipulation/renumberMesh/Allwmake @@ -4,19 +4,18 @@ cd ${0%/*} || exit 1 # Run from this directory # Parse arguments for compilation (at least for error catching) . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments -export COMPILE_FLAGS='' -export LINK_FLAGS='' +unset COMP_FLAGS LINK_FLAGS if [ -f "${FOAM_LIBBIN}/libSloanRenumber.so" ] then - echo "Found libSloanRenumber.so -- enabling Sloan renumbering support." + echo " found libSloanRenumber -- enabling sloan renumbering support." export LINK_FLAGS="${LINK_FLAGS} -lSloanRenumber" fi if [ -f "${ZOLTAN_ARCH_PATH}/lib/libzoltan.a" -a -f "${FOAM_LIBBIN}/libzoltanRenumber.so" ] then - echo "Found libzoltanRenumber.so -- enabling zoltan renumbering support." - export COMPILE_FLAGS="-DFOAM_USE_ZOLTAN" + echo " found libzoltanRenumber -- enabling sloan renumbering support." + export COMP_FLAGS="-DFOAM_USE_ZOLTAN" export LINK_FLAGS="${LINK_FLAGS} -lzoltanRenumber -L${ZOLTAN_ARCH_PATH}/lib -lzoltan" fi diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index 3d8b7225d9..f285297247 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -1,6 +1,6 @@ EXE_INC = \ /* -DFULLDEBUG -g -O0 */ \ - ${COMPILE_FLAGS} \ + ${COMP_FLAGS} \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake index 260b46ea0b..db490161d8 100755 --- a/applications/utilities/surface/surfaceBooleanFeatures/Allwmake +++ b/applications/utilities/surface/surfaceBooleanFeatures/Allwmake @@ -1,16 +1,16 @@ #!/bin/sh cd ${0%/*} || exit 1 # Run from this directory -unset COMPILE_FLAGS LINK_FLAGS +unset COMP_FLAGS LINK_FLAGS if [ -f "$CGAL_ARCH_PATH/include/CGAL/version.h" ] || \ [ "${CGAL_ARCH_PATH##*-}" = system -a -f /usr/include/CGAL/version.h ] then wmake PolyhedronReader - export COMPILE_FLAGS='-IPolyhedronReader' + export COMP_FLAGS='-IPolyhedronReader' export LINK_FLAGS='${CGAL_LIBS} -lPolyhedronReader' else - export COMPILE_FLAGS="-DNO_CGAL" + export COMP_FLAGS="-DNO_CGAL" fi wmake diff --git a/applications/utilities/surface/surfaceBooleanFeatures/Make/options b/applications/utilities/surface/surfaceBooleanFeatures/Make/options index 873db3134a..4ff7ef8014 100644 --- a/applications/utilities/surface/surfaceBooleanFeatures/Make/options +++ b/applications/utilities/surface/surfaceBooleanFeatures/Make/options @@ -14,7 +14,7 @@ EXE_INC = \ ${EXE_NDEBUG} \ ${CGAL_INC} \ ${c++CGALWARN} \ - $(COMPILE_FLAGS) \ + $(COMP_FLAGS) \ -I$(FOAM_SRC)/surfMesh/lnInclude \ -I$(FOAM_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \ diff --git a/src/OSspecific/POSIX/Allwmake b/src/OSspecific/POSIX/Allwmake index d932523c92..83d082c99e 100755 --- a/src/OSspecific/POSIX/Allwmake +++ b/src/OSspecific/POSIX/Allwmake @@ -14,8 +14,6 @@ if [ -f /usr/include/sys/inotify.h ] then echo " found -- enabling inotify for file monitoring." export COMP_FLAGS="-DFOAM_USE_INOTIFY" -else - unset COMP_FLAGS fi # make (non-shared by default) object From 60574799266c89604de33bdc9f9a4c40f10719e2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 24 Feb 2017 12:20:45 +0100 Subject: [PATCH 18/18] ENH: provide wcleanBuild and improve wcleanPlatform - new behaviour is to do nothing if no platform was specified. This helps avoid inadvertently removing files. - support special platforms for compatibility with wmake/wclean targets. Eg, "wcleanPlatform all" - allow use from ThirdParty top-level as well, since the directory structure is similar. BUG: fix regression in wcleanLnIncludeAll introduced by 9e2e111518ea --- wmake/wcleanBuild | 135 ++++++++++++++++++++++++++++++++++++ wmake/wcleanLnIncludeAll | 27 +++++--- wmake/wcleanPlatform | 143 ++++++++++++++++++++++----------------- 3 files changed, 232 insertions(+), 73 deletions(-) create mode 100755 wmake/wcleanBuild diff --git a/wmake/wcleanBuild b/wmake/wcleanBuild new file mode 100755 index 0000000000..3989b06e0a --- /dev/null +++ b/wmake/wcleanBuild @@ -0,0 +1,135 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# License +# This file is part of OpenFOAM. +# +# OpenFOAM is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License +# along with OpenFOAM. If not, see . +# +# Script +# wcleanBuild +# +# Usage +# wcleanBuild [.. ] +# +# Description +# Deletes the specified 'build/' object files directories from the +# the project top-level 'build/' directory $WM_PROJECT_DIR. +# +# special platforms +# - 'all' removes all platforms. +# - 'compiler' corresponds to $WM_ARCH$WM_COMPILER. +# - 'current' corresponds to $WM_OPTIONS. +# +# You must be in the project or the third-party top-level directory +# to run this script. +# +#------------------------------------------------------------------------------ +Script=${0##*/} + +usage() { + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat< [.. ] + $Script -all | -compiler | -current [ [.. ]] + +options: + -a, -all Same as 'all' + -comp, -compiler Same as 'compiler' + -c, -current Same as 'current' + -h, -help Print the usage + + +Deletes the specified build/ object file directories from the project +top-level build/ directory $WM_PROJECT_DIR. + +special platforms: + all Remove all platforms + compiler $WM_ARCH$WM_COMPILER (ie, \$WM_ARCH\$WM_COMPILER) + current $WM_OPTIONS (ie, \$WM_OPTIONS) + +You must be in the project or the third-party top-level directory +to run this script. + +USAGE + exit 1 +} + +# Find -help anywhere +for i +do + case "$i" in (-h | -help) usage ;; esac +done + +#------------------------------------------------------------------------------ +# Run from OPENFOAM or THIRDPARTY top-level directory only +wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ +wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ +{ +cat<&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat<&2 fi diff --git a/wmake/wcleanPlatform b/wmake/wcleanPlatform index 34767739b7..39c6da0a86 100755 --- a/wmake/wcleanPlatform +++ b/wmake/wcleanPlatform @@ -26,24 +26,19 @@ # wcleanPlatform # # Usage -# wcleanPlatform [ -current | -all ] -# wcleanPlatform [ ... ] +# wcleanPlatform [.. ] # # Description -# Deletes the specified platforms object files directories from the -# the project top-level platforms directory $WM_PROJECT_DIR. +# Deletes the specified 'platforms/' object files directories from the +# the project top-level 'platforms/' directory $WM_PROJECT_DIR. # -# You need to be in the project top-level directory to run this script. +# special platforms +# - 'all' removes all platforms, lnInclude directories and cleans tutorials. +# - 'compiler' corresponds to $WM_ARCH$WM_COMPILER. +# - 'current' corresponds to $WM_OPTIONS. # -# Options -# -current: clean the current platform -# -all: clean all platforms -# -# If either -current or no platform is specified then the current platform -# $WM_OPTIONS is deleted. -# -# If the -all option is specified all platforms and lnInclude directories -# are deleted +# You must be in the project or the third-party top-level directory +# to run this script. # #------------------------------------------------------------------------------ Script=${0##*/} @@ -52,67 +47,91 @@ usage() { exec 1>&2 while [ "$#" -ge 1 ]; do echo "$1"; shift; done cat< [ ... ] - Deletes the specified platforms object files directories from the - the project top-level platforms directory $WM_PROJECT_DIR. +Usage: $Script [.. ] + $Script -all | -compiler | -current [ [.. ]] - You need to be in the project top-level directory to run this script. +options: + -a, -all Same as 'all' + -comp, -compiler Same as 'compiler' + -c, -current Same as 'current' + -h, -help Print the usage - If either -current or no platform is specified then the current platform - $WM_OPTIONS is deleted. - If the -all option is specified all platforms and lnInclude directories - are deleted. +Deletes the specified platforms/ object file directories from the project +top-level platforms/ directory $WM_PROJECT_DIR. + +special platforms: + all Remove all platforms, lnInclude and clean tutorials + compiler $WM_ARCH$WM_COMPILER (ie, \$WM_ARCH\$WM_COMPILER) + current $WM_OPTIONS (ie, \$WM_OPTIONS) + +You must be in the project or the third-party top-level directory +to run this script. USAGE exit 1 } -# Print help message -if [ "$1" = "-h" -o "$1" = "-help" ] +# Find -help anywhere +for i +do + case "$i" in (-h | -help) usage ;; esac +done + +#------------------------------------------------------------------------------ +# Run from OPENFOAM or THIRDPARTY top-level directory only +wmakeCheckPwd -q "$WM_PROJECT_DIR" 2>/dev/null || \ +wmakeCheckPwd -q "$WM_THIRD_PARTY_DIR" 2>/dev/null || \ +{ +cat<