BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bslscm_version.h
Go to the documentation of this file.
1/// @file bslscm_version.h
2///
3/// The content of this file has been pre-processed for Doxygen.
4///
5
6
7// bslscm_version.h -*-C++-*-
8#ifndef INCLUDED_BSLSCM_VERSION
9#define INCLUDED_BSLSCM_VERSION
10
11#include <bsls_ident.h>
12BSLS_IDENT("$Id: $")
13
14/// @defgroup bslscm_version bslscm_version
15/// @brief Provide source control management (versioning) information.
16/// @addtogroup bsl
17/// @{
18/// @addtogroup bslscm
19/// @{
20/// @addtogroup bslscm_version
21/// @{
22///
23/// <h1> Outline </h1>
24/// * <a href="#bslscm_version-purpose"> Purpose</a>
25/// * <a href="#bslscm_version-classes"> Classes </a>
26/// * <a href="#bslscm_version-description"> Description </a>
27/// * <a href="#bslscm_version-usage"> Usage </a>
28///
29/// # Purpose {#bslscm_version-purpose}
30/// Provide source control management (versioning) information.
31///
32/// # Classes {#bslscm_version-classes}
33///
34/// - bslscm::Version: namespace for RCS and SCCS versioning information for `bsl`
35///
36/// # Description {#bslscm_version-description}
37/// This component provides source control management (versioning)
38/// information for the `bsl` package group. In particular, this component
39/// embeds RCS-style and SCCS-style version strings in binary executable files
40/// that use one or more components from the `bsl` package group. This version
41/// information may be extracted from binary files using common UNIX utilities
42/// (e.g., `ident` and `what`). In addition, the `version` `static` member
43/// function in the `bslscm::Version` `struct` can be used to query version
44/// information for the `bsl` package group at runtime. The following usage
45/// examples illustrate these two basic capabilities.
46///
47/// Note that unless the `version` method will be called, it is not necessary to
48/// `#include` this component header file to get `bsl` version information
49/// embedded in an executable. It is only necessary to use one or more `bsl`
50/// components (and, hence, link in the `bsl` library).
51///
52/// ## Usage {#bslscm_version-usage}
53///
54///
55/// A program can display the version of BSL that was used to build it by
56/// printing the version string returned by `bslscm::Version::version()` to
57/// `stdout` as follows:
58/// @code
59/// std::printf("BSL version: %s\n", bslscm::Version::version());
60/// @endcode
61/// @}
62/** @} */
63/** @} */
64
65/** @addtogroup bsl
66 * @{
67 */
68/** @addtogroup bslscm
69 * @{
70 */
71/** @addtogroup bslscm_version
72 * @{
73 */
74
75#include <bsls_buildtarget.h> // need to ensure consistent build options
76#include <bsls_platform.h>
77#include <bsls_linkcoercion.h>
78
79#include <bslscm_versiontag.h> // BSL_VERSION_MAJOR, BSL_VERSION_MINOR
80
81#ifndef BDE_OMIT_INTERNAL_DEPRECATED
82 // This macro controls whether we allow features which we must continue to
83 // support for our clients but do not want to rely on in our own code base.
84 // Clients who want to continue using these features need take no special
85 // steps. In order to make sure an entire code base does not rely on these
86 // features, recompile with this macro defined. Examples of such features
87 // are: including '<stdheader>' as opposed to '<bsl_stdheader.h>', or using
88 // 'DEBUG' instead of 'e_DEBUG'.
89#else
90#define BDE_DONT_ALLOW_TRANSITIVE_INCLUDES 1
91 // When we don't want to rely on legacy features, we also want to make sure
92 // we are not picking up macros or type aliases via (direct or transitive)
93 // includes of headers that have migrated from 'bde' to 'bsl' libraries.
94#endif // BDE_OMIT_INTERNAL_DEPRECATED
95
96
97
98namespace bslscm {
99
100 // =======
101 // Version
102 // =======
103
104/// This struct provides a namespace for (1) source control management
105/// (versioning) information that is embedded in binary executable files,
106/// and (2) a facility to query that information at runtime.
107struct Version {
108
109 // CLASS DATA
110 static const char *s_ident;
111 static const char *s_what;
112
113#define BSLSCM_CONCAT2(a,b,c,d,e,f) a ## b ## c ## d ## e ## f
114#define BSLSCM_CONCAT(a,b,c,d,e,f) BSLSCM_CONCAT2(a,b,c,d,e,f)
115
116// 'BSLSCM_D_VERSION' is a symbol whose name warns users of version mismatch
117// linking errors. Note that the exact string "compiled_this_object" must be
118// present in this version coercion symbol. Tools may look for this pattern to
119// warn users of mismatches.
120
121#define BSLSCM_S_VERSION BSLSCM_CONCAT(s_version_BSL_, \
122 BSL_VERSION_MAJOR, _, \
123 BSL_VERSION_MINOR, _, \
124 compiled_this_object)
125
126 static const char *BSLSCM_S_VERSION;
127
128 static const char *s_dependencies;
129 static const char *s_buildInfo;
130 static const char *s_timestamp;
131 static const char *s_sourceControlInfo;
132
133 // CLASS METHODS
134
135 /// Return the address of a character string that identifies the version
136 /// of the `bsl` package group in use.
137 static const char *version();
138};
139
140// ============================================================================
141// INLINE DEFINITIONS
142// ============================================================================
143
144 // --------------
145 // struct Version
146 // --------------
147
148// CLASS METHODS
149inline
150const char *Version::version()
151{
152 return BSLSCM_S_VERSION;
153}
154
155} // close package namespace
156
157// Force linker to pull in this component's object file.
158
160 bslscm_version_assertion,
162
163
164
165#endif
166
167// ----------------------------------------------------------------------------
168// Copyright 2013 Bloomberg Finance L.P.
169//
170// Licensed under the Apache License, Version 2.0 (the "License");
171// you may not use this file except in compliance with the License.
172// You may obtain a copy of the License at
173//
174// http://www.apache.org/licenses/LICENSE-2.0
175//
176// Unless required by applicable law or agreed to in writing, software
177// distributed under the License is distributed on an "AS IS" BASIS,
178// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
179// See the License for the specific language governing permissions and
180// limitations under the License.
181// ----------------------------- END-OF-FILE ----------------------------------
182
183/** @} */
184/** @} */
185/** @} */
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_LINKCOERCION_FORCE_SYMBOL_DEPENDENCY(type, refName, referredSymbol)
Definition bsls_linkcoercion.h:194
Definition bslscm_version.h:98
Definition bslscm_version.h:107
static const char * s_sourceControlInfo
Definition bslscm_version.h:131
static const char * BSLSCM_S_VERSION
Definition bslscm_version.h:126
static const char * s_ident
Definition bslscm_version.h:110
static const char * s_what
Definition bslscm_version.h:111
static const char * s_dependencies
Definition bslscm_version.h:128
static const char * s_timestamp
Definition bslscm_version.h:130
static const char * s_buildInfo
Definition bslscm_version.h:129
static const char * version()
Definition bslscm_version.h:150