diff --git a/applications/test/foamVersion/Test-foamVersion.C b/applications/test/foamVersion/Test-foamVersion.C index 740b15632c..9588954bc2 100644 --- a/applications/test/foamVersion/Test-foamVersion.C +++ b/applications/test/foamVersion/Test-foamVersion.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,9 +51,8 @@ void testExtraction(const std::string& str) int main() { - Info - << "\nVersion information (function)" << nl; - foamVersion::printBuildInfo(); + Info<< "\nVersion information (function)" << nl; + foamVersion::printBuildInfo(Info().stdStream()); Info << "\nVersion information (macros)" << nl diff --git a/applications/test/wmake1/newStub.C b/applications/test/wmake1/newStub.C index 153ccd4173..480c595808 100644 --- a/applications/test/wmake1/newStub.C +++ b/applications/test/wmake1/newStub.C @@ -8,6 +8,6 @@ namespace Foam void printTest() { Info<< nl; - foamVersion::printBuildInfo(); + foamVersion::printBuildInfo(Info().stdStream()); } } diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 61f02b1656..76f3c03668 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2015-2019 OpenCFD Ltd. + Copyright (C) 2015-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -828,9 +828,9 @@ Foam::argList::argList ++argi; if (argi >= args_.size()) { - foamVersion::printBuildInfo(false); + foamVersion::printBuildInfo(Info().stdStream(), false); - Info< FOAM FATAL ERROR :\n " - "Could not find mandatory etc entry (mode=" + << "--> FOAM FATAL ERROR :\n" + " Could not find mandatory etc entry (mode=" << locationToString(location) << ")\n '" << name << "'\n" << std::endl; @@ -96,9 +114,6 @@ static inline bool userResourceDir(Foam::fileName& queried) // But we would have worse problems elsewhere if that were the case. return true; } - #elif defined FULLDEBUG - #warning FOAM_RESOURCE_USER_CONFIG_DIRNAME \ - is undefined (was this intentional?) #endif return false; @@ -120,38 +135,30 @@ static inline bool groupResourceDir(Foam::fileName& queried) { #ifdef FOAM_RESOURCE_SITE_ENVNAME queried = Foam::getEnv(FOAM_RESOURCE_SITE_ENVNAME)/"etc"; - if (queried.size() > 3) + if (queried.size() > 4) { return Foam::isDir(queried); } - #elif defined FULLDEBUG - #warning FOAM_RESOURCE_SITE_ENVNAME \ - is undefined (was this intentional?) #endif // Fallback when WM_PROJECT_SITE is unset #ifdef FOAM_RESOURCE_SITE_FALLBACK_ENVNAME queried = Foam::getEnv(FOAM_RESOURCE_SITE_FALLBACK_ENVNAME)/"site/etc"; - if (queried.size() > 8 && Foam::isDir(queried)) + if (queried.size() > 9 && Foam::isDir(queried)) { return true; } - #elif defined FULLDEBUG - #warning FOAM_RESOURCE_SITE_FALLBACK_ENVNAME \ - is undefined (was this intentional?) #endif // Compile-time paths - queried = Foam::foamVersion::configuredProjectDir(); - if (queried.size()) + #ifdef FOAM_CONFIGURED_PROJECT_DIR + queried = FOAM_CONFIGURED_PROJECT_DIR "/site/etc"; + if (queried.size() > 9 && Foam::isDir(queried)) { - queried /= "site/etc"; - if (Foam::isDir(queried)) - { - return true; - } + return true; } + #endif queried.clear(); return false; @@ -171,32 +178,29 @@ static inline bool groupResourceDir(Foam::fileName& queried) // - FOAM_CONFIGURED_PROJECT_DIR/"etc" static inline bool projectResourceDir(Foam::fileName& queried) { - queried = Foam::getEnv("WM_PROJECT_DIR")/"etc"; - if (queried.size() > 3 && Foam::isDir(queried)) + queried = Foam::getEnv(FOAM_PROJECT_ENVNAME)/"etc"; + if (queried.size() > 4 && Foam::isDir(queried)) { return true; } // Compile-time paths - queried = Foam::foamVersion::configuredEtcDir(); - if (queried.size()) + #ifdef FOAM_CONFIGURED_PROJECT_ETC + queried = FOAM_CONFIGURED_PROJECT_ETC; + if (Foam::isDir(queried)) { - if (Foam::isDir(queried)) - { - return true; - } + return true; } + #endif - queried = Foam::foamVersion::configuredProjectDir(); - if (queried.size()) + #ifdef FOAM_CONFIGURED_PROJECT_DIR + queried = FOAM_CONFIGURED_PROJECT_DIR "/etc"; + if (queried.size() > 4 && Foam::isDir(queried)) { - queried /= "etc"; - if (Foam::isDir(queried)) - { - return true; - } + return true; } + #endif queried.clear(); return false; diff --git a/src/OpenFOAM/global/version/foamVersion.C b/src/OpenFOAM/global/version/foamVersion.C index 5b99825dc2..ebc1df5872 100644 --- a/src/OpenFOAM/global/version/foamVersion.C +++ b/src/OpenFOAM/global/version/foamVersion.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2019 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -37,28 +37,28 @@ 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() && foamVersion::patch[0] != '@') && (foamVersion::patch.size() > 1 || foamVersion::patch[0] != '0') ); } -void Foam::foamVersion::printBuildInfo(const bool full) +void Foam::foamVersion::printBuildInfo(std::ostream& os, const bool full) { - Info<< "Using: OpenFOAM-" << foamVersion::version.c_str() + os << "Using: OpenFOAM-" << foamVersion::version << " (" << foamVersion::api << ") - visit www.openfoam.com\n" - << "Build: " << foamVersion::build.c_str(); + << "Build: " << foamVersion::build; if (foamVersion::patched()) { // Patch-level, when defined - Info<< " (patch=" << foamVersion::patch.c_str() << ')'; + os << " (patch=" << foamVersion::patch << ')'; } - Info<< nl; + os << '\n'; if (full) { - Info<< "Arch: " << foamVersion::buildArch.c_str() << nl; + os << "Arch: " << foamVersion::buildArch << '\n'; } } diff --git a/src/OpenFOAM/include/foamVersion.H b/src/OpenFOAM/include/foamVersion.H index 5f52742fd9..085e119f62 100644 --- a/src/OpenFOAM/include/foamVersion.H +++ b/src/OpenFOAM/include/foamVersion.H @@ -54,7 +54,7 @@ SourceFiles #ifndef foamVersion_H #define foamVersion_H -#include "stdFoam.H" +#include #include //- The directory name for user-resources within the HOME directory @@ -113,7 +113,7 @@ namespace Foam //- Extract scalar size (in bytes) from "scalar=" tag in string unsigned scalarByteSize(const std::string& str); - //- Print information about version, build, arch to Info + //- Print information about version, build, arch to output stream // // Eg, // \code @@ -122,8 +122,9 @@ namespace Foam // Arch: // \endcode // + // \param os the output stream // \param full includes Arch information - void printBuildInfo(const bool full=true); + void printBuildInfo(std::ostream& os, const bool full=true); //- Compile-time definition of the OpenFOAM project directory //- or empty if not defined.