| 1 | //! @file build.cpp |
| 2 | //! @author ryftchen |
| 3 | //! @brief The definitions (build) in the application module. |
| 4 | //! @version 0.1.0 |
| 5 | //! @copyright Copyright (c) 2022-2025 ryftchen. All rights reserved. |
| 6 | |
| 7 | #include "build.hpp" |
| 8 | |
| 9 | #include "utility/include/macro.hpp" |
| 10 | |
| 11 | namespace application::build |
| 12 | { |
| 13 | //! @brief Commit revision. |
| 14 | //! @return revision |
| 15 | std::string revision() |
| 16 | { |
| 17 | #ifdef _COMMIT_REVISION |
| 18 | return _COMMIT_REVISION; |
| 19 | #else |
| 20 | #pragma message("Unknown revision at compile time.") |
| 21 | return "unknown revision" ; |
| 22 | #endif // _COMMIT_REVISION |
| 23 | } |
| 24 | |
| 25 | //! @brief Compiler name. |
| 26 | //! @return compiler |
| 27 | std::string compiler() |
| 28 | { |
| 29 | #ifdef __clang__ |
| 30 | return "clang " MACRO_STRINGIFY(__clang_major__) "." MACRO_STRINGIFY(__clang_minor__) "." MACRO_STRINGIFY( |
| 31 | __clang_patchlevel__) "" ; |
| 32 | #elif __GNUC__ |
| 33 | return "gcc " MACRO_STRINGIFY(__GNUC__) "." MACRO_STRINGIFY(__GNUC_MINOR__) "." MACRO_STRINGIFY( |
| 34 | __GNUC_PATCHLEVEL__) "" ; |
| 35 | #else |
| 36 | #pragma message("Unknown compiler at compile time.") |
| 37 | return "unknown compiler" ; |
| 38 | #endif // __clang__, __GNUC__ |
| 39 | } |
| 40 | |
| 41 | //! @brief Target processor. |
| 42 | //! @return processor |
| 43 | std::string processor() |
| 44 | { |
| 45 | #ifdef _TARGET_PROCESSOR |
| 46 | return _TARGET_PROCESSOR; |
| 47 | #else |
| 48 | #pragma message("Unknown processor at compile time.") |
| 49 | return "unknown processor" ; |
| 50 | #endif // _TARGET_PROCESSOR |
| 51 | } |
| 52 | |
| 53 | //! @brief Build date. |
| 54 | //! @return date |
| 55 | std::string date() |
| 56 | { |
| 57 | #if defined(__DATE__) && defined(__TIME__) |
| 58 | return "" __DATE__ " " __TIME__ "" ; |
| 59 | #else |
| 60 | #pragma message("Unknown date at compile time.") |
| 61 | return "unknown date" ; |
| 62 | #endif // defined(__DATE__) && defined(__TIME__) |
| 63 | } |
| 64 | } // namespace application::build |
| 65 | |