From fb0e096e4e73fbbc41f2044f89bf18abe87db7ee Mon Sep 17 00:00:00 2001 From: Thomas Kuschel Date: Wed, 21 Oct 2026 00:13:59 +0200 Subject: [PATCH] refactor Build Date, GIT_TAG, and GIT_HASH support --- platformio.ini | 5 +++++ src/cli.cpp | 3 ++- src/config.hpp | 2 +- src/main.cpp | 11 +++++++---- 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/platformio.ini b/platformio.ini index 03b76d2..6a6bcff 100644 --- a/platformio.ini +++ b/platformio.ini @@ -25,6 +25,11 @@ build_flags = ; -isystem /home/tom/.platformio/packages/framework-espidf/components/esp_libc/platform_include -Wno-include-next ; --- STRICT MODE FOR PROJECT APPLICATION CODE ONLY --- + + #-DGIT_HASH=\"\"${sysenv.GIT_HASH}\"\" + !echo -DGIT_HASH=\\\"$(git rev-parse --short HEAD)\\\" + !echo -DGIT_TAG=\\\"$(git describe --tags --always)\\\" + ; These flags are strictly applied ONLY to C++ files inside the src/ directory. build_src_flags = ; Enables all standard compiler warning flags diff --git a/src/cli.cpp b/src/cli.cpp index 1b52cc5..eefe133 100644 --- a/src/cli.cpp +++ b/src/cli.cpp @@ -95,7 +95,8 @@ void process_command(const char* cmd) { printf(" test-display - Run a comprehensive visual test suite\r\n"); } else if (strcmp(cmd, "version") == 0) { - printf("%s System - Running Version: %s\r\n", Config::PROJECT_TITLE, Config::PROJECT_VERSION); + printf("%s System - Running Version: %s Tag: " GIT_TAG "\r\n", Config::PROJECT_TITLE, Config::PROJECT_VERSION); + printf("Build Date: " __DATE__ ", Git-Hash: " GIT_HASH "\r\n"); } else if (strcmp(cmd, "status") == 0) { printf("--- %s Status ---\r\n", Config::PROJECT_TITLE); diff --git a/src/config.hpp b/src/config.hpp index ed9482a..89eda1d 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -22,7 +22,7 @@ namespace Config { // Compile-time constants with strict type enforcement constexpr const char* PROJECT_TITLE = "FoxMesh"; - constexpr const char* PROJECT_VERSION = "1.0.3"; + constexpr const char* PROJECT_VERSION = "1.0"; constexpr const char* PROJECT_AUTHORS = "Tom OE3TKT"; // CLI Mute Configuration diff --git a/src/main.cpp b/src/main.cpp index c508661..deb2991 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8,6 +8,10 @@ * For the full license terms, see the LICENSE file in the project root. */ +#ifndef GIT_TAG + #define GIT_TAG "unknown" +#endif + #include #include "freertos/FreeRTOS.h" #include "freertos/task.h" @@ -127,12 +131,10 @@ extern "C" { // Trigger synchronous welcome splash screen frame if (display != nullptr) { char msg[32]; - //display->printMessage(0, "FoxMesh " Config::PROJECT_VERSION " \x86" "OE3TKT"); - snprintf(msg, sizeof(msg), "FoxMesh %s", Config::PROJECT_VERSION); + snprintf(msg, sizeof(msg), "FoxMesh " GIT_TAG); display->printMessage(0, msg); - display->appendMessage(0, "OE3TKT", 15*6); + // display->appendMessage(0, GIT_TAG, 12*6); display->printMessage(1, "----------------------"); - //display->printMessage(2, "Bärbel frühstückt ©"); } // Main system watchdog and status monitor loop while (true) { @@ -140,6 +142,7 @@ extern "C" { Config::PROJECT_TITLE, Config::PROJECT_VERSION, (unsigned long)esp_get_free_heap_size()); + // ESP_LOGI(TAG, "Git-Hash: %s", GIT_HASH); vTaskDelay(pdMS_TO_TICKS(5000)); }