icedb  version 0.5.1
Snow particle scattering database API
versioning.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ICEDB_HPP_VERSIONING
3 #define ICEDB_HPP_VERSIONING
4 #include "../defs.h"
5 #include <iostream>
6 #include <map>
7 #include <memory>
8 #include <string>
9 #include <vector>
10 #include <cstring>
11 #include <string>
12 #include "versioningForwards.hpp"
13 #include "cmake-settings.h"
14 #include "../util.h"
15 
16 #define QUOTE(str) #str
17 #define EXPAND_AND_QUOTE(str) QUOTE(str)
18 
21  std::string vstr;
22 };
23 
24 namespace icedb {
25  namespace versioning {
27  inline void genVersionInfo(versionInfo &out)
28  {
29  for (size_t i = 0; i < versionInfo::V_MAX_INTS; ++i) out.vn[i] = 0;
30  for (size_t i = 0; i < versionInfo::V_MAX_BOOLS; ++i) out.vb[i] = false;
31  out.vn[versionInfo::V_VERSIONINFO] = 1; // Change this if the structure is modified. Differences are ALWAYS incompatible.
32  out.vsdate[0] = '\0'; out.vssource[0] = '\0'; out.vsuuid[0] = '\0';
33  out.vboost[0] = '\0'; out.vassembly[0] = '\0';
34  ICEDB_COMPAT_strncpy_s(out.vdate, versionInfo::charmax, __DATE__, versionInfo::charmax);
35  ICEDB_COMPAT_strncpy_s(out.vtime, versionInfo::charmax, __TIME__, versionInfo::charmax);
36  ICEDB_COMPAT_strncpy_s(out.vgithash, versionInfo::charmax, libicedb_GitHash, versionInfo::charmax);
37  ICEDB_COMPAT_strncpy_s(out.vgitbranch, versionInfo::charmax, libicedb_GitBranch, versionInfo::charmax);
38 
39  out.vn[versionInfo::V_MAJOR] = libicedb_MAJOR;
40  out.vn[versionInfo::V_MINOR] = libicedb_MINOR;
41  out.vn[versionInfo::V_REVISION] = libicedb_REVISION;
42 
43 
44 #ifdef __GNUC__
45  out.vn[versionInfo::V_GNUC_MAJ] = __GNUC__;
46  out.vn[versionInfo::V_GNUC_MIN] = __GNUC_MINOR__;
47  out.vn[versionInfo::V_GNUC_PATCH] = __GNUC_PATCHLEVEL__;
48 #endif
49 #ifdef __MINGW32__
50  out.vn[versionInfo::V_MINGW_MAJ] = __MINGW32_MAJOR_VERSION;
51  out.vn[versionInfo::V_MINGW_MIN] = __MINGW32_MINOR_VERSION;
52 #endif
53 #ifdef __SUNPRO_CC
54  out.vn[versionInfo::V_SUNPRO] = __SUNPRO_CC;
55 #endif
56 #ifdef __PATHCC__
57  out.vn[versionInfo::V_PATHCC_MAJ] = __PATHCC__;
58  out.vn[versionInfo::V_PATHCC_MIN] = __PATHCC_MINOR__;
59  out.vn[versionInfo::V_PATHCC_PATCH] = __PATHCC_PATCHLEVEL__;
60 #endif
61 #ifdef __llvm__
62  out.vb[versionInfo::V_LLVM] = true;
63 #endif
64 #ifdef __clang__
65  out.vn[versionInfo::V_CLANG_MAJ] = __clang_major__;
66  out.vn[versionInfo::V_CLANG_MIN] = __clang_minor__;
67  out.vn[versionInfo::V_CLANG_PATCH] = __clang_patchlevel__;
68 #endif
69 #ifdef __INTEL_COMPILER
70  out.vn[versionInfo::V_INTEL] = __INTEL_COMPILER;
71  out.vn[versionInfo::V_INTEL_DATE] = __INTEL_COMPILER_BUILD_DATE;
72 #endif
73 #ifdef _MSC_FULL_VER
74  out.vn[versionInfo::V_MSCVER] = _MSC_FULL_VER;
75 #endif
76 #ifdef BOOST_LIB_VERSION
77  inline_strncpy_s(out.vboost, versionInfo::charmax, BOOST_LIB_VERSION, versionInfo::charmax);
78 #endif
79 #ifdef _DEBUG
80  out.vb[versionInfo::V_DEBUG] = true;
81 #endif
82 #ifdef _OPENMP
83  out.vb[versionInfo::V_OPENMP] = true;
84 #endif
85 #ifdef __amd64
86  out.vb[versionInfo::V_AMD64] = true;
87 #endif
88 #ifdef _M_X64
89  out.vb[versionInfo::V_X64] = true;
90 #endif
91 #ifdef __unix__
92  out.vb[versionInfo::V_UNIX] = true;
93 #endif
94 #ifdef __APPLE__
95  out.vb[versionInfo::V_APPLE] = true;
96 #endif
97 #ifdef _WIN32
98  out.vb[versionInfo::V_WIN32] = true;
99 #endif
100  }
102  std::shared_ptr<versionInfo> res(new versionInfo);
103  genVersionInfo(*(res.get()));
104  versionInfo_p r(res);
105  return r;
106  }
116  inline void debug_preamble(const versionInfo &v, std::ostream &out = std::cerr)
117  {
118  out << "Compiled on " << v.vdate << " at " << v.vtime << std::endl;
119  out << "Version " << v.vn[versionInfo::V_MAJOR] << "." << v.vn[versionInfo::V_MINOR]
120  << "." << v.vn[versionInfo::V_REVISION] << std::endl;
121  if (v.vgitbranch[0] != '\0') out << "GIT Branch " << v.vgitbranch << std::endl;
122  if (v.vgithash[0] != '\0') out << "GIT Hash " << v.vgithash << std::endl;
123  if (v.vn[versionInfo::V_SVNREVISION]) out << "SVN Revision " << v.vn[versionInfo::V_SVNREVISION] << std::endl;
124  if (v.vsdate[0] != '\0') out << "SVN Revision Date: " << v.vsdate << std::endl;
125  if (v.vssource[0] != '\0') out << "SVN Source: " << v.vssource << std::endl;
126  if (v.vsuuid[0] != '\0') out << "SVN UUID: " << v.vsuuid << std::endl;
127  if (v.vb[versionInfo::V_DEBUG]) out << "Debug Version" << std::endl;
128  else out << "Release Version" << std::endl;
129  if (v.vb[versionInfo::V_OPENMP]) out << "OpenMP enabled in Compiler" << std::endl;
130  else out << "OpenMP disabled in Compiler" << std::endl;
131  if (v.vb[versionInfo::V_AMD64] || v.vb[versionInfo::V_X64]) out << "64-bit build" << std::endl;
132  if (v.vb[versionInfo::V_UNIX]) out << "Unix / Linux Compile" << std::endl;
133  if (v.vb[versionInfo::V_APPLE]) out << "Mac Os X Compile" << std::endl;
134  if (v.vb[versionInfo::V_WIN32]) out << "Windows Compile" << std::endl;
135 
136  if (v.vn[versionInfo::V_GNUC_MAJ])
137  out << "GNU Compiler Suite " << v.vn[versionInfo::V_GNUC_MAJ] << "."
138  << v.vn[versionInfo::V_GNUC_MIN] << "." << v.vn[versionInfo::V_GNUC_PATCH] << std::endl;
139  if (v.vn[versionInfo::V_MINGW_MAJ])
140  out << "MinGW Compiler Suite " << v.vn[versionInfo::V_MINGW_MAJ] << "."
141  << v.vn[versionInfo::V_MINGW_MIN] << std::endl;
142  if (v.vn[versionInfo::V_SUNPRO])
143  out << "Sun Studio Compiler Suite " << v.vn[versionInfo::V_SUNPRO] << std::endl;
144  if (v.vn[versionInfo::V_PATHCC_MAJ])
145  out << "EKOPath Compiler " << v.vn[versionInfo::V_PATHCC_MAJ] << "."
146  << v.vn[versionInfo::V_PATHCC_MIN] << "." << v.vn[versionInfo::V_PATHCC_PATCH] << std::endl;
147  if (v.vb[versionInfo::V_LLVM]) out << "LLVM Compiler Suite" << std::endl;
148  if (v.vn[versionInfo::V_CLANG_MAJ])
149  out << "clang compiler " << v.vn[versionInfo::V_CLANG_MAJ] << "."
150  << v.vn[versionInfo::V_CLANG_MIN] << "." << v.vn[versionInfo::V_CLANG_PATCH] << std::endl;
151  if (v.vn[versionInfo::V_INTEL])
152  out << "Intel Suite " << v.vn[versionInfo::V_INTEL]
153  << " Date " << v.vn[versionInfo::V_INTEL_DATE] << std::endl;
154  if (v.vn[versionInfo::V_MSCVER])
155  out << "Microsoft Visual Studio Compiler Version " << v.vn[versionInfo::V_MSCVER] << std::endl;
156  if (v.vboost[0]) out << "Boost version " << v.vboost << std::endl;
157 
158 
159  out << std::endl;
160  out << std::endl;
161  }
162 
163  inline void debug_preamble(std::ostream &out = std::cerr)
164  {
165  versionInfo v;
166  genVersionInfo(v);
167  debug_preamble(v, out);
168  }
169  }
170 }
171 #undef QUOTE
172 #undef EXPAND_AND_QUOTE
173 #endif
icedb::versioning::versionInfo_p p
Definition: versioning.hpp:20
std::string vstr
Definition: versioning.hpp:21
versionInfo_p genVersionInfo()
Definition: versioning.hpp:101
ICEDB_BEGIN_DECL_C ICEDB_SYMBOL_SHARED size_t ICEDB_COMPAT_strncpy_s(char *dest, size_t destSz, const char *src, size_t srcSz)
Definition: util.cpp:14
void debug_preamble(std::ostream &out=std::cerr)
Definition: versioning.hpp:163
std::shared_ptr< const versionInfo > versionInfo_p