Commit be998059 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: isolate config/version information from regular globals

- slight speed gain for recompilation and provisions for future
  refactoring
parent 9423d2bd
......@@ -16,7 +16,7 @@ esac
if [ -n "$touch" ]
then
# Triggers update of version info
wrmo global/global.Cver 2>/dev/null
wrmo global/foamConfig.Cver 2>/dev/null
fi
exit 0 # clean exit
......
global/global.Cver
/* global/constants/constants.C in global.Cver */
/* global/constants/dimensionedConstants.C in global.Cver */
global/foamConfig.Cver
global/globals.C
/* global/constants/constants.C in globals.C */
/* global/constants/dimensionedConstants.C in globals.C */
global/argList/argList.C
global/argList/argListHelp.C
global/clock/clock.C
......@@ -13,7 +14,6 @@ global/profiling/profilingSysInfo.C
global/profiling/profilingTrigger.C
global/profiling/profilingPstream.C
global/etcFiles/etcFiles.C
global/version/foamVersion.C
fileOps = global/fileOperations
$(fileOps)/fileOperation/fileOperation.C
......
......@@ -5,7 +5,6 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
......@@ -25,26 +24,25 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Define the globals used in the OpenFOAM library.
It is important that these are constructed in the appropriate order to
avoid the use of unconstructed data in the global namespace.
Define configure constants used in the OpenFOAM library.
This file has a '.Cver' extension to trigger a Makefile rule to replace
'BUILD', 'VERSION' tags with the corresponding strings.
The '.Cver' extension is used to trigger a Makefile rule to filter
the corresponding strings.
\*---------------------------------------------------------------------------*/
#include "foamVersion.H"
#include "endian.H"
#include "label.H"
#include "scalar.H"
#include "labelFwd.H"
#include "scalarFwd.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace
{
// Extract value from "tag=<digits>", eg "LSB;label=32;scalar=64"
// Extract value from "key=<digits>", eg "LSB;label=32;scalar=64"
// The 'tag' string includes the '=' for additional safety.
// Return 0 on any errors
static inline unsigned getTaggedSize(const char* tag, const std::string& s)
{
......@@ -151,59 +149,37 @@ std::string Foam::foamVersion::configuredEtcDir()
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Setup an error handler for the global new operator
#include "new.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// The nullObject singleton and a dummy zero singleton
#include "nullObject.C"
#include "zero.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global IO streams
#include "IOstreams.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "JobInfo.H"
bool Foam::JobInfo::constructed(false);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global error definitions (initialised by construction)
#include "messageStream.C"
#include "error.C"
#include "IOerror.C"
#include "token.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read the debug and info switches
#include "debug.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read file modification checking switches
#include "regIOobject.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read parallel communication switches
#include "UPstream.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read constants
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')
);
}
#include "constants.C"
#include "dimensionedConstants.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory
void Foam::foamVersion::printBuildInfo(std::ostream& os, const bool full)
{
// Could also use @TOKENS@ directly...
os << "Using: OpenFOAM-" << foamVersion::version
<< " (" << foamVersion::api << ") - visit www.openfoam.com\n"
<< "Build: " << foamVersion::build;
if (foamVersion::patched())
{
// Patch-level, when defined
os << " (patch=" << foamVersion::patch << ')';
}
os << '\n';
if (full)
{
os << "Arch: " << foamVersion::buildArch << '\n';
}
}
#include "JobInfo.C"
// ************************************************************************* //
......@@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -24,7 +25,9 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Setup an error handler for the global new operator
Define the globals used in the OpenFOAM library.
It is important that these are constructed in the appropriate order to
avoid the use of unconstructed data in the global namespace.
\*---------------------------------------------------------------------------*/
......@@ -32,18 +35,19 @@ Description
#include <iostream>
#include <cstdlib>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Setup an error handler for the global new operator
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void newError()
{
std::cerr<<
"new cannot satisfy memory request.\n"
"This does not necessarily mean you have run out of virtual memory.\n"
"It could be due to a stack violation caused "
"by e.g. bad use of pointers or an out of date shared library"
"by e.g. bad use of pointers or an out-of-date shared library"
<< std::endl;
std::abort();
......@@ -51,9 +55,57 @@ void newError()
void (*old_new_handler)() = std::set_new_handler(newError);
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// The nullObject singleton and a dummy zero singleton
} // End namespace Foam
#include "nullObject.C"
#include "zero.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global IO streams
#include "IOstreams.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "JobInfo.H"
bool Foam::JobInfo::constructed(false);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global error definitions (initialised by construction)
#include "messageStream.C"
#include "error.C"
#include "IOerror.C"
#include "token.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read the debug and info switches
#include "debug.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read file modification checking switches
#include "regIOobject.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read parallel communication switches
#include "UPstream.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Read constants
#include "constants.C"
#include "dimensionedConstants.C"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create the jobInfo file in the $FOAM_JOB_DIR/runningJobs directory
#include "JobInfo.C"
// ************************************************************************* //
/*-------------------------------*- C++ -*-----------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "foamVersion.H"
#include "messageStream.H"
// Static data members are constructed in global.Cver
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
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(std::ostream& os, const bool full)
{
os << "Using: OpenFOAM-" << foamVersion::version
<< " (" << foamVersion::api << ") - visit www.openfoam.com\n"
<< "Build: " << foamVersion::build;
if (foamVersion::patched())
{
// Patch-level, when defined
os << " (patch=" << foamVersion::patch << ')';
}
os << '\n';
if (full)
{
os << "Arch: " << foamVersion::buildArch << '\n';
}
}
// ************************************************************************* //
......@@ -31,12 +31,8 @@ Description
Note
Compile-time version information is conveyed by the \b OPENFOAM define
provided in the wmake rules "General/general".
The foamVersion.H file is located directly in the src/OpenFOAM/include
directory for easier use by external packages and to allow easier
modification during packaging.
Provisions for compile-time configuration of some paths
provided in the wmake rules "General/general"
and compile-time configuration of some paths via FOAM_EXTRA_CXXFLAGS:
- FOAM_CONFIGURED_PROJECT_DIR
- FOAM_CONFIGURED_PROJECT_ETC
......@@ -45,9 +41,12 @@ Note
FOAM_EXTRA_CXXFLAGS='-DFOAM_CONFIGURED_PROJECT_ETC=\"/etc/openfoam\"'
\endverbatim
The foamVersion.H file is located directly in the src/OpenFOAM/include
directory for easier use by external packages and to allow easier
modification during packaging.
SourceFiles
foamVersion.C
global.Cver
foamConfig.Cver
\*---------------------------------------------------------------------------*/
......@@ -57,6 +56,8 @@ SourceFiles
#include <iostream>
#include <string>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- The directory name for user-resources within the HOME directory
//
// Default: ".OpenFOAM"
......@@ -77,6 +78,18 @@ SourceFiles
// Used by foamEtcFiles() and stringOps::expand()
#define FOAM_RESOURCE_SITE_FALLBACK_ENVNAME "WM_PROJECT_DIR"
// Fallback project directory name (hard-coded)
//
// Default: undefined
// Used by foamEtcFiles()
/* #undef FOAM_CONFIGURED_PROJECT_DIR */
// Fallback project etc/ directory name (hard-coded)
//
// Default: undefined
// Used by foamEtcFiles()
/* #undef FOAM_CONFIGURED_PROJECT_ETC */
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment