git: store git short ref hash on build stage to Version.h
This commit is contained in:
parent
d82a1c5225
commit
e04c8ee95e
|
@ -55,10 +55,22 @@ if(BUILD_DFU)
|
|||
set(BUILD_DFU true)
|
||||
endif()
|
||||
|
||||
set(PROJECT_GIT_COMMIT_HASH "")
|
||||
|
||||
execute_process(COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH
|
||||
RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS)
|
||||
|
||||
string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH)
|
||||
|
||||
message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS})
|
||||
|
||||
message("BUILD CONFIGURATION")
|
||||
message("-------------------")
|
||||
message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
|
||||
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
|
||||
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})
|
||||
message(" * NRF52 SDK : " ${NRF5_SDK_PATH})
|
||||
set(PROGRAMMER "???")
|
||||
if(USE_JLINK)
|
||||
|
|
|
@ -8,11 +8,13 @@ namespace Pinetime {
|
|||
static constexpr uint32_t Major() {return major;}
|
||||
static constexpr uint32_t Minor() {return minor;}
|
||||
static constexpr uint32_t Patch() {return patch;}
|
||||
static constexpr const char* GitCommitHash() {return commitHash;}
|
||||
static constexpr const char* VersionString() {return versionString;}
|
||||
private:
|
||||
static constexpr uint32_t major = @PROJECT_VERSION_MAJOR@;
|
||||
static constexpr uint32_t minor = @PROJECT_VERSION_MINOR@;
|
||||
static constexpr uint32_t patch = @PROJECT_VERSION_PATCH@;
|
||||
static constexpr const char* commitHash = "@PROJECT_GIT_COMMIT_HASH@";
|
||||
static constexpr const char* versionString = "@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@";
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user