diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 50737442181af95a278d1cd85888c4c657182983..5a60a51f9acb6b58ec91a449436e5389e78ca151 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -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'" ;; diff --git a/wmake/makefiles/info b/wmake/makefiles/info index 5985f48a78943a677f36229043a23b666f56215d..65fabf1f6f8ab92949dfc9ee03e2a0bf7492e7a0 100644 --- a/wmake/makefiles/info +++ b/wmake/makefiles/info @@ -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)))" diff --git a/wmake/scripts/wmakeFunctions b/wmake/scripts/wmakeFunctions index c228ba5cad8b2ddef0249f171b119dbd73d494df..d564c6883b7d402843a1a7dc5e0376e467f00893 100644 --- a/wmake/scripts/wmakeFunctions +++ b/wmake/scripts/wmakeFunctions @@ -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) diff --git a/wmake/wmake b/wmake/wmake index 1892932ef5fa9ff5ab9faf4eb99f71be5d4d3253..abb07294ed59c1ee79e079c2541f12d7bfbdb7c4 100755 --- a/wmake/wmake +++ b/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'"