ENH: robustness, consistency for wmake -show-api, -version
- add to wmakeFunctions to ensure it works even without 'make' being installed. Exit immediately after -show-api for consistency with -version. foamEtcFile: - drop warnings for some old (pre-v1812) defunct options and simply flag as unknown options. - handle -version, --version as equivalent to -show-api
This commit is contained in:
parent
1afa6f1b46
commit
c7bde70ecb
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -74,15 +74,16 @@ options:
|
||||
-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
|
||||
-version | --version Print version (same as -show-api)
|
||||
-help Print the usage
|
||||
|
||||
Locate user/group/other file as per '#includeEtc'
|
||||
|
||||
Do not group single character options.
|
||||
Equivalent options:
|
||||
| -mode=MODE | -mode MODE | -m MODE
|
||||
| -prefix=DIR | -prefix DIR | -p DIR [obsolete 1812]
|
||||
| -version=VER | -version VER | -v VER [obsolete 1812]
|
||||
| -mode=MODE | -mode MODE | -m MODE
|
||||
| -prefix=DIR [obsolete 1812]
|
||||
| -version=VER [obsolete 1812]
|
||||
|
||||
Exit status
|
||||
0 when the file is found. Print resolved path to stdout.
|
||||
@ -149,7 +150,7 @@ do
|
||||
-h | -help*)
|
||||
printHelp
|
||||
;;
|
||||
-show-api) # Show API and exit
|
||||
-show-api | -version | --version) # Show API and exit
|
||||
getApiInfo api
|
||||
exit $?
|
||||
;;
|
||||
@ -202,25 +203,17 @@ do
|
||||
-s | -silent)
|
||||
optSilent=true
|
||||
;;
|
||||
|
||||
-etc=*)
|
||||
# FOAM_CONFIG_ETC for finding files. Empty unsets it (later)
|
||||
export FOAM_CONFIG_ETC="${1#*=}"
|
||||
;;
|
||||
-prefix=* | -version=*)
|
||||
echo "ignored defunct option '${1%%=*}'" 1>&2
|
||||
;;
|
||||
-p | -prefix | -v | -version)
|
||||
# Ignored, but still need to check/discard its argument
|
||||
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||
echo "ignored defunct option '$1'" 1>&2
|
||||
shift
|
||||
;;
|
||||
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-prefix=* | -version=*)
|
||||
echo "ignored defunct option '${1%%=*}'" 1>&2
|
||||
;;
|
||||
-*)
|
||||
die "unknown option: '$1'"
|
||||
;;
|
||||
|
@ -5,7 +5,7 @@
|
||||
# \\ / A nd | www.openfoam.com
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
@ -55,6 +55,7 @@ COMPILE_CXX := $(strip $(CC) $(c++FLAGS))
|
||||
# Display information
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Extract WM_VERSION = OPENFOAM=<digits>
|
||||
.PHONY: api
|
||||
api:
|
||||
@echo "$(lastword $(subst =, ,$(WM_VERSION)))"
|
||||
|
@ -55,6 +55,28 @@ checkEnv()
|
||||
}
|
||||
|
||||
|
||||
# (api) from WM_DIR/rules/General/general
|
||||
# - extract WM_VERSION = OPENFOAM=<digits>
|
||||
getApiOpenFOAM()
|
||||
{
|
||||
local rulesFile="$WM_DIR/rules/General/general"
|
||||
local value
|
||||
|
||||
if [ -n "$WM_DIR" ] && [ -f "$rulesFile" ]
|
||||
then
|
||||
value="$(sed -ne 's@^ *WM_VERSION *= *OPENFOAM=\([0-9][0-9]*\).*@\1@p' "$rulesFile" 2>/dev/null)"
|
||||
fi
|
||||
|
||||
if [ -n "$value" ]
|
||||
then
|
||||
echo "$value"
|
||||
else
|
||||
echo "Could not extract OpenFOAM API value" 1>&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Set FOAM_MODULE_PREFIX according to
|
||||
# - absolute/relative path
|
||||
# - predefined type (u,user | g,group | o,openfoam)
|
||||
|
16
wmake/wmake
16
wmake/wmake
@ -7,7 +7,7 @@
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
# Copyright (C) 2017-2020 OpenCFD Ltd.
|
||||
# Copyright (C) 2017-2021 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
@ -183,7 +183,8 @@ die()
|
||||
make="make"
|
||||
|
||||
# Print compiler/system information (serial only)
|
||||
printInfo() {
|
||||
printInfo()
|
||||
{
|
||||
if [ -f "$WM_DIR"/makefiles/info ]
|
||||
then
|
||||
make --no-print-directory -f "$WM_DIR"/makefiles/info "$@"
|
||||
@ -193,6 +194,7 @@ printInfo() {
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Set nCores to the number of cores on the machine
|
||||
@ -265,7 +267,7 @@ do
|
||||
setModulePrefix "${1#*=}"
|
||||
;;
|
||||
|
||||
-show-api | -show-ext-so | \
|
||||
-show-ext-so | \
|
||||
-show-compile-c | -show-c | -show-cflags | -show-cflags-arch | \
|
||||
-show-compile-cxx | -show-cxx | -show-cxxflags | -show-cxxflags-arch | \
|
||||
-show-mpi-compile | -show-mpi-link )
|
||||
@ -323,10 +325,10 @@ do
|
||||
optUpdate=true
|
||||
: "${optAll:=all}" # implies 'all', unless previously set
|
||||
;;
|
||||
-version | --version)
|
||||
printInfo api
|
||||
optShow=true
|
||||
break;
|
||||
|
||||
-show-api | -version | --version)
|
||||
getApiOpenFOAM # From wmakeFunctions
|
||||
exit "$?"
|
||||
;;
|
||||
-*)
|
||||
die "unknown option: '$1'"
|
||||
|
Loading…
Reference in New Issue
Block a user