Add dev status handling
This commit is contained in:
parent
ab299e36d1
commit
2485c36391
|
|
@ -40,9 +40,11 @@ message(STATUS "Project version (Configuration.h): ${PROJECT_VERSION}")
|
|||
message(STATUS "Project version suffix ..........: ${PROJECT_VERSION_SUFFIX}")
|
||||
message(STATUS "Project version description......: ${PROJECT_VERSION_FULL}")
|
||||
|
||||
# testing
|
||||
# SET(FW_COMMIT_DSC "v3.13.0-1234")
|
||||
|
||||
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 "${PROJECT_VERSION_SUFFIX}" STREQUAL "UNKNOWN") # else -> no commit hash is known... likely no git.
|
||||
string(REGEX MATCH "v([0-9]+)\.([0-9]+)\.([0-9]+)-?(${DEV_TAG_REGEX})?([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,13 +58,24 @@ 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()
|
||||
|
||||
if (CMAKE_MATCH_4) # Do we have a build type?
|
||||
decode_flavor_code(PROJECT_VER_TAG_FLV "${CMAKE_MATCH_4}" "${CMAKE_MATCH_5}")
|
||||
else()
|
||||
# No dev status found, it must be a final tag.
|
||||
decode_flavor_code(PROJECT_VER_TAG_FLV "RELEASED" "0")
|
||||
endif()
|
||||
|
||||
if(NOT ${PROJECT_VER_TAG_FLV} STREQUAL ${PROJECT_VERSION_TWEAK})
|
||||
message(FATAL_ERROR "Dev status of current tag disagrees with Configuration.h ${PROJECT_VER_TAG_FLV}!=${PROJECT_VERSION_TWEAK}")
|
||||
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 "Configuration.h and tag match: OK (${PROJECT_VERSION}/${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${PROJECT_VER_TAG_FLV})")
|
||||
MESSAGE(STATUS "Commit Nr: Configuration.h: ${PROJECT_VERSION_COMMIT} Tag: ${CMAKE_MATCH_6}")
|
||||
MESSAGE(STATUS "These tag values will override Configuration.h")
|
||||
SET(PROJECT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${CMAKE_MATCH_4})
|
||||
SET(PROJECT_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}.${PROJECT_VER_TAG_FLV})
|
||||
else(GIT_FOUND)
|
||||
|
||||
MESSAGE(STATUS "Git was not found. Falling back to Configuration.h values (${PROJECT_VERSION}).")
|
||||
|
|
@ -339,7 +352,7 @@ function(add_base_binary variant_name)
|
|||
target_link_options(
|
||||
${variant_name} PUBLIC -Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${variant_name}.map
|
||||
)
|
||||
|
||||
decode_tweak_version(PROJECT_VERSION_FLV PROJECT_VERSION_FLV_VER)
|
||||
target_compile_definitions(
|
||||
${variant_name}
|
||||
PRIVATE CMAKE_CONTROL FW_REPOSITORY="${PROJECT_REPOSITORY}"
|
||||
|
|
@ -347,8 +360,16 @@ 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}
|
||||
FW_COMMITNR=${PROJECT_VERSION_COMMIT}
|
||||
)
|
||||
if(NOT PROJECT_VERSION_FLV STREQUAL "RELEASED")
|
||||
target_compile_definitions(
|
||||
${variant_name}
|
||||
PRIVATE
|
||||
FW_FLAVERSION=${PROJECT_VERSION_FLV_VER}
|
||||
FW_FLAVOR=${PROJECT_VERSION_FLV}
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(fw_add_variant variant_name)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#define STR_HELPER(x) #x
|
||||
#define STR(x) STR_HELPER(x)
|
||||
#define _CONCAT(x,y) x##y
|
||||
#define CONCAT(x,y) _CONCAT(x,y)
|
||||
|
||||
#include <avr/pgmspace.h>
|
||||
extern const uint16_t _nPrinterType;
|
||||
|
|
@ -19,17 +21,18 @@ 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_COMMITNR 6853
|
||||
#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 still need to be provided by cmake"
|
||||
#endif
|
||||
|
||||
#ifndef FW_FLAVOR
|
||||
#define FW_TWEAK (FIRMWARE_REVISION_RELEASED)
|
||||
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION)
|
||||
#else
|
||||
// Construct the TWEAK value as it is expected from the enum.
|
||||
#define FW_TWEAK (CONCAT(FIRMWARE_REVISION_,FW_FLAVOR) + FW_FLAVERSION)
|
||||
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION) "-" STR(FW_FLAVOR) "" STR(FW_FLAVERSION)
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ const uint16_t FW_VERSION_NR[4] PROGMEM = {
|
|||
FW_MAJOR,
|
||||
FW_MINOR,
|
||||
FW_REVISION,
|
||||
FW_COMMITNR
|
||||
FW_TWEAK,
|
||||
};
|
||||
|
||||
const uint32_t FW_VERSION_HASH PROGMEM = FW_COMMIT_HASH;
|
||||
|
|
|
|||
|
|
@ -15,13 +15,50 @@
|
|||
# ~~~
|
||||
#]]
|
||||
|
||||
# NOTE: these are ordered according to the enum in Util.h. DO NOT ALTER!
|
||||
# // Definition of a firmware flavor numerical values.
|
||||
# // To keep it short as possible
|
||||
# // DEVs/ALPHAs/BETAs limited to max 8 flavor versions
|
||||
# // RCs limited to 32 flavor versions
|
||||
# // Final Release always 64 as highest
|
||||
# enum FirmwareRevisionFlavorType : uint16_t {
|
||||
# FIRMWARE_REVISION_RELEASED = 0x0040,
|
||||
# FIRMWARE_REVISION_DEV = 0x0000,
|
||||
# FIRMWARE_REVISION_ALPHA = 0x008,
|
||||
# FIRMWARE_REVISION_BETA = 0x0010,
|
||||
# FIRMWARE_REVISION_RC = 0x0020
|
||||
# };
|
||||
|
||||
# Note - the Xes are padding because there is an extended allowance of RC numbers.
|
||||
SET(DEV_TAGS "DEV" "ALPHA" "BETA" "RC" "X" "X" "X" "X" "RELEASED")
|
||||
STRING(REPLACE ";" "\|" DEV_TAG_REGEX "${DEV_TAGS}")
|
||||
function(decode_flavor_code _output _label _ver)
|
||||
LIST(FIND DEV_TAGS "${_label}" _code_index)
|
||||
MESSAGE(DEBUG "Tweak math: (8*0${_code_index})+${_ver}")
|
||||
MATH(EXPR _decoded "(8*0${_code_index})+${_ver}")
|
||||
set(${_output}
|
||||
"${_decoded}"
|
||||
PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(decode_tweak_version _str _ver)
|
||||
MATH(EXPR _string_id "(${PROJECT_VERSION_TWEAK})/8")
|
||||
MATH(EXPR _version "${PROJECT_VERSION_TWEAK}-(8*${_string_id})")
|
||||
set(${_ver} "${_version}" PARENT_SCOPE)
|
||||
LIST(GET DEV_TAGS ${_string_id} _string_val)
|
||||
set(${_str} "${_string_val}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
|
||||
file(STRINGS ${CMAKE_CURRENT_SOURCE_DIR}/Firmware/Configuration.h CFG_VER_DATA
|
||||
REGEX "#define FW_[A-Z]+ ([0-9]+)"
|
||||
REGEX "#define FW_[A-Z]+ (${DEV_TAG_REGEX}|[0-9]+)"
|
||||
)
|
||||
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)
|
||||
list(GET CFG_VER_DATA 3 PROJECT_VERSION_COMMIT)
|
||||
list(GET CFG_VER_DATA 4 PROJECT_VERSION_FLV)
|
||||
list(GET CFG_VER_DATA 5 PROJECT_VERSION_FLV_VER)
|
||||
|
||||
string(REGEX MATCH "FW_MAJOR ([0-9]+)" PROJECT_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
|
||||
set(PROJECT_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
||||
|
|
@ -32,8 +69,21 @@ 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})
|
||||
|
||||
string(REGEX MATCH "FW_COMMITNR +([0-9]+)" PROJECT_VERSION_TWEAK "${PROJECT_VERSION_TWEAK}")
|
||||
set(PROJECT_VERSION_TWEAK ${CMAKE_MATCH_1})
|
||||
string(REGEX MATCH "FW_COMMITNR +([0-9]+)" PROJECT_VERSION_COMMIT "${PROJECT_VERSION_COMMIT}")
|
||||
set(PROJECT_VERSION_COMMIT ${CMAKE_MATCH_1})
|
||||
|
||||
string(REGEX MATCH "^#define FW_FLAVOR +(${DEV_TAG_REGEX})" PROJECT_VERSION_FLV "${PROJECT_VERSION_FLV}")
|
||||
IF(PROJECT_VERSION_FLV)
|
||||
message(STATUS "Found a defined FW_FLAVOR")
|
||||
set(PROJECT_VERSION_FLV ${CMAKE_MATCH_1})
|
||||
string(REGEX MATCH "FW_FLAVERSION +([0-9]+)" PROJECT_VERSION_FLV_VER "${PROJECT_VERSION_FLV_VER}")
|
||||
set(PROJECT_VERSION_FLV_VER ${CMAKE_MATCH_1})
|
||||
|
||||
decode_flavor_code(PROJECT_VERSION_TWEAK "${PROJECT_VERSION_FLV}" "${PROJECT_VERSION_FLV_VER}")
|
||||
ELSE()
|
||||
decode_flavor_code(PROJECT_VERSION_TWEAK "RELEASED" "0")
|
||||
ENDIF()
|
||||
|
||||
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_REV}.${PROJECT_VERSION_TWEAK}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue