Initial round of changes to address some cmake features
This commit is contained in:
parent
7cdd175cb8
commit
916d02824e
|
|
@ -36,9 +36,27 @@ set(CUSTOM_COMPILE_OPTIONS
|
||||||
set(FN_PREFIX "FW${PROJECT_VERSION}+${PROJECT_VERSION_SUFFIX}")
|
set(FN_PREFIX "FW${PROJECT_VERSION}+${PROJECT_VERSION_SUFFIX}")
|
||||||
|
|
||||||
# Inform user about the resolved settings
|
# Inform user about the resolved settings
|
||||||
message(STATUS "Project version ...........: ${PROJECT_VERSION}")
|
message(STATUS "Project version (Configuration.h): ${PROJECT_VERSION}")
|
||||||
message(STATUS "Project version suffix ....: ${PROJECT_VERSION_SUFFIX}")
|
message(STATUS "Project version suffix ..........: ${PROJECT_VERSION_SUFFIX}")
|
||||||
message(STATUS "Project version description: ${PROJECT_VERSION_FULL}")
|
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
|
# Language configuration
|
||||||
set(MAIN_LANGUAGES
|
set(MAIN_LANGUAGES
|
||||||
|
|
@ -58,7 +76,7 @@ set(COMMUNITY_LANGUAGES
|
||||||
set(SELECTED_LANGUAGES ${MAIN_LANGUAGES} ${COMMUNITY_LANGUAGES})
|
set(SELECTED_LANGUAGES ${MAIN_LANGUAGES} ${COMMUNITY_LANGUAGES})
|
||||||
|
|
||||||
get_dependency_directory(prusa3dboards PRUSA_BOARDS_DIR)
|
get_dependency_directory(prusa3dboards PRUSA_BOARDS_DIR)
|
||||||
project(Prusa-Firmware)
|
project(Prusa-Firmware VERSION ${PROJECT_VERSION})
|
||||||
add_subdirectory(lib)
|
add_subdirectory(lib)
|
||||||
|
|
||||||
# Get LANG_MAX_SIZE from sources
|
# Get LANG_MAX_SIZE from sources
|
||||||
|
|
@ -314,6 +332,9 @@ function(add_base_binary variant_name)
|
||||||
${variant_name}
|
${variant_name}
|
||||||
PRIVATE CMAKE_CONTROL FW_REPOSITORY="${PROJECT_REPOSITORY}"
|
PRIVATE CMAKE_CONTROL FW_REPOSITORY="${PROJECT_REPOSITORY}"
|
||||||
FW_VERSION_FULL="${PROJECT_VERSION_FULL}" FW_COMMIT_HASH=0x${FW_COMMIT_HASH}
|
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()
|
endfunction()
|
||||||
|
|
||||||
|
|
@ -500,7 +521,7 @@ if(CMAKE_CROSSCOMPILING)
|
||||||
set(DIR_NAME ${THIS_VAR})
|
set(DIR_NAME ${THIS_VAR})
|
||||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME})
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME})
|
||||||
file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME}/CMakeLists.txt
|
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})
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/build_gen/${DIR_NAME})
|
||||||
endforeach(THIS_VAR IN LISTS FW_VARIANTS)
|
endforeach(THIS_VAR IN LISTS FW_VARIANTS)
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,20 @@ extern const char _sPrinterName[] PROGMEM;
|
||||||
extern const uint16_t _nPrinterMmuType;
|
extern const uint16_t _nPrinterMmuType;
|
||||||
extern const char _sPrinterMmuName[] PROGMEM;
|
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_MAJOR 3
|
||||||
#define FW_MINOR 13
|
#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_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.
|
#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
|
#ifndef FW_FLAVOR
|
||||||
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION)
|
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION)
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,11 @@ const uint16_t FW_VERSION_NR[4] PROGMEM = {
|
||||||
FW_MINOR,
|
FW_MINOR,
|
||||||
FW_REVISION,
|
FW_REVISION,
|
||||||
(uint16_t)(FW_COMMIT_HASH) // explicitly truncate the hash to fit
|
(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()
|
const char* FW_VERSION_STR_P()
|
||||||
{
|
{
|
||||||
return FW_VERSION_STR;
|
return FW_VERSION_STR;
|
||||||
|
|
@ -147,7 +150,7 @@ inline bool strncmp_PP(const char *p1, const char *p2, uint8_t n)
|
||||||
return -1;
|
return -1;
|
||||||
if (pgm_read_byte(p1) > pgm_read_byte(p2))
|
if (pgm_read_byte(p1) > pgm_read_byte(p2))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@
|
||||||
extern const uint16_t FW_VERSION_NR[4];
|
extern const uint16_t FW_VERSION_NR[4];
|
||||||
extern const char* FW_VERSION_STR_P();
|
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.
|
// Definition of a firmware flavor numerical values.
|
||||||
// To keep it short as possible
|
// To keep it short as possible
|
||||||
// DEVs/ALPHAs/BETAs limited to max 8 flavor versions
|
// DEVs/ALPHAs/BETAs limited to max 8 flavor versions
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ function(git_describe _var)
|
||||||
endif()
|
endif()
|
||||||
if(NOT hash)
|
if(NOT hash)
|
||||||
set(${_var}
|
set(${_var}
|
||||||
"HEAD-HASH-NOTFOUND"
|
"0" # This is an integer in the code...
|
||||||
PARENT_SCOPE)
|
PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue