Added Git Hash To Build
This commit is contained in:
+22
-1
@@ -1,3 +1,24 @@
|
||||
idf_component_register(SRCS "main.c" "uart_handler.c" "communication_handler.c" "uart_prot.c"
|
||||
idf_component_register(SRCS "main.c" "uart_handler.c" "communication_handler.c" "uart_prot.c" "client_handler.c" "message_parser.c" "message_builder.c" "message_handler.c"
|
||||
INCLUDE_DIRS ".")
|
||||
|
||||
# Get the short Git commit hash of the current HEAD.
|
||||
# If not in a Git repository or git command fails, it will default to "N/A".
|
||||
execute_process(
|
||||
COMMAND git rev-parse --short HEAD
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_VARIABLE GIT_COMMIT_HASH_SHORT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE GIT_HASH_RESULT
|
||||
)
|
||||
# Fallback if git is not available or not in a git repo
|
||||
if(GIT_HASH_RESULT_CODE)
|
||||
set(GIT_COMMIT_HASH_SHORT "N/A")
|
||||
endif()
|
||||
|
||||
# Add the Git hash as a preprocessor definition to your component.
|
||||
# This makes BUILD_GIT_HASH available in your C/C++ source files.
|
||||
target_compile_definitions(${COMPONENT_LIB} PRIVATE
|
||||
BUILD_GIT_HASH="${GIT_COMMIT_HASH_SHORT}"
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ void SendClientInfoTask() {
|
||||
}
|
||||
|
||||
void app_main(void) {
|
||||
ESP_LOGI(TAG, "Starting Alox Powerpod Version %d Build: %s", version,
|
||||
BUILD_GIT_HASH);
|
||||
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES ||
|
||||
ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
|
||||
Reference in New Issue
Block a user