mirror of
https://github.com/esphome/esphome.git
synced 2026-02-28 18:04:19 -07:00
[core] Move build_info_data.h out of application.h to fix incremental rebuilds
build_info_data.h contains ESPHOME_BUILD_TIME which changes every build. Since application.h included it, changing any source file caused build_info_data.h to be rewritten (via sources_changed), which then triggered a rebuild of every file that includes application.h. Move all build_info_data.h dependent code from application.h inline methods to application.cpp, so only application.cpp recompiles when build info changes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
#include "esphome/core/progmem.h"
|
||||
#include "esphome/components/network/util.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/build_info_data.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/controller_registry.h"
|
||||
#include "esphome/core/entity_base.h"
|
||||
@@ -376,7 +375,9 @@ json::SerializationBuffer<> WebServer::get_config_json() {
|
||||
JsonObject root = builder.root();
|
||||
|
||||
root[ESPHOME_F("title")] = App.get_friendly_name().empty() ? App.get_name().c_str() : App.get_friendly_name().c_str();
|
||||
root[ESPHOME_F("comment")] = ESPHOME_COMMENT_STR;
|
||||
char comment_buffer[Application::COMMENT_MAX_SIZE];
|
||||
App.get_comment_string(comment_buffer);
|
||||
root[ESPHOME_F("comment")] = comment_buffer;
|
||||
#if defined(USE_WEBSERVER_OTA_DISABLED) || !defined(USE_WEBSERVER_OTA)
|
||||
root[ESPHOME_F("ota")] = false; // Note: USE_WEBSERVER_OTA_DISABLED only affects web_server, not captive_portal
|
||||
#else
|
||||
|
||||
@@ -215,7 +215,8 @@ void Application::loop() {
|
||||
void Application::process_dump_config_() {
|
||||
if (this->dump_config_at_ == 0) {
|
||||
char build_time_str[Application::BUILD_TIME_STR_SIZE];
|
||||
this->get_build_time_string(build_time_str);
|
||||
ESPHOME_strncpy_P(build_time_str, ESPHOME_BUILD_TIME_STR, sizeof(build_time_str));
|
||||
build_time_str[sizeof(build_time_str) - 1] = '\0';
|
||||
ESP_LOGI(TAG, "ESPHome version " ESPHOME_VERSION " compiled on %s", build_time_str);
|
||||
#ifdef ESPHOME_PROJECT_NAME
|
||||
ESP_LOGI(TAG, "Project " ESPHOME_PROJECT_NAME " version " ESPHOME_PROJECT_VERSION);
|
||||
@@ -749,16 +750,14 @@ void Application::get_build_time_string(std::span<char, BUILD_TIME_STR_SIZE> buf
|
||||
buffer[buffer.size() - 1] = '\0';
|
||||
}
|
||||
|
||||
size_t Application::get_comment_size() { return ESPHOME_COMMENT_SIZE; }
|
||||
|
||||
void Application::get_comment_string(char *buffer, size_t size) {
|
||||
ESPHOME_strncpy_P(buffer, ESPHOME_COMMENT_STR, size);
|
||||
buffer[size - 1] = '\0';
|
||||
void Application::get_comment_string(std::span<char, COMMENT_MAX_SIZE> buffer) {
|
||||
ESPHOME_strncpy_P(buffer.data(), ESPHOME_COMMENT_STR, buffer.size());
|
||||
buffer[buffer.size() - 1] = '\0';
|
||||
}
|
||||
|
||||
std::string Application::get_comment() {
|
||||
char buffer[ESPHOME_COMMENT_SIZE];
|
||||
this->get_comment_string(buffer, sizeof(buffer));
|
||||
char buffer[COMMENT_MAX_SIZE];
|
||||
this->get_comment_string(buffer);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -273,11 +273,11 @@ class Application {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// Get the size of the comment buffer (including null terminator)
|
||||
static size_t get_comment_size();
|
||||
/// Maximum size of the comment buffer (including null terminator)
|
||||
static constexpr size_t COMMENT_MAX_SIZE = 256;
|
||||
|
||||
/// Copy the comment string into the provided buffer
|
||||
void get_comment_string(char *buffer, size_t size);
|
||||
/// Get the comment string (PROGMEM-safe, copies to buffer)
|
||||
void get_comment_string(std::span<char, COMMENT_MAX_SIZE> buffer);
|
||||
|
||||
/// Get the comment of this Application as a string
|
||||
std::string get_comment();
|
||||
@@ -296,8 +296,7 @@ class Application {
|
||||
/// Get the build time as a Unix timestamp
|
||||
time_t get_build_time();
|
||||
|
||||
/// Copy the build time string into the provided buffer
|
||||
/// Buffer must be BUILD_TIME_STR_SIZE bytes
|
||||
/// Get the build time string (PROGMEM-safe, copies to buffer)
|
||||
void get_build_time_string(std::span<char, BUILD_TIME_STR_SIZE> buffer);
|
||||
|
||||
/// Get the build time as a string (deprecated, use get_build_time_string() instead)
|
||||
|
||||
Reference in New Issue
Block a user