CONFIG: add build information into shell session

- more closely reflect what the binaries report
- report the installation path
- change PS1 case/separator to roughly correspond to package names

STYLE: adjust README to mention upcoming v2112
This commit is contained in:
Mark Olesen
2021-11-24 17:40:01 +01:00
parent 1804d3fed5
commit bcf8a48c68
5 changed files with 54 additions and 16 deletions

View File

@ -49,7 +49,7 @@
<!-- <!--
Providing details of your set-up can help us identify any issues, e.g. Providing details of your set-up can help us identify any issues, e.g.
OpenFOAM version : v1806|v1812|v1906|v1912|v2006|v2012|v2106 etc OpenFOAM version : v2112|v2106|v2012|v2006|v1912|v1906 etc
Operating system : ubuntu|openSUSE|centos etc Operating system : ubuntu|openSUSE|centos etc
Hardware info : any info that may help? Hardware info : any info that may help?
Compiler : gcc|intel|clang etc Compiler : gcc|intel|clang etc

View File

@ -40,9 +40,9 @@ Violations of the Trademark are monitored, and will be duly prosecuted.
If OpenFOAM has already been compiled on your system, simply source If OpenFOAM has already been compiled on your system, simply source
the appropriate `etc/bashrc` or `etc/cshrc` file and get started. the appropriate `etc/bashrc` or `etc/cshrc` file and get started.
For example, for the OpenFOAM-v2106 version: For example, for the OpenFOAM-v2112 version:
``` ```
source /installation/path/OpenFOAM-v2106/etc/bashrc source /installation/path/OpenFOAM-v2112/etc/bashrc
``` ```
## Compiling OpenFOAM ## Compiling OpenFOAM
@ -127,8 +127,8 @@ These 3rd-party sources are normally located in a directory parallel
to the OpenFOAM directory. For example, to the OpenFOAM directory. For example,
``` ```
/path/parent /path/parent
|-- OpenFOAM-v2106 |-- OpenFOAM-v2112
\-- ThirdParty-v2106 \-- ThirdParty-v2112
``` ```
There are, however, many cases where this simple convention is inadequate: There are, however, many cases where this simple convention is inadequate:
@ -136,7 +136,7 @@ There are, however, many cases where this simple convention is inadequate:
operating system or cluster installation provides it) operating system or cluster installation provides it)
* When we have changed the OpenFOAM directory name to some arbitrary * When we have changed the OpenFOAM directory name to some arbitrary
directory name, e.g. openfoam-sandbox2106, etc.. directory name, e.g. openfoam-sandbox2112, etc..
* When we would like any additional 3rd party software to be located * When we would like any additional 3rd party software to be located
inside of the OpenFOAM directory to ensure that the installation is inside of the OpenFOAM directory to ensure that the installation is
@ -156,9 +156,9 @@ when locating the ThirdParty directory with the following precedence:
2. PREFIX/ThirdParty-VERSION 2. PREFIX/ThirdParty-VERSION
* this corresponds to the traditional approach * this corresponds to the traditional approach
3. PREFIX/ThirdParty-vAPI 3. PREFIX/ThirdParty-vAPI
* allows for an updated value of VERSION, *eg*, `v2106-myCustom`, * allows for an updated value of VERSION, *eg*, `v2112-myCustom`,
without requiring a renamed ThirdParty. The API value would still without requiring a renamed ThirdParty. The API value would still
be `2106` and the original `ThirdParty-v2106/` would be found. be `2112` and the original `ThirdParty-v2112/` would be found.
4. PREFIX/ThirdParty-API 4. PREFIX/ThirdParty-API
* same as the previous example, but using an unadorned API value. * same as the previous example, but using an unadorned API value.
5. PREFIX/ThirdParty-common 5. PREFIX/ThirdParty-common

View File

@ -46,6 +46,9 @@
# The '-show-api' and '-show-patch' options extract values from # The '-show-api' and '-show-patch' options extract values from
# the "META-INFO/api-info" file # the "META-INFO/api-info" file
# #
# The '-show-build' options extract values from
# the "META-INFO/build-info" file
#
# SeeAlso # SeeAlso
# META-INFO/README.md for other routines that also use META-INFO. # META-INFO/README.md for other routines that also use META-INFO.
# #
@ -71,6 +74,7 @@ options:
-etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative etc directory -etc=[DIR] set/unset FOAM_CONFIG_ETC for alternative etc directory
-show-api Print META-INFO api value and exit -show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit -show-patch Print META-INFO patch value and exit
-show-build Print META-INFO build value and exit
-with-api=NUM Specify alternative api value to search with -with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output -quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output -silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -155,6 +159,14 @@ getApiInfo()
} }
# Get 'build' from META-INFO/build-info
getBuildValue()
{
value="$(sed -ne 's@^build *= *\([^ ]*\).*@\1@p' "$projectDir"/META-INFO/build-info 2>/dev/null)"
echo "$value"
}
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
unset shellOutput verboseOutput unset shellOutput verboseOutput
unset optAll optConfig optList projectApi unset optAll optConfig optList projectApi
@ -177,6 +189,10 @@ do
getApiInfo patch getApiInfo patch
exit $? exit $?
;; ;;
-show-build) # Show build information and exit
getBuildValue
exit $?
;;
-with-api=*) -with-api=*)
projectApi="${1#*=}" projectApi="${1#*=}"
;; ;;

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com # \\ / A nd | www.openfoam.com
# \\/ M anipulation | # \\/ M anipulation |
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Copyright (C) 2019-2020 OpenCFD Ltd. # Copyright (C) 2019-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# License # License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -68,26 +68,48 @@ then
# Some feedback # Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ] if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
then then
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)" _foam_api="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-api 2>/dev/null)"
_foam_patch="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
_foam_build="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-build 2>/dev/null)"
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2 if [ "${_foam_patch:-0}" = 0 ]
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2 then
unset _foam_patch
fi
if [ -n "$_foam_build" ]
then
# Everything there - format like binary -help output
_foam_build="${_foam_build}${_foam_patch:+ (patch=${_foam_patch})}"
_foam_verinfo="${_foam_api}"
else
# Missing build info - combine api and patch info together
_foam_verinfo="${_foam_api}${_foam_patch:+ patch=${_foam_patch}}"
fi
echo "Using: OpenFOAM-$WM_PROJECT_VERSION (${_foam_verinfo}) - visit www.openfoam.com" 1>&2
if [ -n "$_foam_build" ]
then
echo "Build: ${_foam_build}" 1>&2
fi
echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2 echo "Arch: $WM_OPTIONS (mpi=$FOAM_MPI)" 1>&2
# Arch: LSB;label=32;scalar=64
## echo "$WM_PROJECT_DIR" 1>&2
## echo 1>&2 ## echo 1>&2
# Set prompt as reminder that this is a shell session # Set prompt as reminder that this is a shell session
# Chalmers likes this one: # Chalmers likes this one:
# PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'$(foamPwd)\n\u\$ ' # PS1="openfoam${_foam_api}:"'$(foamPwd)\n\u\$ '
PS1="OpenFOAM${FOAM_API:+-$FOAM_API}:"'\w/\n\u\$ ' PS1="openfoam${_foam_api}:"'\w/\n\u\$ '
unset _foam_api _foam_patch _foam_build _foam_verinfo
fi fi
else else
echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2 echo "Could not locate OpenFOAM etc/bashrc in '$projectDir'" 1>&2
fi fi
echo 1>&2
echo "openfoam = $WM_PROJECT_DIR" 1>&2
echo "OpenFOAM shell session - use exit to quit" 1>&2 echo "OpenFOAM shell session - use exit to quit" 1>&2
echo 1>&2 echo 1>&2

View File

@ -1,4 +1,4 @@
## Known Build Issues (v2012, v2106) ## Known Build Issues (v2012, v2106, v2112)
### Windows cross-compilation ### Windows cross-compilation