mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: command-line query for the OPENFOAM_PLUS wmake value (issue #378)
Examples,
wmakePrintBuild -plus
Check if value is known
(ie, everything configured and also OpenFOAM+):
if wmakePrintBuild -plus >/dev/null 2>&1
then
echo YES
else
echo NO
fi
Check if version is new enough
if ofver=$(wmakePrintBuild -plus 2>/dev/null) && [ "$ofver" -ge 1612 ]
then
echo YES
else
echo NO
fi
Conditionals
ofver=$(wmakePrintBuild -plus 2>/dev/null)
case "${ofver:=0}" in
1612)
echo "something for 1612
;;
1706)
echo "something for 1706
;;
esac
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
# \\ / O peration |
|
# \\ / O peration |
|
||||||
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
# \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
# License
|
# License
|
||||||
# This file is part of OpenFOAM.
|
# This file is part of OpenFOAM.
|
||||||
@ -48,6 +48,8 @@ options:
|
|||||||
-pkg TAG specify packager/release tag ('none' marks an empty packager)
|
-pkg TAG specify packager/release tag ('none' marks an empty packager)
|
||||||
-short report short version information (ie, without pkg tag)
|
-short report short version information (ie, without pkg tag)
|
||||||
-version VER specify an alternative version
|
-version VER specify an alternative version
|
||||||
|
-plus report wmake value of OPENFOAM_PLUS and exit
|
||||||
|
-help
|
||||||
|
|
||||||
Print the version used when building the project, in this order of precedence:
|
Print the version used when building the project, in this order of precedence:
|
||||||
* the git head commit (prefixed with \$WM_PROJECT_VERSION)
|
* the git head commit (prefixed with \$WM_PROJECT_VERSION)
|
||||||
@ -58,11 +60,23 @@ USAGE
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Report error and exit
|
||||||
|
die()
|
||||||
|
{
|
||||||
|
exec 1>&2
|
||||||
|
echo
|
||||||
|
echo "Error encountered:"
|
||||||
|
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
|
||||||
|
echo
|
||||||
|
echo "See '${0##*/} -help' for usage"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Parse arguments and options
|
# Parse arguments and options
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
unset checkOnly update package version shortOpt
|
unset checkOnly update package version optPlus optShort
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]
|
while [ "$#" -gt 0 ]
|
||||||
do
|
do
|
||||||
@ -81,21 +95,25 @@ do
|
|||||||
update=true
|
update=true
|
||||||
;;
|
;;
|
||||||
-pkg | -package)
|
-pkg | -package)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||||
# Mark empty as 'none', disallow '!' in string
|
# Mark empty as 'none', disallow '!' in string
|
||||||
package=$(echo "${2:-none}" | sed -e 's/!//g')
|
package=$(echo "${2:-none}" | sed -e 's/!//g')
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
-short)
|
-short)
|
||||||
shortOpt=true
|
optShort=true
|
||||||
;;
|
;;
|
||||||
-v | -version)
|
-v | -version)
|
||||||
[ "$#" -ge 2 ] || usage "'$1' option requires an argument"
|
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
|
||||||
version="$2"
|
version="$2"
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
|
-plus)
|
||||||
|
optPlus=true
|
||||||
|
break
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
usage "unknown option/argument: '$1'"
|
die "unknown option/argument: '$1'"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
@ -106,7 +124,6 @@ done
|
|||||||
# Persistent build tag
|
# Persistent build tag
|
||||||
build="$WM_PROJECT_DIR/.build"
|
build="$WM_PROJECT_DIR/.build"
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as
|
# Retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as
|
||||||
# version [packager]
|
# version [packager]
|
||||||
@ -139,7 +156,23 @@ printTag()
|
|||||||
# Get the version
|
# Get the version
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [ -n "$version" ]
|
if [ "$optPlus" = true ]
|
||||||
|
then
|
||||||
|
# Retrieve OPENFOAM_PLUS=<digits> from $WM_DIR/rules/General/general
|
||||||
|
version=$(
|
||||||
|
sed -ne 's@^.*OPENFOAM_PLUS=\([0-9][0-9]*\).*@\1@p' \
|
||||||
|
$WM_DIR/rules/General/general 2>/dev/null | tail -1
|
||||||
|
)
|
||||||
|
|
||||||
|
if [ -n "$version" ]
|
||||||
|
then
|
||||||
|
echo "$version"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "no wmake definition for OPENFOAM_PLUS" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [ -n "$version" ]
|
||||||
then
|
then
|
||||||
# Specified a version - no error possible
|
# Specified a version - no error possible
|
||||||
rc=0
|
rc=0
|
||||||
@ -164,10 +197,10 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Retrieve old values
|
# Retrieve old values (oldPackage oldVersion)
|
||||||
getOldValues
|
getOldValues
|
||||||
|
|
||||||
if [ "$shortOpt" = true ]
|
if [ "$optShort" = true ]
|
||||||
then
|
then
|
||||||
unset package oldPackage
|
unset package oldPackage
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user