util/version.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // SPDX-License-Identifier: BSD-3-Clause | ||
| 2 | /// @file version.cpp | ||
| 3 | /// @brief Ernie's version and build information, set by the build. | ||
| 4 | #include "ernie/util/version.h" | ||
| 5 | |||
| 6 | #include <string> | ||
| 7 | |||
| 8 | namespace ernie { | ||
| 9 | |||
| 10 | 7 | std::string_view Version() { | |
| 11 | 7 | return ERNIE_VERSION_STRING; | |
| 12 | } | ||
| 13 | |||
| 14 | 1 | std::string_view BuildDate() { | |
| 15 | 1 | return __DATE__ " " __TIME__; | |
| 16 | } | ||
| 17 | |||
| 18 | 1 | std::string_view BuildType() { | |
| 19 | // Empty when a single-configuration build sets none. | ||
| 20 | 1 | constexpr std::string_view type = ERNIE_BUILD_TYPE; | |
| 21 | 1 | return type.empty() ? "unknown" : type; | |
| 22 | } | ||
| 23 | |||
| 24 | 1 | std::string_view Compiler() { | |
| 25 | #if defined(__clang__) | ||
| 26 | return "Clang " __clang_version__; | ||
| 27 | #elif defined(__GNUC__) | ||
| 28 | 1 | return "GCC " __VERSION__; | |
| 29 | #elif defined(_MSC_VER) | ||
| 30 | static const std::string compiler = "MSVC " + std::to_string(_MSC_FULL_VER); | ||
| 31 | return compiler; | ||
| 32 | #else | ||
| 33 | return "unknown"; | ||
| 34 | #endif | ||
| 35 | } | ||
| 36 | |||
| 37 | } // namespace ernie | ||
| 38 |