build: Set all version data based on git tags

Drop the ALPHA/BETA/custom version handling. Set the version string and
firmware date based on the current tree description which has all the
required details.

Allow to override the repository information via cmake.

Use a truncated commit hash to set the internal commit number for
compatibility.

Rebase and fix issues
This commit is contained in:
Yuri D'Elia 2022-10-06 13:42:41 +02:00 committed by VintagePC
parent 80594880cd
commit 334bfe4d29
4 changed files with 23 additions and 57 deletions

View File

@ -23,6 +23,10 @@ set(PROJECT_VERSION_FULL
if(PROJECT_VERSION_FULL STREQUAL "<auto>")
set(PROJECT_VERSION_FULL "${FW_COMMIT_DSC}")
endif()
set(PROJECT_REPOSITORY
"Unknown"
CACHE STRING "Repository string to be shown on the info screen in settings."
)
set(FN_PREFIX "FW${PROJECT_VERSION}+${PROJECT_VERSION_SUFFIX}")
# Inform user about the resolved settings
@ -300,7 +304,11 @@ function(add_base_binary variant_name)
${variant_name} PUBLIC -Wl,-Map=${CMAKE_CURRENT_BINARY_DIR}/${variant_name}.map
)
target_compile_definitions(${variant_name} PRIVATE CMAKE_CONTROL)
target_compile_definitions(
${variant_name}
PRIVATE CMAKE_CONTROL FW_REPOSITORY="${PROJECT_REPOSITORY}"
FW_VERSION_FULL="${PROJECT_VERSION_FULL}" FW_COMMIT_HASH=0x${FW_COMMIT_HASH}
)
endfunction()
function(fw_add_variant variant_name)

View File

@ -24,42 +24,16 @@ extern const char _sPrinterMmuName[] PROGMEM;
#define FW_VERSION STR(FW_MAJOR) "." STR(FW_MINOR) "." STR(FW_REVISION) "-" STR(FW_FLAVOR) "" STR(FW_FLAVERSION)
#endif
#define FW_COMMIT_NR 7052
// FW_VERSION_UNKNOWN means this is an unofficial build.
// The firmware should only be checked into github with this symbol.
#define FW_DEV_VERSION FW_VERSION_UNKNOWN
// The full version string and repository source are set via cmake
#ifndef CMAKE_CONTROL
#define FW_COMMIT_HASH 0
#define FW_REPOSITORY "Unknown"
#define FW_VERSION_FULL FW_VERSION "-" STR(FW_COMMIT_NR)
#define FW_VERSION_FULL FW_VERSION "-unknown"
#endif
// G-code language level
#define GCODE_LEVEL 1
// Debug version has debugging enabled (the symbol DEBUG_BUILD is set).
// The debug build may be a bit slower than the non-debug build, therefore the debug build should
// not be shipped to a customer.
#define FW_VERSION_DEBUG 6
// This is a development build. A development build is either built from an unofficial git repository,
// or from an unofficial branch, or it does not have a label set. Only the build server should set this build type.
#define FW_VERSION_DEVEL 5
// This is an alpha release. Only the build server should set this build type.
#define FW_VERSION_ALPHA 4
// This is a beta release. Only the build server should set this build type.
#define FW_VERSION_BETA 3
// This is a release candidate build. Only the build server should set this build type.
#define FW_VERSION_RC 2
// This is a final release. Only the build server should set this build type.
#define FW_VERSION_GOLD 1
// This is an unofficial build. The firmware should only be checked into github with this symbol,
// the build server shall never produce builds with this build type.
#define FW_VERSION_UNKNOWN 0
#if FW_DEV_VERSION == FW_VERSION_DEBUG
#define DEBUG_BUILD
#else
#undef DEBUG_BUILD
#endif
#ifndef SOURCE_DATE_EPOCH
#define SOURCE_DATE_EPOCH __DATE__
#endif
@ -160,7 +134,7 @@ extern const char _sPrinterMmuName[] PROGMEM;
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// Ultimaker
// MakerGear
// #define DEFAULT_Kp 7.0
@ -196,15 +170,15 @@ The issue: If a thermistor come off, it will read a lower temperature than actua
The system will turn the heater on forever, burning up the filament and anything
else around.
After the temperature reaches the target for the first time, this feature will
start measuring for how long the current temperature stays below the target
After the temperature reaches the target for the first time, this feature will
start measuring for how long the current temperature stays below the target
minus _HYSTERESIS (set_temperature - THERMAL_RUNAWAY_PROTECTION_HYSTERESIS).
If it stays longer than _PERIOD, it means the thermistor temperature
cannot catch up with the target, so something *may be* wrong. Then, to be on the
safe side, the system will he halt.
Bear in mind the count down will just start AFTER the first time the
Bear in mind the count down will just start AFTER the first time the
thermistor temperature is over the target, so you will have no problem if
your extruder heater takes 2 minutes to hit the target on heating.
@ -296,7 +270,7 @@ your extruder heater takes 2 minutes to hit the target on heating.
#define X_MAX_LENGTH (X_MAX_POS - X_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
#define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
#define Z_HEIGHT_HIDE_LIVE_ADJUST_MENU 2.0f
@ -415,9 +389,9 @@ your extruder heater takes 2 minutes to hit the target on heating.
#endif
#endif
#endif
#endif // ENABLE_AUTO_BED_LEVELING

View File

@ -1606,10 +1606,8 @@ static void lcd_support_menu()
MENU_ITEM_BACK_P(PSTR("Firmware:"));
MENU_ITEM_BACK_P(PSTR(" " FW_VERSION_FULL));
#if (FW_DEV_VERSION != FW_VERSION_GOLD) && (FW_DEV_VERSION != FW_VERSION_RC)
MENU_ITEM_BACK_P(PSTR(" repo " FW_REPOSITORY));
#endif
MENU_ITEM_BACK_P(PSTR(" date " SOURCE_DATE_EPOCH));
MENU_ITEM_BACK_P(_n("prusa3d.com"));////MSG_PRUSA3D c=18
MENU_ITEM_BACK_P(_n("forum.prusa3d.com"));////MSG_PRUSA3D_FORUM c=18
MENU_ITEM_BACK_P(_n("help.prusa3d.com"));////MSG_PRUSA3D_HELP c=18
@ -1618,8 +1616,6 @@ static void lcd_support_menu()
MENU_ITEM_BACK_P(PSTR(ELECTRONICS));
MENU_ITEM_BACK_P(PSTR(NOZZLE_TYPE));
MENU_ITEM_BACK_P(STR_SEPARATOR);
MENU_ITEM_BACK_P(_i("Date:"));////MSG_DATE c=17
MENU_ITEM_BACK_P(PSTR(SOURCE_DATE_EPOCH));
#if defined(FILAMENT_SENSOR) && (FILAMENT_SENSOR_TYPE == FSENSOR_IR_ANALOG)
MENU_ITEM_BACK_P(STR_SEPARATOR);

View File

@ -14,19 +14,7 @@ const uint16_t FW_VERSION_NR[4] PROGMEM = {
FW_MAJOR,
FW_MINOR,
FW_REVISION,
#ifndef FW_FLAVOR
FW_COMMIT_NR
#else
# if FW_DEV_VERSION == FW_VERSION_ALPHA
FIRMWARE_REVISION_ALPHA + FW_FLAVERSION
# elif FW_DEV_VERSION == FW_VERSION_BETA
FIRMWARE_REVISION_BETA + FW_FLAVERSION
# elif FW_DEV_VERSION == FW_VERSION_RC
FIRMWARE_REVISION_RC + FW_FLAVERSION
# elif FW_DEV_VERSION == FW_VERSION_GOLD
0
# endif
#endif
(uint16_t)(FW_COMMIT_HASH) // explicitly truncate the hash to fit
};
const char* FW_VERSION_STR_P()