mirror of
https://github.com/esphome/esphome.git
synced 2026-02-24 20:35:30 -07:00
[core] Move build_info_data.h out of application.h to fix incremental rebuilds (#14230)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "version_text_sensor.h"
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/build_info_data.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/version.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
|
||||
@@ -375,7 +375,7 @@ 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();
|
||||
char comment_buffer[ESPHOME_COMMENT_SIZE];
|
||||
char comment_buffer[Application::ESPHOME_COMMENT_SIZE_MAX];
|
||||
App.get_comment_string(comment_buffer);
|
||||
root[ESPHOME_F("comment")] = comment_buffer;
|
||||
#if defined(USE_WEBSERVER_OTA_DISABLED) || !defined(USE_WEBSERVER_OTA)
|
||||
|
||||
@@ -749,4 +749,15 @@ void Application::get_build_time_string(std::span<char, BUILD_TIME_STR_SIZE> buf
|
||||
buffer[buffer.size() - 1] = '\0';
|
||||
}
|
||||
|
||||
void Application::get_comment_string(std::span<char, ESPHOME_COMMENT_SIZE_MAX> buffer) {
|
||||
ESPHOME_strncpy_P(buffer.data(), ESPHOME_COMMENT_STR, ESPHOME_COMMENT_SIZE);
|
||||
buffer[ESPHOME_COMMENT_SIZE - 1] = '\0';
|
||||
}
|
||||
|
||||
uint32_t Application::get_config_hash() { return ESPHOME_CONFIG_HASH; }
|
||||
|
||||
uint32_t Application::get_config_version_hash() { return fnv1a_hash_extend(ESPHOME_CONFIG_HASH, ESPHOME_VERSION); }
|
||||
|
||||
time_t Application::get_build_time() { return ESPHOME_BUILD_TIME; }
|
||||
|
||||
} // namespace esphome
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <span>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "esphome/core/build_info_data.h"
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/defines.h"
|
||||
#include "esphome/core/hal.h"
|
||||
@@ -274,16 +273,15 @@ class Application {
|
||||
return "";
|
||||
}
|
||||
|
||||
/// Maximum size of the comment buffer (including null terminator)
|
||||
static constexpr size_t ESPHOME_COMMENT_SIZE_MAX = 256;
|
||||
|
||||
/// Copy the comment string into the provided buffer
|
||||
/// Buffer must be ESPHOME_COMMENT_SIZE bytes (compile-time enforced)
|
||||
void get_comment_string(std::span<char, ESPHOME_COMMENT_SIZE> buffer) {
|
||||
ESPHOME_strncpy_P(buffer.data(), ESPHOME_COMMENT_STR, buffer.size());
|
||||
buffer[buffer.size() - 1] = '\0';
|
||||
}
|
||||
void get_comment_string(std::span<char, ESPHOME_COMMENT_SIZE_MAX> buffer);
|
||||
|
||||
/// Get the comment of this Application as a string
|
||||
std::string get_comment() {
|
||||
char buffer[ESPHOME_COMMENT_SIZE];
|
||||
char buffer[ESPHOME_COMMENT_SIZE_MAX];
|
||||
this->get_comment_string(buffer);
|
||||
return std::string(buffer);
|
||||
}
|
||||
@@ -294,13 +292,13 @@ class Application {
|
||||
static constexpr size_t BUILD_TIME_STR_SIZE = 26;
|
||||
|
||||
/// Get the config hash as a 32-bit integer
|
||||
constexpr uint32_t get_config_hash() { return ESPHOME_CONFIG_HASH; }
|
||||
uint32_t get_config_hash();
|
||||
|
||||
/// Get the config hash extended with ESPHome version
|
||||
constexpr uint32_t get_config_version_hash() { return fnv1a_hash_extend(ESPHOME_CONFIG_HASH, ESPHOME_VERSION); }
|
||||
uint32_t get_config_version_hash();
|
||||
|
||||
/// Get the build time as a Unix timestamp
|
||||
constexpr time_t get_build_time() { return ESPHOME_BUILD_TIME; }
|
||||
time_t get_build_time();
|
||||
|
||||
/// Copy the build time string into the provided buffer
|
||||
/// Buffer must be BUILD_TIME_STR_SIZE bytes (compile-time enforced)
|
||||
|
||||
Reference in New Issue
Block a user