From 5adb1e9618d4a461a9b690f5554dd3c44df11fc7 Mon Sep 17 00:00:00 2001 From: Tillsunset <35825944+Tillsunset@users.noreply.github.com> Date: Sun, 6 Nov 2022 19:47:59 -0600 Subject: [PATCH] Add commit hash to build name on build check workflow (#463) --- CMakeLists.txt | 9 ++++++++- src/Common/version.h | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b2b7898..3615c65a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,14 @@ option(MACOS_BUNDLE "The executable when built on macOS will be created as an ap set(EXPERIMENTAL_VERSION "" CACHE STRING "") # used by CI script to set experimental version if (EXPERIMENTAL_VERSION) - add_definitions(-DEMULATOR_VERSION_MINOR=${EXPERIMENTAL_VERSION}) + add_definitions(-DEMULATOR_VERSION_MINOR=${EXPERIMENTAL_VERSION}) + execute_process( + COMMAND git log --format=%h -1 + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE GIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + add_definitions(-DEMULATOR_HASH=${GIT_HASH}) endif() if (ENABLE_VCPKG) diff --git a/src/Common/version.h b/src/Common/version.h index 74464393..8c08f238 100644 --- a/src/Common/version.h +++ b/src/Common/version.h @@ -21,8 +21,13 @@ #define _STRINGFY(s) #s #if EMULATOR_VERSION_MINOR != 0 +#if defined(EMULATOR_HASH) && EMULATOR_VERSION_MINOR == 999999 +#define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) +#define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_HASH) EMULATOR_VERSION_SUFFIX) +#else #define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) #define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) "-" _XSTRINGFY(EMULATOR_VERSION_MINOR) EMULATOR_VERSION_SUFFIX) +#endif #else #define BUILD_VERSION_STRING (_XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) EMULATOR_VERSION_SUFFIX) #define BUILD_VERSION_WITH_NAME_STRING (EMULATOR_NAME " " _XSTRINGFY(EMULATOR_VERSION_LEAD) "." _XSTRINGFY(EMULATOR_VERSION_MAJOR) EMULATOR_VERSION_SUFFIX)