Use commit number as version tweak value
This commit is contained in:
parent
916d02824e
commit
ab299e36d1
|
|
@ -39,10 +39,10 @@ set(FN_PREFIX "FW${PROJECT_VERSION}+${PROJECT_VERSION_SUFFIX}")
|
|||
message(STATUS "Project version (Configuration.h): ${PROJECT_VERSION}")
|
||||
message(STATUS "Project version suffix ..........: ${PROJECT_VERSION_SUFFIX}")
|
||||
message(STATUS "Project version description......: ${PROJECT_VERSION_FULL}")
|
||||
message(STATUS "PROJECT() VERSION argument.......: ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV}")
|
||||
|
||||
|
||||
string(REGEX MATCH "v([0-9]+)\.([0-9]+)\.([0-9]+)" TAG_VERSION "${FW_COMMIT_DSC}")
|
||||
if(NOT "${PROJECT_VERSION_SUFFIX}" STREQUAL "UNKNOWN") # No commit hash is known... likely no git.
|
||||
string(REGEX MATCH "v([0-9]+)\.([0-9]+)\.([0-9]+)-.+-([0-9]+)" TAG_VERSION "${FW_COMMIT_DSC}")
|
||||
|
||||
if(NOT ${CMAKE_MATCH_1} STREQUAL ${PROJECT_VERSION_MAJOR})
|
||||
message(FATAL_ERROR "Major version of current tag disagrees with Configuration.h ${CMAKE_MATCH_1}!=${PROJECT_VERSION_MAJOR}")
|
||||
|
|
@ -56,7 +56,19 @@ if(NOT ${CMAKE_MATCH_3} STREQUAL ${PROJECT_VERSION_REV})
|
|||
message(FATAL_ERROR "Rev version of current tag disagrees with Configuration.h ${CMAKE_MATCH_3}!=${PROJECT_VERSION_REV}")
|
||||
endif()
|
||||
|
||||
# Note - we don't check the commit counter, that'd be too much of a headache. Maybe it
|
||||
# should be an error only on a tagged build?
|
||||
|
||||
MESSAGE(STATUS "Configuration.h and tag match: OK (${PROJECT_VERSION}/${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3})")
|
||||
MESSAGE(STATUS "Commit nr: Configuration.h: ${PROJECT_VERSION_TWEAK} Tag: ${CMAKE_MATCH_4}")
|
||||
MESSAGE(STATUS "These tag values will override Configuration.h")
|
||||
SET(PROJECT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${CMAKE_MATCH_4})
|
||||
else(GIT_FOUND)
|
||||
|
||||
MESSAGE(STATUS "Git was not found. Falling back to Configuration.h values (${PROJECT_VERSION}).")
|
||||
set(FW_COMMIT_HASH "0") # Clear it, the code expects a binary...
|
||||
|
||||
endif()
|
||||
|
||||
# Language configuration
|
||||
set(MAIN_LANGUAGES
|
||||
|
|
@ -335,6 +347,7 @@ function(add_base_binary variant_name)
|
|||
FW_MAJOR=${PROJECT_VERSION_MAJOR}
|
||||
FW_MINOR=${PROJECT_VERSION_MINOR}
|
||||
FW_REVISION=${PROJECT_VERSION_REV}
|
||||
FW_COMMITNR=${PROJECT_VERSION_TWEAK}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
|
|
|
|||
|
|
@ -19,12 +19,13 @@ extern const char _sPrinterMmuName[] PROGMEM;
|
|||
#define FW_MAJOR 3
|
||||
#define FW_MINOR 13
|
||||
#define FW_REVISION 0
|
||||
#define FW_COMMITNR 6853
|
||||
#warning "** Not sure why I had to touch this, but it seems like v3.13.1 is not in the linear history of this branch yet?"
|
||||
#endif
|
||||
|
||||
#define FW_FLAVOR RC //uncomment if DEBUG, DEVEL, ALPHA, BETA or RC
|
||||
#define FW_FLAVERSION 1 //uncomment if FW_FLAVOR is defined and versioning is needed. Limited to max 8.
|
||||
#warning "^^^These are temporary and need to be provided by cmake"
|
||||
#warning "^^^These are temporary and still need to be provided by cmake"
|
||||
|
||||
#ifndef FW_FLAVOR
|
||||
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,7 @@ const uint16_t FW_VERSION_NR[4] PROGMEM = {
|
|||
FW_MAJOR,
|
||||
FW_MINOR,
|
||||
FW_REVISION,
|
||||
(uint16_t)(FW_COMMIT_HASH) // explicitly truncate the hash to fit
|
||||
#warning "^^^ this is wrong and needs fixing. Should it be build nr or the flavour?"
|
||||
FW_COMMITNR
|
||||
};
|
||||
|
||||
const uint32_t FW_VERSION_HASH PROGMEM = FW_COMMIT_HASH;
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ function(git_describe _var)
|
|||
endif()
|
||||
if(NOT hash)
|
||||
set(${_var}
|
||||
"0" # This is an integer in the code...
|
||||
"HEAD-HASH-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
|
@ -229,9 +229,9 @@ function(git_describe_working_tree _var)
|
|||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
git_head_commit_number(COMMIT_COUNT) #Bake the commit count into the full DSC
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --dirty ${ARGN}
|
||||
COMMAND "${GIT_EXECUTABLE}" describe --abbrev=0 --dirty=-${COMMIT_COUNT}-D --broken=-B ${ARGN}
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
|
|
@ -358,3 +358,29 @@ function(git_head_commit_data _var _format)
|
|||
${out}
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(git_head_commit_number _var)
|
||||
if(NOT GIT_FOUND)
|
||||
find_package(Git QUIET)
|
||||
endif()
|
||||
if(NOT GIT_FOUND)
|
||||
set(${_var}
|
||||
"GIT-NOTFOUND"
|
||||
PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND "${GIT_EXECUTABLE}" rev-list --count HEAD
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
RESULT_VARIABLE res
|
||||
OUTPUT_VARIABLE out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT res EQUAL 0)
|
||||
set(out "${out}-${res}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
set(${_var}
|
||||
"${out}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Firmware/Configuration.h CFG_VER_DATA
|
|||
list(GET CFG_VER_DATA 0 PROJECT_VERSION_MAJOR)
|
||||
list(GET CFG_VER_DATA 1 PROJECT_VERSION_MINOR)
|
||||
list(GET CFG_VER_DATA 2 PROJECT_VERSION_REV)
|
||||
list(GET CFG_VER_DATA 3 PROJECT_VERSION_TWEAK)
|
||||
|
||||
string(REGEX MATCH "FW_MAJOR ([0-9]+)" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(PROJECT_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
|
|
@ -31,7 +32,10 @@ set(PROJECT_VERSION_MINOR ${CMAKE_MATCH_1})
|
|||
string(REGEX MATCH "FW_REVISION +([0-9]+)" PROJECT_VERSION_REV "${PROJECT_VERSION_REV}")
|
||||
set(PROJECT_VERSION_REV ${CMAKE_MATCH_1})
|
||||
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV}")
|
||||
string(REGEX MATCH "FW_COMMITNR +([0-9]+)" PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}")
|
||||
set(PROJECT_VERSION_TWEAK ${CMAKE_MATCH_1})
|
||||
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV}.${PROJECT_VERSION_TWEAK}")
|
||||
|
||||
function(resolve_version_variables)
|
||||
if(FW_COMMIT_DSC)
|
||||
|
|
|
|||
Loading…
Reference in New Issue