diff --git a/applications/test/foamVersion/Test-foamVersion.C b/applications/test/foamVersion/Test-foamVersion.C index 9eeb08ef3b..fc8490df34 100644 --- a/applications/test/foamVersion/Test-foamVersion.C +++ b/applications/test/foamVersion/Test-foamVersion.C @@ -31,6 +31,7 @@ Description #include #include "foamVersion.H" +#include "Switch.H" #include "IOstreams.H" using namespace Foam; @@ -49,10 +50,13 @@ int main() Info << "\nVersion information (namespace)" << nl + << "patched? = " << Switch(foamVersion::patched()) << nl << "api " << foamVersion::api << nl + << "patch " << foamVersion::patch << nl << "version " << foamVersion::version << nl << "build " << foamVersion::build << nl << "buildArch " << foamVersion::buildArch << nl; + Info << "\nTypes" << nl << "version " << typeid(foamVersion::version).name() << nl diff --git a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H index 0743ffffca..4064bbaed2 100644 --- a/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H +++ b/src/OpenFOAM/db/functionObjects/functionObjectList/functionObjectList.H @@ -194,14 +194,15 @@ public: //- Foam::findEtcDirs("caseDicts/postProcessing") // // -# \b user settings - // - ~/.OpenFOAM/$WM_PROJECT_VERSION/"caseDicts/postProcessing" + // - ~/.OpenFOAM/{PROJECT_API}/"caseDicts/postProcessing" // - ~/.OpenFOAM/"caseDicts/postProcessing" // -# \b group settings - // - $WM_PROJECT_SITE/$WM_PROJECT_VERSION/"caseDicts/postProcessing" + // - $WM_PROJECT_SITE/{PROJECT_API}/"caseDicts/postProcessing" // - $WM_PROJECT_SITE/"caseDicts/postProcessing" // -# \b other (shipped) settings // - $WM_PROJECT_DIR/etc/"caseDicts/postProcessing" // + // Where {PROJECT_API} is the value of the OPENFOAM define. // See further notes in Foam::findEtcFiles() static void list(); diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 9677383da9..d5d1cd32f0 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -872,10 +872,15 @@ void Foam::argList::parse { IOobject::writeBanner(Info, true) << "Build : " << foamVersion::build.c_str() - #if OPENFOAM - << " (OPENFOAM=" << OPENFOAM << ')' - #endif - << nl + << " (OPENFOAM=" << OPENFOAM; + + if (foamVersion::patched()) + { + // Patch-level, when defined + Info<< " patch=" << foamVersion::patch.c_str(); + } + + Info<< ')' << nl << "Arch : " << foamVersion::buildArch << nl << "Exec : " << commandLine_.c_str() << nl << "Date : " << dateString.c_str() << nl diff --git a/src/OpenFOAM/global/etcFiles/etcFiles.H b/src/OpenFOAM/global/etcFiles/etcFiles.H index 859c1010b5..c6e7665d31 100644 --- a/src/OpenFOAM/global/etcFiles/etcFiles.H +++ b/src/OpenFOAM/global/etcFiles/etcFiles.H @@ -61,17 +61,16 @@ fileNameList findEtcDirs // The search hierarchy corresponds to that of the foamEtcFile script, // which allows for version-specific and version-independent files: // -# \b user settings -// - ~/.OpenFOAM/$WM_PROJECT_VERSION +// - ~/.OpenFOAM/{PROJECT_API} // - ~/.OpenFOAM/ // -# \b group settings -// - $WM_PROJECT_SITE/$WM_PROJECT_VERSION +// - $WM_PROJECT_SITE/{PROJECT_API} // - $WM_PROJECT_SITE/ // -# \b other (shipped) settings // - $WM_PROJECT_DIR/etc/ // -// \note Treatment of empty or undefined variables -// - \b \$WM_PROJECT_VERSION : Use compile-time value of OPENFOAM -// - \b \$WM_PROJECT_SITE : Use $WM_PROJECT_DIR/site +// Where {PROJECT_API} is the value of the OPENFOAM define. +// - \b \$WM_PROJECT_SITE : If unset, use $WM_PROJECT_DIR/site // // \return The list of full paths of all the matching files or // an empty list if the name cannot be found. diff --git a/src/OpenFOAM/global/global.Cver b/src/OpenFOAM/global/global.Cver index 6795b9e80b..5e8e56ad5a 100644 --- a/src/OpenFOAM/global/global.Cver +++ b/src/OpenFOAM/global/global.Cver @@ -41,22 +41,18 @@ Description // Value from OPENFOAM, defined in wmake rules const int Foam::foamVersion::api ( - #if OPENFOAM OPENFOAM - #else - 0 - #endif ); -// Value of VERSION\_STRING generated by the build-script -const std::string Foam::foamVersion::version +// Value of PATCH generated by the build-script +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 ( "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 diff --git a/src/OpenFOAM/global/version/foamVersion.C b/src/OpenFOAM/global/version/foamVersion.C index b9a387d1b5..4b71a18fc3 100644 --- a/src/OpenFOAM/global/version/foamVersion.C +++ b/src/OpenFOAM/global/version/foamVersion.C @@ -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) { // Can use #if OPENFOAM directly - Info<<"Using: OpenFOAM-" << foamVersion::version.c_str() - << " (see www.OpenFOAM.com)" << nl - << "Build: " << foamVersion::build.c_str() - // The same as using foamVersion::api - #if OPENFOAM - << " (OPENFOAM=" << OPENFOAM << ')' - #endif - << nl; + Info<< "Using: OpenFOAM-" << foamVersion::version.c_str() + << " (" << OPENFOAM << ") (see www.OpenFOAM.com)" << nl + << "Build: " << foamVersion::build.c_str(); + + if (foamVersion::patched()) + { + // Patch-level, when defined + Info<< " (patch=" << foamVersion::patch.c_str() << ')'; + } + Info<< nl; if (full) { diff --git a/src/OpenFOAM/include/foamVersion.H b/src/OpenFOAM/include/foamVersion.H index 90e3d5dd31..5f521bebb0 100644 --- a/src/OpenFOAM/include/foamVersion.H +++ b/src/OpenFOAM/include/foamVersion.H @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. + \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -83,8 +83,8 @@ namespace Foam // The value is 0 if OPENFOAM was not defined. extern const int api; - //- OpenFOAM version (name or stringified number) as a std::string - extern const std::string version; + //- OpenFOAM patch number as a std::string + extern const std::string patch; //- OpenFOAM build information as a std::string extern const std::string build; @@ -93,13 +93,19 @@ namespace Foam //- (machine endian, label/scalar sizes) as a std::string 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 // // Eg, // \code - // Using: OpenFOAM- (see www.OpenFOAM.com) - // Build: (OPENFOAM=) + // Using: OpenFOAM- (see www.OpenFOAM.com) + // Build: // Arch: "" // \endcode // @@ -112,8 +118,8 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Compatibility names (1806 and earlier). -// Historically assumed to be called within the Foam namespace, so they are -// defined without the Foam namespace qualifier. +// Historically assumed to be called within the Foam namespace, they are +// thus defined without the Foam namespace qualifier. // // - FOAMversion: c-string // - FOAMbuild: c-string