diff --git a/CMakeLists.txt b/CMakeLists.txt index bf72ead3b..d5a6f4c9c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,9 +36,27 @@ set(CUSTOM_COMPILE_OPTIONS set(FN_PREFIX "FW${PROJECT_VERSION}+${PROJECT_VERSION_SUFFIX}") # Inform user about the resolved settings -message(STATUS "Project version ...........: ${PROJECT_VERSION}") -message(STATUS "Project version suffix ....: ${PROJECT_VERSION_SUFFIX}") -message(STATUS "Project version description: ${PROJECT_VERSION_FULL}") +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 ${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}") +endif() + +if(NOT ${CMAKE_MATCH_2} STREQUAL ${PROJECT_VERSION_MINOR}) + message(FATAL_ERROR "Minor version of current tag disagrees with Configuration.h ${CMAKE_MATCH_2}!=${PROJECT_VERSION_MINOR}") +endif() + +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() + +MESSAGE(STATUS "Configuration.h and tag match: OK (${PROJECT_VERSION}/${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3})") # Language configuration set(MAIN_LANGUAGES @@ -58,7 +76,7 @@ set(COMMUNITY_LANGUAGES set(SELECTED_LANGUAGES ${MAIN_LANGUAGES} ${COMMUNITY_LANGUAGES}) get_dependency_directory(prusa3dboards PRUSA_BOARDS_DIR) -project(Prusa-Firmware) +project(Prusa-Firmware VERSION ${PROJECT_VERSION}) add_subdirectory(lib) # Get LANG_MAX_SIZE from sources @@ -314,6 +332,9 @@ function(add_base_binary variant_name) ${variant_name} PRIVATE CMAKE_CONTROL FW_REPOSITORY="${PROJECT_REPOSITORY}" FW_VERSION_FULL="${PROJECT_VERSION_FULL}" FW_COMMIT_HASH=0x${FW_COMMIT_HASH} + FW_MAJOR=${PROJECT_VERSION_MAJOR} + FW_MINOR=${PROJECT_VERSION_MINOR} + FW_REVISION=${PROJECT_VERSION_REV} ) endfunction() @@ -500,7 +521,7 @@ if(CMAKE_CROSSCOMPILING) set(DIR_NAME ${THIS_VAR}) file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}) file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}/CMakeLists.txt - "project(${DIR_NAME})\nfw_add_variant(${THIS_VAR})" + "project(${DIR_NAME} VERSION ${PROJECT_VERSION})\nfw_add_variant(${THIS_VAR})" ) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}) endforeach(THIS_VAR IN LISTS FW_VARIANTS) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index d6973dc48..6a44e9fc8 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -12,12 +12,20 @@ extern const char _sPrinterName[] PROGMEM; extern const uint16_t _nPrinterMmuType; extern const char _sPrinterMmuName[] PROGMEM; -// Firmware version +// Firmware version. +// NOTE: These are ONLY used if you are not building via cmake and/or not in a git repository. +// Otherwise the repository information takes precedence. +#ifndef CMAKE_CONTROL #define FW_MAJOR 3 #define FW_MINOR 13 -#define FW_REVISION 1 +#define FW_REVISION 0 +#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" + #ifndef FW_FLAVOR #define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION) #else diff --git a/Firmware/util.cpp b/Firmware/util.cpp index ea24bac89..63cf34075 100644 --- a/Firmware/util.cpp +++ b/Firmware/util.cpp @@ -15,8 +15,11 @@ const uint16_t FW_VERSION_NR[4] PROGMEM = { 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?" }; +const uint32_t FW_VERSION_HASH PROGMEM = FW_COMMIT_HASH; + const char* FW_VERSION_STR_P() { return FW_VERSION_STR; @@ -147,7 +150,7 @@ inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n) return -1; if (pgm_read_byte(p1) > pgm_read_byte(p2)) return 1; - } + } } return 0; } diff --git a/Firmware/util.h b/Firmware/util.h index 0fcf76824..ee5748578 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -4,6 +4,9 @@ extern const uint16_t FW_VERSION_NR[4]; extern const char* FW_VERSION_STR_P(); +extern const uint32_t FW_VERSION_HASH PROGMEM; +static inline uint32_t FW_VERSION_HASH_P() { return (uint32_t)pgm_read_dword(&FW_VERSION_HASH); } + // Definition of a firmware flavor numerical values. // To keep it short as possible // DEVs/ALPHAs/BETAs limited to max 8 flavor versions diff --git a/cmake/GetGitRevisionDescription.cmake b/cmake/GetGitRevisionDescription.cmake index f9db917e8..aa0755de1 100644 --- a/cmake/GetGitRevisionDescription.cmake +++ b/cmake/GetGitRevisionDescription.cmake @@ -189,7 +189,7 @@ function(git_describe _var) endif() if(NOT hash) set(${_var} - "HEAD-HASH-NOTFOUND" + "0" # This is an integer in the code... PARENT_SCOPE) return() endif()