From 45fe65f83ee04ab983d34a2c5770b17662ca9fce Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 10 Jul 2019 20:19:01 +0200 Subject: [PATCH] CONFIG: backport of META-INFO information (#1367) --- META-INFO/.gitignore | 9 ++++++ META-INFO/README.md | 5 +++ META-INFO/api-info | 2 ++ bin/foamEtcFile | 74 ++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 META-INFO/.gitignore create mode 100644 META-INFO/README.md create mode 100644 META-INFO/api-info diff --git a/META-INFO/.gitignore b/META-INFO/.gitignore new file mode 100644 index 0000000000..813c7152d6 --- /dev/null +++ b/META-INFO/.gitignore @@ -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 diff --git a/META-INFO/README.md b/META-INFO/README.md new file mode 100644 index 0000000000..e241867775 --- /dev/null +++ b/META-INFO/README.md @@ -0,0 +1,5 @@ +# META-INFO + +Meta-information is for OpenFOAM internal use only. + +(Backport from 1812) diff --git a/META-INFO/api-info b/META-INFO/api-info new file mode 100644 index 0000000000..53e43c3d6c --- /dev/null +++ b/META-INFO/api-info @@ -0,0 +1,2 @@ +api=1706 +patch=180618 diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 195b91bdbe..2564b4ed02 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -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 # . @@ -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