diff --git a/bin/foamCleanPath b/bin/foamCleanPath
index a5910cad1f..1fcfcb196d 100755
--- a/bin/foamCleanPath
+++ b/bin/foamCleanPath
@@ -7,11 +7,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
-# Copyright (C) 2017-2018 OpenCFD Ltd.
+# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
-# This file is part of OpenFOAM, licensed under GNU General Public License
-# .
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamCleanPath
@@ -41,7 +40,7 @@
# cleaned=$(foamCleanPath -env=PATH dir1:dir2) && PATH=$cleaned
#
# - Using shell evaluation for the output
-# eval $(foamCleanPath -sh=PATH $PATH" dir1:dir2)
+# eval "$(foamCleanPath -sh=PATH "$PATH" dir1:dir2)"
# eval "$(foamCleanPath -sh=PATH -env=PATH dir1:dir2)"
# eval "$(foamCleanPath -sh-env=PATH dir1:dir2)"
#
@@ -49,16 +48,17 @@
# eval `foamCleanPath -csh-env=PATH dir1:dir2`
#
#------------------------------------------------------------------------------
-usage() {
- cat <&2
+printHelp() {
+ cat<.
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# . change-sitedir.sh PREFIX [SUFFIX]
@@ -59,7 +46,7 @@ then
foamOldDirs="$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN \
$WM_PROJECT_SITE $WM_PROJECT_DIR/site"
- foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
+ foamClean="$WM_PROJECT_DIR/bin/foamCleanPath"
if [ -x "$foamClean" ]
then
cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
diff --git a/bin/tools/change-userdir.sh b/bin/tools/change-userdir.sh
index 16b584e212..bb0dc25dd1 100644
--- a/bin/tools/change-userdir.sh
+++ b/bin/tools/change-userdir.sh
@@ -5,23 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
-# Copyright (C) 2017 OpenCFD Ltd.
+# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# 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 .
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# . change-userdir.sh PREFIX [SUFFIX]
@@ -59,7 +46,7 @@ then
suffix="$2"
foamOldDirs="$FOAM_USER_APPBIN $FOAM_USER_LIBBIN"
- foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
+ foamClean="$WM_PROJECT_DIR/bin/foamCleanPath"
if [ -x "$foamClean" ]
then
cleaned=$($foamClean "$PATH" "$foamOldDirs") && PATH="$cleaned"
diff --git a/bin/tools/foamAllHC b/bin/tools/foamAllHC
deleted file mode 100755
index 96b7c2e046..0000000000
--- a/bin/tools/foamAllHC
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/bin/sh
-#------------------------------------------------------------------------------
-# ========= |
-# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
-# \\ / O peration |
-# \\ / A nd | www.openfoam.com
-# \\/ M anipulation |
-#-------------------------------------------------------------------------------
-# Copyright (C) 2011 OpenFOAM Foundation
-#------------------------------------------------------------------------------
-# 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
-# foamAllHC
-#
-# Description
-# execute operation $1 on all C,H,L files
-#
-#------------------------------------------------------------------------------
-
-if [ "$#" -gt 0 ]
-then
- find . -name "*.[CHL]" -type f -exec $1 {} \; -print
-fi
-
-#------------------------------------------------------------------------------
diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths
index f2d400ab2f..12ea3d36bc 100755
--- a/bin/tools/foamConfigurePaths
+++ b/bin/tools/foamConfigurePaths
@@ -29,18 +29,49 @@
#
#------------------------------------------------------------------------------
printHelp() {
- cat<&2
+ echo "Configuring OpenFOAM ($projectDir)" 1>&2
else
die "Please run from the OpenFOAM top-level installation directory" \
"No etc/bashrc or META-INFO/ found"
@@ -172,18 +201,22 @@ _inlineSed()
local replacement="$3"
local msg="$4"
local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
+ local localFile
[ -f "$file" ] || {
echo "Missing file: $file"
exit 2 # Fatal
}
+ # Local filename (for reporting)
+ localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
+
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
- echo "Failed: ${msg:-replacement} in $file"
+ echo "Failed: ${msg:-replacement} in $localFile"
return 1
}
- [ -n "$msg" ] && echo " $msg ($file)"
+ [ -n "$msg" ] && echo " $msg ($localFile)"
return 0
}
@@ -209,7 +242,7 @@ replace()
"$file" \
"$key=.*" \
"$key=$val" \
- "Replaced $key setting by '$val'"
+ "Replaced $key by '$val'"
done
}
@@ -232,9 +265,9 @@ replaceCsh()
_inlineSed \
"$file" \
- "setenv *$key [^ #]*" \
+ "setenv [ ]*$key [^ #]*" \
"setenv $key $val" \
- "Replaced $key setenv by '$val'"
+ "Replaced $key by '$val'"
done
}
@@ -323,7 +356,13 @@ unset adjusted optMpi
while [ "$#" -gt 0 ]
do
case "$1" in
- -h | -help* | --help*)
+ -help-c*) # Compat help
+ printHelp -compat
+ ;;
+ -help-f*) # Full help
+ printHelp -full
+ ;;
+ -h | -help*) # Short help
printHelp
;;
'')
@@ -516,12 +555,12 @@ CONFIG_CSH
_inlineSed $(_foamEtc config.sh/mpi) \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optMpi" \
- "Replaced 'FOAM_MPI=$expected' setting by 'FOAM_MPI=$optMpi'"
+ "Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
_inlineSed $(_foamEtc config.csh/mpi) \
"FOAM_MPI $expected" \
"FOAM_MPI $optMpi" \
- "Replaced 'FOAM_MPI $expected' setting by 'FOAM_MPI $optMpi'"
+ "Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
@@ -711,11 +750,11 @@ CONFIG_CSH
shift
;;
- -vtk)
- # Replace vtk_version=...
+ -llvm)
+ # Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
- replaceEtc config.sh/vtk vtk_version "$optionValue"
- replaceEtc config.csh/vtk vtk_version "$optionValue"
+ replaceEtc config.sh/vtk mesa_llvm "$optionValue"
+ replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
;;
@@ -729,6 +768,42 @@ CONFIG_CSH
shift
;;
+ -vtk)
+ # Replace vtk_version=...
+ optionValue=$(getOptionValue "$@")
+ replaceEtc config.sh/vtk vtk_version "$optionValue"
+ replaceEtc config.csh/vtk vtk_version "$optionValue"
+ adjusted=true
+ shift
+ ;;
+
+ -llvm-path)
+ # Replace LLVM_ARCH_PATH=...
+ optionValue=$(getOptionValue "$@")
+ replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
+ replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
+ adjusted=true
+ shift
+ ;;
+
+ -mesa-path)
+ # Replace MESA_ARCH_PATH...
+ optionValue=$(getOptionValue "$@")
+ replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
+ replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
+ adjusted=true
+ shift
+ ;;
+
+ -vtk-path)
+ # Replace VTK_DIR...
+ optionValue=$(getOptionValue "$@")
+ replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
+ replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
+ adjusted=true
+ shift
+ ;;
+
## Misc ##
diff --git a/bin/tools/foamCreateModuleInclude b/bin/tools/foamCreateModuleInclude
index 7a95574057..9fe28d98b9 100755
--- a/bin/tools/foamCreateModuleInclude
+++ b/bin/tools/foamCreateModuleInclude
@@ -241,7 +241,7 @@ $MESA_ARCH_PATH $LLVM_ARCH_PATH \
$MPI_ARCH_PATH $SCOTCH_ARCH_PATH \
$FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN $WM_PROJECT_SITE \
$FOAM_USER_APPBIN $FOAM_USER_LIBBIN"
-foamClean=$WM_PROJECT_DIR/bin/foamCleanPath
+foamClean="$WM_PROJECT_DIR/bin/foamCleanPath"
if [ -x "$foamClean" ]
then
diff --git a/bin/tools/foamExec b/bin/tools/foamExec
index 723ade6817..2e73098040 100755
--- a/bin/tools/foamExec
+++ b/bin/tools/foamExec
@@ -6,23 +6,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
-# Copyright (C) 2019 OpenCFD Ltd.
+# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# 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 .
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamExec ...
@@ -31,17 +18,20 @@
# Runs an application (with arguments) after first sourcing the OpenFOAM
# etc/bashrc file from the project directory
#
-# This script must exist in $WM_PROJECT_DIR/bin/tools
-#
# Can useful for parallel runs. For example,
#
# mpirun -n \
# projectDir/bin/tools/foamExec ... -parallel
#
+# Note
+# This script normally exists in the project 'bin/tools' directory.
+# Do not copy/move/link to other locations unless you also edit it!
+#
#------------------------------------------------------------------------------
-usage() {
- exec 1>&2
- while [ "$#" -ge 1 ]; do echo "$1"; shift; done
+toolsDir="${0%/*}" # The bin/tools dir
+projectDir="${toolsDir%/bin/tools}" # Project dir
+
+printHelp() {
cat< ...
@@ -49,11 +39,12 @@ Usage: ${0##*/} [OPTION] ...
options:
-help Print the usage
-Runs an application (with arguments) after first sourcing the OpenFOAM
-etc/bashrc file from the project directory
+Run an application (with arguments) after first sourcing
+the OpenFOAM etc/bashrc file from the project directory:
+($projectDir)
USAGE
- exit 1
+ exit 0 # A clean exit
}
# Report error and exit
@@ -70,15 +61,13 @@ die()
}
#-------------------------------------------------------------------------------
-toolsDir="${0%/*}" # The bin/tools dir
-projectDir="${toolsDir%/bin/tools}" # Project dir
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
- usage
+ printHelp
;;
--)
shift
@@ -116,6 +105,7 @@ sourceBashrc()
. "$projectDir/etc/bashrc" $FOAM_SETTINGS
}
+
sourceBashrc
exec "$@"
diff --git a/bin/tools/help-filter b/bin/tools/help-filter
new file mode 100755
index 0000000000..f9991129d7
--- /dev/null
+++ b/bin/tools/help-filter
@@ -0,0 +1,36 @@
+#!/bin/sh
+#------------------------------------------------------------------------------
+# ========= |
+# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+# \\ / O peration |
+# \\ / A nd | www.openfoam.com
+# \\/ M anipulation |
+#-------------------------------------------------------------------------------
+# Copyright (C) 2020 OpenCFD Ltd.
+#------------------------------------------------------------------------------
+# License
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
+#
+# Script
+# help-filter
+#
+# Description
+# Feed with output from -help-full.
+#
+# For example,
+# blockMesh -help-full | ./help-filter
+#
+#------------------------------------------------------------------------------
+
+sed -ne '1,/^[Oo]ptions:/d' \
+ -e '/^ \{8\}/d;' \
+ -e 's/^ *//; /^$/d; /^[^-]/d; /^--/d; /^-help-man/d;' \
+ -e '/^-hostRoots /d; /^-roots /d;' \
+ -e '/^-lib /d;' \
+ -e '/^-[a-z]*-switch /d;' \
+ -e 'y/,/ /; s/=.*$/=/;' \
+ -e '/^-[^ ]* { s/^\(-[^ ]* <\).*$/\1/; p; d }' \
+ -e 's/^\(-[^ ]*\).*$/\1/; p; /^-help-full/q;' \
+-
+
+#------------------------------------------------------------------------------
diff --git a/bin/tools/lib-dir b/bin/tools/lib-dir
index 12651b22b6..f423411fa3 100755
--- a/bin/tools/lib-dir
+++ b/bin/tools/lib-dir
@@ -22,8 +22,14 @@
# LIBEXT if these failed. A DIR ending in "-none" or "-system" is skipped.
#
# output -csh: setenv LD_LIBRARY_PATH dir/lib:$LD_LIBRARY_PATH
-# output -make: -Ldir/lib
# output -sh: LD_LIBRARY_PATH=dir/lib:$LD_LIBRARY_PATH
+# output -make: -Ldir/lib
+#
+# Note
+# LD_LIBRARY_PATH automatically changes to DYLD_LIBRARY_PATH for Darwin.
+#
+# Environment
+# WM_COMPILER_LIB_ARCH
#
#------------------------------------------------------------------------------
printHelp() {
@@ -34,9 +40,9 @@ Usage: ${0##*/} [OPTION] DIR [LIBEXT]
options:
-sh Emit POSIX shell syntax (default)
-csh Emit C-shell shell syntax
- -sh-verbose As per -sh, with additional verbosity
- -csh-verbose As per -csh, with additional verbosity
- -make Emit content for a makefile
+ -sh-verbose Like -sh, with additional verbosity
+ -csh-verbose Like -csh, with additional verbosity
+ -make Emit content for a Makefile
-help Print the usage
Resolves for the existence of DIR/lib64 and DIR/lib, or uses the fallback
@@ -139,10 +145,10 @@ then
# Fallback
case "$alt" in
/*)
- resolved=$alt
+ resolved="$alt"
;;
(*)
- resolved=$dir/$alt
+ resolved="$dir/$alt"
;;
esac
exit 0
@@ -177,6 +183,7 @@ then
fi
;;
*)
+ # Default is -sh
echo "LD_LIBRARY_PATH=$resolved:$LD_LIBRARY_PATH"
if [ -n "$verboseOutput" ]
then
diff --git a/bin/tools/scanpackages b/bin/tools/scanpackages
deleted file mode 100755
index ed30adb677..0000000000
--- a/bin/tools/scanpackages
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-#
-# Generate Packages file on debian repositories.
-
-for D in `find . -mindepth 4 -type d`
-do
- dpkg-scanpackages $D | gzip -9c > ${D}/Packages.gz
-done