From c70d7237e29fd34f1c1fb6b2503adfaa7763abe2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Sun, 17 Dec 2017 15:19:09 +0100 Subject: [PATCH] STYLE: more robust extraction of API number from wmake rules --- wmake/wmakePrintBuild | 39 +++++++++++++-------------------------- 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 3c56d7cfd4..01351975a0 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -7,27 +7,12 @@ # \\/ M anipulation | Copyright (C) 2016-2017 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, licensed under GNU General Public License +# . # # Script # wmakePrintBuild # -# Usage -# wmakePrintBuild [OPTION] -# # Description # Print the version used when building the project # @@ -48,7 +33,7 @@ options: -pkg TAG specify packager/release tag ('none' marks an empty packager) -short report short version information (ie, without pkg tag) -version VER specify an alternative version - -plus report wmake value of OPENFOAM_PLUS and exit + -api report wmake value of OPENFOAM/OPENFOAM_API/OPENFOAM_PLUS -help Print the version used when building the project, in this order of precedence: @@ -76,7 +61,7 @@ die() #------------------------------------------------------------------------------ # Parse arguments and options #------------------------------------------------------------------------------ -unset checkOnly update package version optPlus optShort +unset checkOnly update package version optApi optShort while [ "$#" -gt 0 ] do @@ -108,8 +93,8 @@ do version="$2" shift ;; - -plus) - optPlus=true + -api | -plus) + optApi=true break ;; *) @@ -156,11 +141,13 @@ printTag() # Get the version #------------------------------------------------------------------------------ -if [ "$optPlus" = true ] +if [ -n "$optApi" ] then - # Retrieve OPENFOAM_PLUS= from $WM_DIR/rules/General/general + # Extract API version from $WM_DIR/rules/General/general + # Any of OPENFOAM=, OPENFOAM_API=, OPENFOAM_COM= + # OPENFOAM_PLUS= version=$( - sed -ne 's@^.*OPENFOAM_PLUS=\([0-9][0-9]*\).*@\1@p' \ + sed -ne 's@^.*OPENFOAM\(_API|_COM|_PLUS\)*=\([0-9][0-9]*\).*@\2@p' \ $WM_DIR/rules/General/general 2>/dev/null ) @@ -169,7 +156,7 @@ then echo "$version" exit 0 else - echo "no wmake definition for OPENFOAM_PLUS" 1>&2 + echo "no wmake definition for OPENFOAM API" 1>&2 exit 1 fi elif [ -n "$version" ] @@ -200,7 +187,7 @@ fi # Retrieve old values (oldPackage oldVersion) getOldValues -if [ "$optShort" = true ] +if [ -n "$optShort" ] then unset package oldPackage fi