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 -------------------------------------------------------------------------------
10 License
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 
26 Namespace
27  Foam::foamVersion
28 
29 Description
30  Namespace for OpenFOAM version information
31 
32 Note
33  Compile-time version information is conveyed by the \b OPENFOAM define
34  provided in the wmake rules "General/general".
35  The foamVersion.H file is located directly in the src/OpenFOAM/include
36  directory for easier use by external packages and to allow easier
37  modification during packaging.
38 
39  Provisions for compile-time configuration of some paths
40  - FOAM_CONFIGURED_PROJECT_DIR
41  - FOAM_CONFIGURED_PROJECT_ETC
42 
43  For example,
44  \verbatim
45  FOAM_EXTRA_CXXFLAGS='-DFOAM_CONFIGURED_PROJECT_ETC=\"/etc/openfoam\"'
46  \endverbatim
47 
48 SourceFiles
49  foamVersion.C
50  global.Cver
51 
52 \*---------------------------------------------------------------------------*/
53 
54 #ifndef foamVersion_H
55 #define foamVersion_H
56 
57 #include <iostream>
58 #include <string>
59 
60 //- The directory name for user-resources within the HOME directory
61 //
62 // Default: ".OpenFOAM"
63 // Used by foamEtcFiles(), stringOps::expand(), Foam::JobInfo
64 #define FOAM_RESOURCE_USER_CONFIG_DIRNAME ".OpenFOAM"
65 
66 //- The env name for site-resources to obtain a site-resources directory.
67 //
68 // Default: "WM_PROJECT_SITE"
69 // Used by foamEtcFiles() and stringOps::expand()
70 #define FOAM_RESOURCE_SITE_ENVNAME "WM_PROJECT_SITE"
71 
72 //- The env name for determining a fallback directory name for site-resources
73 //- when the directory corresponding to FOAM_RESOURCE_SITE_ENVNAME is empty.
74 // The fallback search appends "/site" to the directory.
75 //
76 // Default: "WM_PROJECT_DIR"
77 // Used by foamEtcFiles() and stringOps::expand()
78 #define FOAM_RESOURCE_SITE_FALLBACK_ENVNAME "WM_PROJECT_DIR"
79 
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 namespace Foam
84 {
85  //- Version information
86  namespace foamVersion
87  {
88  //- OpenFOAM api number (integer) corresponding to the value of OPENFOAM
89  //- at the time of compilation.
90  // The value is 0 if OPENFOAM was not defined.
91  extern const int api;
92 
93  //- OpenFOAM patch number as a std::string
94  extern const std::string patch;
95 
96  //- OpenFOAM build information as a std::string
97  extern const std::string build;
98 
99  //- OpenFOAM build architecture information
100  //- (machine endian, label/scalar sizes) as a std::string
101  extern const std::string buildArch;
102 
103  //- OpenFOAM version (name or stringified number) as a std::string
104  extern const std::string version;
105 
106  //- Test if the patch string appears to be in use,
107  //- which is when it is defined (non-zero).
108  bool patched();
109 
110  //- Extract label size (in bytes) from "label=" tag in string
111  unsigned labelByteSize(const std::string& str);
112 
113  //- Extract scalar size (in bytes) from "scalar=" tag in string
114  unsigned scalarByteSize(const std::string& str);
115 
116  //- Print information about version, build, arch to output stream
117  //
118  // Eg,
119  // \code
120  // Using: OpenFOAM-<VER> (API) - visit www.openfoam.com
121  // Build: <BUILD> (patch=...)
122  // Arch: <ARCH_INFO>
123  // \endcode
124  //
125  // \param os the output stream
126  // \param full includes Arch information
127  void printBuildInfo(std::ostream& os, const bool full=true);
128 
129  //- Compile-time definition of the OpenFOAM project directory
130  //- or empty if not defined.
131  // Functional equivalent to WM_PROJECT_DIR.
132  std::string configuredProjectDir();
133 
134  //- Compile-time definition of the OpenFOAM etc/ directory
135  //- or empty if not defined.
136  // Functional equivalent to WM_PROJECT_DIR/etc
137  std::string configuredEtcDir();
138  }
139 }
140 
141 
142 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 
144 // Compatibility names (1806 and earlier).
145 // Historically assumed to be called within the Foam namespace, they are
146 // thus defined without the Foam namespace qualifier.
147 //
148 // - FOAMversion: c-string
149 // - FOAMbuild: c-string
150 // - FOAMbuildArch: std::string
151 
152 #define FOAMversion foamVersion::version.c_str()
153 #define FOAMbuild foamVersion::build.c_str()
154 #define FOAMbuildArch foamVersion::buildArch
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 #endif
159 
160 // ************************************************************************* //
Foam::foamVersion::build
const std::string build
OpenFOAM build information as a std::string.
FOAM_RESOURCE_SITE_FALLBACK_ENVNAME
#define FOAM_RESOURCE_SITE_FALLBACK_ENVNAME
Definition: foamVersion.H:78
FOAM_RESOURCE_SITE_ENVNAME
#define FOAM_RESOURCE_SITE_ENVNAME
The env name for site-resources to obtain a site-resources directory.
Definition: foamVersion.H:70
Foam::foamVersion::printBuildInfo
void printBuildInfo(std::ostream &os, const bool full=true)
Print information about version, build, arch to output stream.
Definition: foamVersion.C:46
Foam::foamVersion::api
const int api
FOAM_RESOURCE_USER_CONFIG_DIRNAME
#define FOAM_RESOURCE_USER_CONFIG_DIRNAME
The directory name for user-resources within the HOME directory.
Definition: foamVersion.H:64
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::foamVersion::version
const std::string version
OpenFOAM version (name or stringified number) as a std::string.
Foam::foamVersion::patched
bool patched()
Definition: foamVersion.C:35
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::foamVersion::labelByteSize
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
Foam::foamVersion::buildArch
const std::string buildArch
Foam::foamVersion::scalarByteSize
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
Foam::foamVersion::configuredProjectDir
std::string configuredProjectDir()
Foam::foamVersion::configuredEtcDir
std::string configuredEtcDir()