Commit d483123c authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: limit foamEtcFile -show-api to querying the META-INFO/api-info

- simplifies code, covers most cases.
  Can use wmake -show-api or wmakeBuildInfo to query the make rules.

STYLE: Allwmake script adjustments

- use bin/foamEtcFile instead of relying on PATH.
  The make environment may not have the OpenFOAM bin/ in it.

- simpler shell syntax
parent 8ab37e13
......@@ -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 "========================================"
......
......@@ -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
#------------------------------------------------------------------------------
......
......@@ -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
# <http://www.gnu.org/licenses/>.
# 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
......
......@@ -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
......
......@@ -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
#------------------------------------------------------------------------------
......
#!/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 "$@"
#------------------------------------------------------------------------------
#!/bin/sh
cd "${0%/*}" || exit # Run from this directory
cd "${0%/*}" || exit # Run from this directory
#------------------------------------------------------------------------------
wmakeLnInclude -u decompositionMethods
wmakeLnInclude -u kahipDecomp
......
......@@ -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
# <http://www.gnu.org/licenses/>.
# 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
......
......@@ -79,7 +79,7 @@ then
cat<<HELP_FULL
-debug Define c++DBUG='-DFULLDEBUG -g -O0' as override
-no-scheduler Disable scheduled parallel compilation
-show-api Print api value
-show-api Print api value (from Make rules)
-show-ext-so Print shared library extension (with '.' separator)
-show-c Print C compiler value
-show-cflags Print C compiler flags
......
......@@ -6,23 +6,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 OpenCFD Ltd.
# Copyright (C) 2018-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 <http://www.gnu.org/licenses/>.
# 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=<digits>
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment