COMP: adjust headers for more detailed build info in the future (issue #1010)

- this splits a larger changeset for a gradual implementation
This commit is contained in:
Mark Olesen
2018-11-29 21:01:01 +01:00
parent 9e094f1f07
commit 4b7e11fc8b
7 changed files with 67 additions and 35 deletions

View File

@ -31,6 +31,7 @@ Description
#include <typeinfo> #include <typeinfo>
#include "foamVersion.H" #include "foamVersion.H"
#include "Switch.H"
#include "IOstreams.H" #include "IOstreams.H"
using namespace Foam; using namespace Foam;
@ -49,10 +50,13 @@ int main()
Info Info
<< "\nVersion information (namespace)" << nl << "\nVersion information (namespace)" << nl
<< "patched? = " << Switch(foamVersion::patched()) << nl
<< "api " << foamVersion::api << nl << "api " << foamVersion::api << nl
<< "patch " << foamVersion::patch << nl
<< "version " << foamVersion::version << nl << "version " << foamVersion::version << nl
<< "build " << foamVersion::build << nl << "build " << foamVersion::build << nl
<< "buildArch " << foamVersion::buildArch << nl; << "buildArch " << foamVersion::buildArch << nl;
Info Info
<< "\nTypes" << nl << "\nTypes" << nl
<< "version " << typeid(foamVersion::version).name() << nl << "version " << typeid(foamVersion::version).name() << nl

View File

@ -194,14 +194,15 @@ public:
//- Foam::findEtcDirs("caseDicts/postProcessing") //- Foam::findEtcDirs("caseDicts/postProcessing")
// //
// -# \b user settings // -# \b user settings
// - ~/.OpenFOAM/$WM_PROJECT_VERSION/"caseDicts/postProcessing" // - ~/.OpenFOAM/{PROJECT_API}/"caseDicts/postProcessing"
// - ~/.OpenFOAM/"caseDicts/postProcessing" // - ~/.OpenFOAM/"caseDicts/postProcessing"
// -# \b group settings // -# \b group settings
// - $WM_PROJECT_SITE/$WM_PROJECT_VERSION/"caseDicts/postProcessing" // - $WM_PROJECT_SITE/{PROJECT_API}/"caseDicts/postProcessing"
// - $WM_PROJECT_SITE/"caseDicts/postProcessing" // - $WM_PROJECT_SITE/"caseDicts/postProcessing"
// -# \b other (shipped) settings // -# \b other (shipped) settings
// - $WM_PROJECT_DIR/etc/"caseDicts/postProcessing" // - $WM_PROJECT_DIR/etc/"caseDicts/postProcessing"
// //
// Where {PROJECT_API} is the value of the OPENFOAM define.
// See further notes in Foam::findEtcFiles() // See further notes in Foam::findEtcFiles()
static void list(); static void list();

View File

@ -872,10 +872,15 @@ void Foam::argList::parse
{ {
IOobject::writeBanner(Info, true) IOobject::writeBanner(Info, true)
<< "Build : " << foamVersion::build.c_str() << "Build : " << foamVersion::build.c_str()
#if OPENFOAM << " (OPENFOAM=" << OPENFOAM;
<< " (OPENFOAM=" << OPENFOAM << ')'
#endif if (foamVersion::patched())
<< nl {
// Patch-level, when defined
Info<< " patch=" << foamVersion::patch.c_str();
}
Info<< ')' << nl
<< "Arch : " << foamVersion::buildArch << nl << "Arch : " << foamVersion::buildArch << nl
<< "Exec : " << commandLine_.c_str() << nl << "Exec : " << commandLine_.c_str() << nl
<< "Date : " << dateString.c_str() << nl << "Date : " << dateString.c_str() << nl

View File

@ -61,17 +61,16 @@ fileNameList findEtcDirs
// The search hierarchy corresponds to that of the foamEtcFile script, // The search hierarchy corresponds to that of the foamEtcFile script,
// which allows for version-specific and version-independent files: // which allows for version-specific and version-independent files:
// -# \b user settings // -# \b user settings
// - ~/.OpenFOAM/$WM_PROJECT_VERSION // - ~/.OpenFOAM/{PROJECT_API}
// - ~/.OpenFOAM/ // - ~/.OpenFOAM/
// -# \b group settings // -# \b group settings
// - $WM_PROJECT_SITE/$WM_PROJECT_VERSION // - $WM_PROJECT_SITE/{PROJECT_API}
// - $WM_PROJECT_SITE/ // - $WM_PROJECT_SITE/
// -# \b other (shipped) settings // -# \b other (shipped) settings
// - $WM_PROJECT_DIR/etc/ // - $WM_PROJECT_DIR/etc/
// //
// \note Treatment of empty or undefined variables // Where {PROJECT_API} is the value of the OPENFOAM define.
// - \b \$WM_PROJECT_VERSION : Use compile-time value of OPENFOAM // - \b \$WM_PROJECT_SITE : If unset, use $WM_PROJECT_DIR/site
// - \b \$WM_PROJECT_SITE : Use $WM_PROJECT_DIR/site
// //
// \return The list of full paths of all the matching files or // \return The list of full paths of all the matching files or
// an empty list if the name cannot be found. // an empty list if the name cannot be found.

View File

@ -41,22 +41,18 @@ Description
// Value from OPENFOAM, defined in wmake rules // Value from OPENFOAM, defined in wmake rules
const int Foam::foamVersion::api const int Foam::foamVersion::api
( (
#if OPENFOAM
OPENFOAM OPENFOAM
#else
0
#endif
); );
// Value of VERSION\_STRING generated by the build-script // Value of PATCH generated by the build-script
const std::string Foam::foamVersion::version const std::string Foam::foamVersion::patch
( (
"VERSION_STRING" ""
); );
// Value of the BUILD\_STRING generated by the build-script // Value of the BUILD generated by the build-script
const std::string Foam::foamVersion::build const std::string Foam::foamVersion::build
( (
"BUILD_STRING" "BUILD_STRING"
@ -78,6 +74,14 @@ const std::string Foam::foamVersion::buildArch
); );
// Value of VERSION generated by the build-script
// Only required for compatibility
const std::string Foam::foamVersion::version
(
"VERSION_STRING"
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Setup an error handler for the global new operator // Setup an error handler for the global new operator

View File

@ -30,18 +30,31 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::foamVersion::patched()
{
// Patch-level, when defined (non-zero) and not some @TOKEN@ rubbish
return
(
foamVersion::patch.size() && foamVersion::patch[0] != '@'
&& (foamVersion::patch.size() > 1 || foamVersion::patch[0] != '0')
);
}
void Foam::foamVersion::printBuildInfo(const bool full) void Foam::foamVersion::printBuildInfo(const bool full)
{ {
// Can use #if OPENFOAM directly // Can use #if OPENFOAM directly
Info<<"Using: OpenFOAM-" << foamVersion::version.c_str() Info<< "Using: OpenFOAM-" << foamVersion::version.c_str()
<< " (see www.OpenFOAM.com)" << nl << " (" << OPENFOAM << ") (see www.OpenFOAM.com)" << nl
<< "Build: " << foamVersion::build.c_str() << "Build: " << foamVersion::build.c_str();
// The same as using foamVersion::api
#if OPENFOAM if (foamVersion::patched())
<< " (OPENFOAM=" << OPENFOAM << ')' {
#endif // Patch-level, when defined
<< nl; Info<< " (patch=" << foamVersion::patch.c_str() << ')';
}
Info<< nl;
if (full) if (full)
{ {

View File

@ -2,8 +2,8 @@
========= | ========= |
\\ / 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 OpenFOAM Foundation \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -83,8 +83,8 @@ namespace Foam
// The value is 0 if OPENFOAM was not defined. // The value is 0 if OPENFOAM was not defined.
extern const int api; extern const int api;
//- OpenFOAM version (name or stringified number) as a std::string //- OpenFOAM patch number as a std::string
extern const std::string version; extern const std::string patch;
//- OpenFOAM build information as a std::string //- OpenFOAM build information as a std::string
extern const std::string build; extern const std::string build;
@ -93,13 +93,19 @@ namespace Foam
//- (machine endian, label/scalar sizes) as a std::string //- (machine endian, label/scalar sizes) as a std::string
extern const std::string buildArch; extern const std::string buildArch;
//- OpenFOAM version (name or stringified number) as a std::string
extern const std::string version;
//- Test if the patch string appeared to be in use,
//- which is when it is defined (non-zero).
bool patched();
//- Print information about version, build, arch to Info //- Print information about version, build, arch to Info
// //
// Eg, // Eg,
// \code // \code
// Using: OpenFOAM-<VERSION> (see www.OpenFOAM.com) // Using: OpenFOAM-<MAJOR> (see www.OpenFOAM.com)
// Build: <BUILD> (OPENFOAM=<API_LEVEL>) // Build: <BUILD>
// Arch: "<ARCH_INFO>" // Arch: "<ARCH_INFO>"
// \endcode // \endcode
// //
@ -112,8 +118,8 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Compatibility names (1806 and earlier). // Compatibility names (1806 and earlier).
// Historically assumed to be called within the Foam namespace, so they are // Historically assumed to be called within the Foam namespace, they are
// defined without the Foam namespace qualifier. // thus defined without the Foam namespace qualifier.
// //
// - FOAMversion: c-string // - FOAMversion: c-string
// - FOAMbuild: c-string // - FOAMbuild: c-string