Loading...
Searching...
No Matches
foamVersion.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2017-2020 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Namespace
27 Foam::foamVersion
28
29Description
30 Namespace for OpenFOAM version information
31
32Note
33 Compile-time version information is conveyed by the \b OPENFOAM define
34 provided in the wmake rules "General/general"
35 and compile-time configuration of some paths via FOAM_EXTRA_CXXFLAGS:
36 - FOAM_CONFIGURED_PROJECT_DIR
37 - FOAM_CONFIGURED_PROJECT_ETC
38
39 For example,
40 \verbatim
41 FOAM_EXTRA_CXXFLAGS='-DFOAM_CONFIGURED_PROJECT_ETC=\"/etc/openfoam\"'
42 \endverbatim
43
44 The foamVersion.H file is located directly in the src/OpenFOAM/include
45 directory for easier use by external packages and to allow easier
46 modification during packaging.
47
48SourceFiles
49 foamConfig.Cver
50
51\*---------------------------------------------------------------------------*/
52
53#ifndef Foam_foamVersion_H
54#define Foam_foamVersion_H
55
56#include <iostream>
57#include <string>
58
59// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60
61//- The directory name for user-resources within the HOME directory
62//
63// Default: ".OpenFOAM"
64// Used by foamEtcFiles(), stringOps::expand(), Foam::JobInfo
65#define FOAM_RESOURCE_USER_CONFIG_DIRNAME ".OpenFOAM"
66
67//- The env name for site-resources to obtain a site-resources directory.
68//
69// Default: "WM_PROJECT_SITE"
70// Used by foamEtcFiles() and stringOps::expand()
71#define FOAM_RESOURCE_SITE_ENVNAME "WM_PROJECT_SITE"
72
73//- The env name for determining a fallback directory name for site-resources
74//- when the directory corresponding to FOAM_RESOURCE_SITE_ENVNAME is empty.
75// The fallback search appends "/site" to the directory.
76//
77// Default: "WM_PROJECT_DIR"
78// Used by foamEtcFiles() and stringOps::expand()
79#define FOAM_RESOURCE_SITE_FALLBACK_ENVNAME "WM_PROJECT_DIR"
80
81// Fallback project directory name (hard-coded)
82//
83// Default: undefined
84// Used by foamEtcFiles()
85/* #undef FOAM_CONFIGURED_PROJECT_DIR */
86
87// Fallback project etc/ directory name (hard-coded)
88//
89// Default: undefined
90// Used by foamEtcFiles()
91/* #undef FOAM_CONFIGURED_PROJECT_ETC */
92
93
94// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
95
96namespace Foam
97{
98 //- Version information
99 namespace foamVersion
100 {
101 //- OpenFOAM api number (integer) corresponding to the value of OPENFOAM
102 //- at the time of compilation.
103 // The value is 0 if OPENFOAM was not defined.
104 extern const int api;
105
106 //- OpenFOAM patch number as a std::string
107 extern const std::string patch;
108
109 //- OpenFOAM build information as a std::string
110 extern const std::string build;
111
112 //- OpenFOAM build architecture information
113 //- (machine endian, label/scalar sizes) as a std::string
114 extern const std::string buildArch;
115
116 //- OpenFOAM version (name or stringified number) as a std::string
117 extern const std::string version;
118
119 //- Test if the patch string appears to be in use,
120 //- which is when it is defined (non-zero).
121 bool patched();
122
123 //- Extract label size (in bytes) from "label=" tag in string
124 unsigned labelByteSize(const std::string& str);
125
126 //- Extract scalar size (in bytes) from "scalar=" tag in string
127 unsigned scalarByteSize(const std::string& str);
128
129 //- Print information about version, build, arch to output stream
130 //
131 // Eg,
132 // \code
133 // Using: OpenFOAM-<VER> (API) - visit www.openfoam.com
134 // Build: <BUILD> (patch=...)
135 // Arch: <ARCH_INFO>
136 // \endcode
137 //
138 // \param os the output stream
139 // \param full includes Arch information
140 void printBuildInfo(std::ostream& os, const bool full=true);
142 //- Compile-time definition of the OpenFOAM project directory
143 //- or empty if not defined.
144 // Functional equivalent to WM_PROJECT_DIR.
145 std::string configuredProjectDir();
147 //- Compile-time definition of the OpenFOAM etc/ directory
148 //- or empty if not defined.
149 // Functional equivalent to WM_PROJECT_DIR/etc
150 std::string configuredEtcDir();
152}
153
154
155// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156
157// Compatibility names (1806 and earlier).
158// Historically assumed to be called within the Foam namespace, they are
159// thus defined without the Foam namespace qualifier.
160//
161// - FOAMversion: c-string
162// - FOAMbuild: c-string
163// - FOAMbuildArch: std::string
164
165#define FOAMversion foamVersion::version.c_str()
166#define FOAMbuild foamVersion::build.c_str()
167#define FOAMbuildArch foamVersion::buildArch
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171#endif
172
173// ************************************************************************* //
OBJstream os(runTime.globalPath()/outputName)
const std::string patch
OpenFOAM patch number as a std::string.
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
std::string configuredProjectDir()
Compile-time definition of the OpenFOAM project directory or empty if not defined.
std::string configuredEtcDir()
Compile-time definition of the OpenFOAM etc/ directory or empty if not defined.
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
const std::string build
OpenFOAM build information as a std::string.
const int api
OpenFOAM api number (integer) corresponding to the value of OPENFOAM at the time of compilation.
bool patched()
Test if the patch string appears to be in use, which is when it is defined (non-zero).
const std::string buildArch
OpenFOAM build architecture information (machine endian, label/scalar sizes) as a std::string.
void printBuildInfo(std::ostream &os, const bool full=true)
Print information about version, build, arch to output stream.
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
Namespace for OpenFOAM.