Conditionally compile API user services to save 4.3KB flash (follow-up to #9262) (#9451)

This commit is contained in:
J. Nick Koston
2025-07-11 19:08:03 -10:00
committed by GitHub
parent 0138ef36cf
commit dd5ba5a90c
23 changed files with 345 additions and 52 deletions
+4 -2
View File
@@ -4,6 +4,8 @@
#ifdef USE_API
#include "esphome/components/api/api_server.h"
#endif
#ifdef USE_API_SERVICES
#include "esphome/components/api/user_services.h"
#endif
@@ -148,7 +150,7 @@ void ComponentIterator::advance() {
}
break;
#endif
#ifdef USE_API
#ifdef USE_API_SERVICES
case IteratorState ::SERVICE:
if (this->at_ >= api::global_api_server->get_user_services().size()) {
advance_platform = true;
@@ -383,7 +385,7 @@ void ComponentIterator::advance() {
}
bool ComponentIterator::on_end() { return true; }
bool ComponentIterator::on_begin() { return true; }
#ifdef USE_API
#ifdef USE_API_SERVICES
bool ComponentIterator::on_service(api::UserServiceDescriptor *service) { return true; }
#endif
#ifdef USE_CAMERA
+3 -3
View File
@@ -10,7 +10,7 @@
namespace esphome {
#ifdef USE_API
#ifdef USE_API_SERVICES
namespace api {
class UserServiceDescriptor;
} // namespace api
@@ -45,7 +45,7 @@ class ComponentIterator {
#ifdef USE_TEXT_SENSOR
virtual bool on_text_sensor(text_sensor::TextSensor *text_sensor) = 0;
#endif
#ifdef USE_API
#ifdef USE_API_SERVICES
virtual bool on_service(api::UserServiceDescriptor *service);
#endif
#ifdef USE_CAMERA
@@ -122,7 +122,7 @@ class ComponentIterator {
#ifdef USE_TEXT_SENSOR
TEXT_SENSOR,
#endif
#ifdef USE_API
#ifdef USE_API_SERVICES
SERVICE,
#endif
#ifdef USE_CAMERA
+1 -1
View File
@@ -108,7 +108,7 @@
#define USE_API_CLIENT_DISCONNECTED_TRIGGER
#define USE_API_NOISE
#define USE_API_PLAINTEXT
#define USE_API_YAML_SERVICES
#define USE_API_SERVICES
#define USE_MD5
#define USE_MQTT
#define USE_NETWORK