diff --git a/Allwmake b/Allwmake
index c6e1ca4f8c..431140a92d 100755
--- a/Allwmake
+++ b/Allwmake
@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
-[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
+then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
+ echo "Argument parse error";
+else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
-}
-
-. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
+fi
#------------------------------------------------------------------------------
# Preamble. Report tools or at least the mpirun location
@@ -45,11 +46,11 @@ echo
"${WM_DIR:-wmake}"/src/Allmake
# Compile ThirdParty libraries and applications
-if [ -d "$WM_THIRD_PARTY_DIR" ]
+if [ -d "$WM_THIRD_PARTY_DIR" ] && [ -x "$WM_THIRD_PARTY_DIR/Allwmake" ]
then
- "$WM_THIRD_PARTY_DIR/Allwmake"
+ "$WM_THIRD_PARTY_DIR"/Allwmake
else
- echo "No ThirdParty directory found - skipping"
+ echo "No ThirdParty directory, or missing Allwmake - skipping"
fi
echo "========================================"
@@ -74,7 +75,7 @@ fi
# Count files in given directory. Ignore "Test-*" binaries.
_foamCountDirEntries()
{
- (cd "$1" 2>/dev/null && find -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
+ (cd "$1" 2>/dev/null && find . -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
sed -e '\@/Test-@d' | wc -l
}
@@ -86,10 +87,10 @@ echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo
-echo " api = $(foamEtcFile -show-api 2>/dev/null)"
-echo " patch = $(foamEtcFile -show-patch 2>/dev/null)"
-echo " bin = $(_foamCountDirEntries $FOAM_APPBIN) entries"
-echo " lib = $(_foamCountDirEntries $FOAM_LIBBIN) entries"
+echo " api = $(bin/foamEtcFile -show-api 2>/dev/null)"
+echo " patch = $(bin/foamEtcFile -show-patch 2>/dev/null)"
+echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
+echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo
echo "========================================"
diff --git a/applications/Allwmake b/applications/Allwmake
index ad65e14112..005fec2570 100755
--- a/applications/Allwmake
+++ b/applications/Allwmake
@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
-[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
+then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
+ echo "Argument parse error";
+else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
-}
-
-. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
+fi
#------------------------------------------------------------------------------
diff --git a/bin/foamEtcFile b/bin/foamEtcFile
index 024c16a33b..544ca7b543 100755
--- a/bin/foamEtcFile
+++ b/bin/foamEtcFile
@@ -7,14 +7,13 @@
# \\/ 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
-# foamEtcFile
+# bin/foamEtcFile
#
# Description
# Locate user/group/other file as per '#includeEtc'.
@@ -61,8 +60,8 @@ options:
-config Add config directory prefix for shell type:
with -csh* for a config.csh/ prefix
with -sh* for a config.sh/ prefix
- -show-api Print api value from wmake/rules, or meta-info and exit
- -show-patch Print patch value from meta-info and exit
+ -show-api Print META-INFO api value and exit
+ -show-patch Print META-INFO patch value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@@ -109,54 +108,17 @@ groupDir="${WM_PROJECT_SITE:-$projectDir/site}" # As per foamVersion.H
#-------------------------------------------------------------------------------
-# The API locations. See wmake/wmakeBuildInfo
-rulesFile="$projectDir/wmake/rules/General/general"
-metaInfoDir="$projectDir/META-INFO"
-
-# Get api from rules/General/general
-#
-# Failure modes:
-# - No api information (can't find file etc).
-# -> Fatal for building, but could be OK for a stripped down version
-#
-# Fallback. Get from api-info
-#
-getApi()
+# Get a value from META-INFO/api-info
+# $1 : keyword
+getApiInfo()
{
- local value
-
- value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
- if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
- then
- # Fallback. Get from api-info
- value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
- fi
-
- if [ -n "$value" ]
- then
- echo "$value"
- else
- return 1
- fi
-}
-
-
-# Get patch from meta-info / api-info
-#
-# Failure modes:
-# - No patch information (can't find file etc).
-#
-getPatchLevel()
-{
- local value
-
- # Fallback. Get from api-info
- value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
+ value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
+ echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
@@ -174,14 +136,12 @@ do
-h | -help*)
printHelp
;;
- -show-api)
- # Show API and exit
- getApi
+ -show-api) # Show API and exit
+ getApiInfo api
exit $?
;;
- -show-patch)
- # Show patch level and exit
- getPatchLevel
+ -show-patch) # Show patch level and exit
+ getApiInfo patch
exit $?
;;
-with-api=*)
@@ -257,7 +217,7 @@ done
#-------------------------------------------------------------------------------
# Establish the API value
-[ -n "$projectApi" ] || projectApi=$(getApi)
+[ -n "$projectApi" ] || projectApi=$(getApiInfo api)
# Split arguments into filename (for searching) and trailing bits for shell eval
diff --git a/bin/foamGetDict b/bin/foamGetDict
index 06e0adceb7..ebe5f304d9 100755
--- a/bin/foamGetDict
+++ b/bin/foamGetDict
@@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018 OpenFOAM Foundation
-# Copyright (C) 2019 OpenCFD Ltd.
+# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@@ -166,7 +166,7 @@ fi
# No api specified -with-api= or from environment (FOAM_API)
if [ -z "$projectApi" ]
then
- projectApi="$(foamEtcFile -show-api 2>/dev/null)"
+ projectApi="$("$projectDir"/bin/foamEtcFile -show-api 2>/dev/null)"
fi
diff --git a/src/Allwmake b/src/Allwmake
index 9fa030779a..7f42ca5cbb 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
-[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
+if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
+then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
+ echo "Argument parse error";
+else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
-}
-
-. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
+fi
#------------------------------------------------------------------------------
diff --git a/src/Allwmake-scan b/src/Allwmake-scan
index 2d12e096bd..07833797a0 100755
--- a/src/Allwmake-scan
+++ b/src/Allwmake-scan
@@ -1,18 +1,8 @@
#!/bin/sh
# Allwmake with scan-build (clang)
-command -v scan-build > /dev/null || {
- exec 1>&2
- echo "No scan-build found, stopping"
- echo
- exit 2
-}
-
-comp_cc="$(command -v "$(wmake -show-c)")"
-comp_cxx="$(command -v "$(wmake -show-cxx)")"
-
-set -x
-scan-build --use-cc="$comp_cc" --use-c++="$comp_cxx" \
+scan-build \
+ --use-cc="$(wmake -show-path-c)" \
+ --use-c++="$(wmake -show-path-cxx)" \
./Allwmake "$@"
-
#------------------------------------------------------------------------------
diff --git a/src/parallel/decompose/AllwmakeLnInclude b/src/parallel/decompose/AllwmakeLnInclude
index db014338ba..5043fba1f2 100755
--- a/src/parallel/decompose/AllwmakeLnInclude
+++ b/src/parallel/decompose/AllwmakeLnInclude
@@ -1,5 +1,7 @@
#!/bin/sh
-cd "${0%/*}" || exit # Run from this directory
+cd "${0%/*}" || exit # Run from this directory
+
+#------------------------------------------------------------------------------
wmakeLnInclude -u decompositionMethods
wmakeLnInclude -u kahipDecomp
diff --git a/wmake/scripts/AllwmakeParseArguments b/wmake/scripts/AllwmakeParseArguments
index 80da8a5b75..eaac63e1a9 100644
--- a/wmake/scripts/AllwmakeParseArguments
+++ b/wmake/scripts/AllwmakeParseArguments
@@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2014-2017 OpenFOAM Foundation
-# Copyright (C) 2019 OpenCFD Ltd.
+# Copyright (C) 2019-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.
#
# File
# wmake/scripts/AllwmakeParseArguments
@@ -22,14 +21,26 @@
# # Parse the arguments by sourcing this script
# . ${WM_PROJECT_DIR:?}/wmake/scripts/AllwmakeParseArguments
#
+# Parsed options (make)
+# -k | -keep-going | -non-stop
+# -j | -jN | -j N
+#
+# Parsed options (wmake)
+# -debug
+# -q | -queue
+#
+# Parsed options (special)
+# -l | -log | -log=FILE
+#
#------------------------------------------------------------------------------
-
-if [ -z "$WM_PROJECT_DIR" ]
-then
- echo "$Script error: The OpenFOAM environment is not set."
- echo " Check the OpenFOAM entries in your dot-files and source them."
+# Check environment
+[ -d "$WM_PROJECT_DIR" ] || {
+ exec 1>&2
+ echo "$Script error: The OpenFOAM environment not set or incorrect."
+ echo " Check OpenFOAM entries in your dot-files and source them."
exit 1
-fi
+}
+
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
diff --git a/wmake/wmake b/wmake/wmake
index 8bc070eb4b..bfbaecae28 100755
--- a/wmake/wmake
+++ b/wmake/wmake
@@ -79,7 +79,7 @@ then
cat<.
+# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# wmakeBuildInfo
@@ -38,12 +25,13 @@
# Note
# Partial logic is also implemented in the bin/foamEtcFile
# -show-api and -show-patch options.
-# Make sure that any changes here are also reflected there.
+# Make sure that changes here are also reflected there.
#
#------------------------------------------------------------------------------
# Locations
rulesFile="${WM_DIR:-$WM_PROJECT_DIR/wmake}/rules/General/general"
-metaInfoDir="$WM_PROJECT_DIR/META-INFO"
+META_INFO="$WM_PROJECT_DIR/META-INFO"
+FOAM_GIT_DIR="$WM_PROJECT_DIR/.git"
usage() {
exec 1>&2
@@ -58,6 +46,7 @@ options:
(exit code 0 for no changes)
-dry-run In combination with -update
-filter FILE Filter @API@, @BUILD@ tags in file with make information
+ -no-git Disable use of git for obtaining information
-remove Remove meta-info build information and exit
-update Update meta-info from make information
-query Report make-info and meta-info
@@ -131,6 +120,9 @@ do
shift # Stop here, a file name follows
break
;;
+ -no-git)
+ unset FOAM_GIT_DIR
+ ;;
*)
die "unknown option/argument: '$1'"
;;
@@ -142,8 +134,8 @@ done
[ -d "$WM_PROJECT_DIR" ] || \
die "Bad or unset environment variable: \$WM_PROJECT_DIR"
-[ -d "$WM_PROJECT_DIR/META-INFO" ] || \
- die "No META-INFO/ directory for project"
+[ -d "$META_INFO" ] || \
+ die "No ${META_INFO##*/}/ directory for project"
#------------------------------------------------------------------------------
@@ -151,12 +143,12 @@ done
if [ "$optUpdate" = remove ]
then
- if [ -f "$metaInfoDir/build-info" ]
+ if [ -f "$META_INFO/build-info" ]
then
- echo "Removing project META-INFO/build-info" 1>&2
- rm -f "$metaInfoDir/build-info" 2>/dev/null
+ echo "Removing project ${META_INFO##*/}/build-info" 1>&2
+ rm -f "$META_INFO/build-info" 2>/dev/null
else
- echo "Already removed project META-INFO/build-info" 1>&2
+ echo "Already removed project ${META_INFO##*/}/build-info" 1>&2
fi
exit 0
@@ -173,7 +165,7 @@ then
else
- [ "$#" -eq 0 ] || die "Unexpected option/arguments $@"
+ [ "$#" -eq 0 ] || die "Unexpected option/arguments $*"
# Nothing specified? Default to -query-make
if [ -z "$optCheck$optUpdate$optQuery" ]
@@ -221,22 +213,25 @@ getMakeInfo()
# (api) from WM_DIR/rules/General/general
# - extract WM_VERSION = OPENFOAM=
- api="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
+ api="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' "$rulesFile" 2>/dev/null)"
- if [ -d "$metaInfoDir" ]
+ if [ -d "$META_INFO" ]
then
# (patch) from build-info - not from api-info
- patch="$(sed -ne 's@^patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/build-info 2>/dev/null)"
+ patch="$(sed -ne 's@^patch *= *\([0-9][0-9]*\).*@\1@p' "$META_INFO/build-info" 2>/dev/null)"
fi
# Build info from git. Use short date format (YYYY-MM-DD) and sed instead
# of the newer --date='format:%y%m%d'
- build="$(git --git-dir=$WM_PROJECT_DIR/.git log -1 --date=short --format='%h=%ad' 2>/dev/null|sed 's/-//g;s/=/-/')"
-
- # Branch info from git
- if [ -n "$build" ]
+ if [ -d "$FOAM_GIT_DIR" ]
then
- branch="$(git --git-dir=$WM_PROJECT_DIR/.git rev-parse --abbrev-ref HEAD 2>/dev/null)"
+ build="$(git --git-dir="$FOAM_GIT_DIR" log -1 --date=short --format='%h=%ad' 2>/dev/null|sed 's/-//g;s/=/-/')"
+
+ # Branch info from git
+ if [ -n "$build" ]
+ then
+ branch="$(git --git-dir="$FOAM_GIT_DIR" rev-parse --abbrev-ref HEAD 2>/dev/null)"
+ fi
fi
make_api="$api"
@@ -269,15 +264,15 @@ getMetaInfo()
local api patch build branch
unset meta_api meta_patch meta_branch meta_build
- if [ -d "$metaInfoDir" ]
+ if [ -d "$META_INFO" ]
then
# (api, patch) from api-info
# (branch, build) from build-info
- api="$(sed -ne 's@^api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
- patch="$(sed -ne 's@^patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
- branch="$(sed -ne 's@^branch *= *\([^ ]*\).*@\1@p' $metaInfoDir/build-info 2>/dev/null)"
- build="$(sed -ne 's@^build *= *\([^ ]*\).*@\1@p' $metaInfoDir/build-info 2>/dev/null)"
+ api="$(sed -ne 's@^api *= *\([0-9][0-9]*\).*@\1@p' "$META_INFO/api-info" 2>/dev/null)"
+ patch="$(sed -ne 's@^patch *= *\([0-9][0-9]*\).*@\1@p' "$META_INFO/api-info" 2>/dev/null)"
+ branch="$(sed -ne 's@^branch *= *\([^ ]*\).*@\1@p' "$META_INFO/build-info" 2>/dev/null)"
+ build="$(sed -ne 's@^build *= *\([^ ]*\).*@\1@p' "$META_INFO/build-info" 2>/dev/null)"
fi
meta_api="$api"
@@ -478,7 +473,7 @@ performUpdate()
local outputFile
# build-info
- outputFile="$metaInfoDir/build-info"
+ outputFile="$META_INFO/build-info"
if [ "$branch" != "${meta_branch}" ] || \
[ "$build" != "${meta_build}" ] || \
[ "$patch" != "${meta_patch}" ]
@@ -499,7 +494,7 @@ performUpdate()
# api-info
- outputFile="$metaInfoDir/api-info"
+ outputFile="$META_INFO/api-info"
if [ "$api" != "${meta_api}" ]
then
patch="${meta_patch:-0}" # <- From meta-info only