build: Firmware-Version bei jedem Build neu erzeugen
NINLIGHT_FW_VERSION kam bisher aus einer configure-Zeit-Variable, die nur bei erneutem CMake-Lauf aktualisiert wurde - nach einem Commit ohne Re-Konfiguration zeigte Banner/system/info also eine veraltete Git-Version. cmake/write_version.cmake schreibt build/generated/nl_version.h bei jedem Build frisch (add_custom_target ALL), app_main.c/nl_app_api.c/nl_mdns.c inkludieren das Makro jetzt von dort statt aus target_compile_definitions.
This commit is contained in:
+7
-11
@@ -1,12 +1,8 @@
|
||||
execute_process(
|
||||
COMMAND git describe --tags --always --dirty
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE NINLIGHT_FW_VERSION
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
|
||||
if(NOT NINLIGHT_FW_VERSION)
|
||||
set(NINLIGHT_FW_VERSION "0.0.0-dev")
|
||||
endif()
|
||||
string(REGEX REPLACE "^v" "" NINLIGHT_FW_VERSION "${NINLIGHT_FW_VERSION}")
|
||||
# The OTA trailer reserves 16 bytes incl. terminator for the version.
|
||||
string(SUBSTRING "${NINLIGHT_FW_VERSION}" 0 15 NINLIGHT_FW_VERSION)
|
||||
# The version is regenerated on every build so the OTA trailer and system/info match the binary.
|
||||
set(NL_VERSION_HEADER ${CMAKE_BINARY_DIR}/generated/nl_version.h)
|
||||
add_custom_target(nl_version ALL
|
||||
BYPRODUCTS ${NL_VERSION_HEADER}
|
||||
COMMAND ${CMAKE_COMMAND} -DOUT=${NL_VERSION_HEADER} -DSRC=${CMAKE_SOURCE_DIR}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/write_version.cmake
|
||||
COMMENT "Updating nl_version.h")
|
||||
string(TIMESTAMP NINLIGHT_BUILD_DATE "%Y-%m-%d")
|
||||
|
||||
Reference in New Issue
Block a user