diff --git a/applications/test/foamVersion/Test-foamVersion.C b/applications/test/foamVersion/Test-foamVersion.C index 740b15632cc91afbb67d8bdc6af02d32193b374d..9588954bc2d49364b40b620b0d4ea991d5133d2a 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 153ccd4173f9488d2cfcac10c3ba5662d11a0e12..480c5958081183a00e56eac37aef1fb545e3d066 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 61f02b1656cbb2ed53ee3435d85f7d71e399beb0..76f3c036685ebcc5a1ad096a8f98eab7e3eb4704 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<<nl + Info<< nl <<"Error: option '-" << optName << "' requires an argument" << nl << nl << "See '" << executable_ << " -help' for usage" @@ -997,7 +997,7 @@ void Foam::argList::parse // Print the collected error messages and exit if check fails if (!check(checkArgs, checkOpts)) { - foamVersion::printBuildInfo(false); + foamVersion::printBuildInfo(Info().stdStream(), false); FatalError.write(Info, false); Pstream::exit(1); // works for serial and parallel diff --git a/src/OpenFOAM/global/argList/argListHelp.C b/src/OpenFOAM/global/argList/argListHelp.C index fbb82b59c1e35f3aa7a448af7022c1ec72741d39..deca811955c528c323b724c0073a1637115cb7ef 100644 --- a/src/OpenFOAM/global/argList/argListHelp.C +++ b/src/OpenFOAM/global/argList/argListHelp.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -41,7 +41,7 @@ static inline int apiYear() return 2000 + (foamVersion::api / 100); } -// manpage Footer +// Footer for manpage static inline void printManFooter() { Info<< ".SH \"SEE ALSO\"" << nl @@ -428,7 +428,7 @@ void Foam::argList::printUsage(bool full) const printNotes(); Info<< nl; - foamVersion::printBuildInfo(true); + foamVersion::printBuildInfo(Info().stdStream(), true); Info<< endl; } diff --git a/src/OpenFOAM/global/etcFiles/etcFiles.C b/src/OpenFOAM/global/etcFiles/etcFiles.C index 377757eed767d8b26fdb207731824a0dfa57ddfe..680bcee60397a746404a97b195587e238da52d26 100644 --- a/src/OpenFOAM/global/etcFiles/etcFiles.C +++ b/src/OpenFOAM/global/etcFiles/etcFiles.C @@ -30,6 +30,24 @@ License #include "foamVersion.H" #include "OSspecific.H" +#ifdef FULLDEBUG +#ifndef FOAM_RESOURCE_USER_CONFIG_DIRNAME +# warning FOAM_RESOURCE_USER_CONFIG_DIRNAME undefined (was this intentional?) +#endif + +#ifndef FOAM_RESOURCE_SITE_ENVNAME +# warning FOAM_RESOURCE_SITE_ENVNAME undefined (was this intentional?) +#endif + +#ifndef FOAM_RESOURCE_SITE_FALLBACK_ENVNAME +# warning FOAM_RESOURCE_SITE_FALLBACK_ENVNAME undefined (was this intentional?) +#endif +#endif + +// Always use these names +#undef FOAM_PROJECT_ENVNAME +#define FOAM_PROJECT_ENVNAME "WM_PROJECT_DIR" + // * * * * * * * * * * * * * * Static Functions * * * * * * * * * * * * * * // // @@ -70,8 +88,8 @@ static inline void errorMandatoryNotFound // setup at all. std::cerr - << "--> 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 5b99825dc26e94f4ec11052ec971727ac848cba0..ebc1df5872d4997174ac2360afbdec1c218b554e 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 5f52742fd972dac07ad65c9ef61c8142945e6cf6..085e119f62cf79a0dc21af360814282f3c4ae842 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 <iostream> #include <string> //- 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: <ARCH_INFO> // \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.