CONFIG: backport of META-INFO information (#1367)

This commit is contained in:
Mark Olesen 2019-07-10 20:19:01 +02:00
parent 696ff79107
commit ead4b73064
4 changed files with 88 additions and 2 deletions

9
META-INFO/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# Do not track build information
build-info
# Do not track time-stamp
time-stamp
# Do not track any manifest files
Manifest.txt
manifest.txt

5
META-INFO/README.md Normal file
View File

@ -0,0 +1,5 @@
# META-INFO
Meta-information is for OpenFOAM internal use only.
(Backport from 1812)

2
META-INFO/api-info Normal file
View File

@ -0,0 +1,2 @@
api=1612
patch=180618

View File

@ -3,9 +3,11 @@
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
# \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
# \\ / A nd | Copyright (C) 2008-2011, 2017-2018 OpenCFD Ltd.
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# | Copyright (C) 2011-2016 OpenFOAM Foundation
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
@ -63,6 +65,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
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
-help Print the usage
@ -184,6 +188,62 @@ setVersion()
}
#-------------------------------------------------------------------------------
# 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()
{
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)"
if [ -n "$value" ]
then
echo "$value"
else
return 1
fi
}
#-------------------------------------------------------------------------------
optMode=ugo # Default mode is always 'ugo'
unset shellOutput verboseOutput
unset optAll optConfig optList optVersion
@ -195,6 +255,16 @@ do
-h | -help*)
printHelp
;;
-show-api)
# Show API and exit
getApi
exit $?
;;
-show-patch)
# Show patch level and exit
getPatchLevel
exit $?
;;
-a | -all)
optAll=true
unset shellOutput verboseOutput