From 9b6d22be5f5511cc64a37376a2313d5d09feaecb Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 28 Mar 2026 16:05:36 -1000 Subject: [PATCH] [version] Use App.get_build_time_string() instead of including build_info_data.h Remove direct include of build_info_data.h from version_text_sensor.cpp and use the existing App.get_build_time_string() API instead. This eliminates duplicate ESPHOME_BUILD_TIME_STR and ESPHOME_COMMENT_STR symbols that were emitted into every translation unit including the header (static const in a header = one copy per TU). Now only application.cpp includes build_info_data.h, which also improves incremental rebuild times: when build info changes, only application.cpp needs recompiling instead of both application.cpp and version_text_sensor.cpp. --- esphome/components/version/version_text_sensor.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/components/version/version_text_sensor.cpp b/esphome/components/version/version_text_sensor.cpp index 8aec98d2da3..34c7aae6bca 100644 --- a/esphome/components/version/version_text_sensor.cpp +++ b/esphome/components/version/version_text_sensor.cpp @@ -1,6 +1,5 @@ #include "version_text_sensor.h" #include "esphome/core/application.h" -#include "esphome/core/build_info_data.h" #include "esphome/core/helpers.h" #include "esphome/core/log.h" #include "esphome/core/progmem.h" @@ -36,7 +35,9 @@ void VersionTextSensor::setup() { if (!this->hide_timestamp_) { size_t len = strlen(version_str); ESPHOME_strncat_P(version_str, BUILT_STR, sizeof(version_str) - len - 1); - ESPHOME_strncat_P(version_str, ESPHOME_BUILD_TIME_STR, sizeof(version_str) - strlen(version_str) - 1); + char build_time_buf[Application::BUILD_TIME_STR_SIZE]; + App.get_build_time_string(build_time_buf); + strncat(version_str, build_time_buf, sizeof(version_str) - strlen(version_str) - 1); } // The closing parenthesis is part of the config-hash suffix and must