diff --git a/esphome/components/haier/haier_base.h b/esphome/components/haier/haier_base.h index 7d92a6611c..1a1230045f 100644 --- a/esphome/components/haier/haier_base.h +++ b/esphome/components/haier/haier_base.h @@ -47,7 +47,7 @@ class HaierClimateBase : public esphome::Component, void set_supported_presets(const std::set &presets); bool valid_connection() const { return this->protocol_phase_ >= ProtocolPhases::IDLE; }; size_t available() noexcept override { return esphome::uart::UARTDevice::available(); }; - size_t read_array(uint8_t *data, size_t len) noexcept override { + size_t read_array(uint8_t *data, size_t len) noexcept override { // NOLINT(readability-non-const-parameter) return esphome::uart::UARTDevice::read_array(data, len) ? len : 0; }; void write_array(const uint8_t *data, size_t len) noexcept override { diff --git a/esphome/components/lvgl/light/lvgl_light.h b/esphome/components/lvgl/light/lvgl_light.h index 67372d89dd..5a178ad5ee 100644 --- a/esphome/components/lvgl/light/lvgl_light.h +++ b/esphome/components/lvgl/light/lvgl_light.h @@ -18,7 +18,7 @@ class LVLight : public light::LightOutput { float red, green, blue; state->current_values_as_rgb(&red, &green, &blue, false); auto color = lv_color_make(red * 255, green * 255, blue * 255); - if (this->obj_ != nullptr) { + if (this->obj_ != nullptr) { // NOLINT(bugprone-branch-clone) this->set_value_(color); } else { this->initial_value_ = color; diff --git a/esphome/components/network/__init__.py b/esphome/components/network/__init__.py index 9ef75e0fb9..96db322bde 100644 --- a/esphome/components/network/__init__.py +++ b/esphome/components/network/__init__.py @@ -1,8 +1,6 @@ -from esphome.core import CORE import esphome.codegen as cg -import esphome.config_validation as cv from esphome.components.esp32 import add_idf_sdkconfig_option - +import esphome.config_validation as cv from esphome.const import ( CONF_ENABLE_IPV6, CONF_MIN_IPV6_ADDR_COUNT, @@ -10,6 +8,7 @@ from esphome.const import ( PLATFORM_ESP8266, PLATFORM_RP2040, ) +from esphome.core import CORE CODEOWNERS = ["@esphome/core"] AUTO_LOAD = ["mdns"] @@ -33,6 +32,7 @@ CONFIG_SCHEMA = cv.Schema( async def to_code(config): + cg.add_define("USE_NETWORK") if (enable_ipv6 := config.get(CONF_ENABLE_IPV6, None)) is not None: cg.add_define("USE_NETWORK_IPV6", enable_ipv6) if enable_ipv6: @@ -42,11 +42,10 @@ async def to_code(config): if CORE.using_esp_idf: add_idf_sdkconfig_option("CONFIG_LWIP_IPV6", enable_ipv6) add_idf_sdkconfig_option("CONFIG_LWIP_IPV6_AUTOCONFIG", enable_ipv6) - else: - if enable_ipv6: - cg.add_build_flag("-DCONFIG_LWIP_IPV6") - cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG") - if CORE.is_rp2040: - cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6") - if CORE.is_esp8266: - cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY") + elif enable_ipv6: + cg.add_build_flag("-DCONFIG_LWIP_IPV6") + cg.add_build_flag("-DCONFIG_LWIP_IPV6_AUTOCONFIG") + if CORE.is_rp2040: + cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_ENABLE_IPV6") + if CORE.is_esp8266: + cg.add_build_flag("-DPIO_FRAMEWORK_ARDUINO_LWIP2_IPV6_LOW_MEMORY") diff --git a/esphome/components/network/ip_address.h b/esphome/components/network/ip_address.h index 30a426e458..941934cf0a 100644 --- a/esphome/components/network/ip_address.h +++ b/esphome/components/network/ip_address.h @@ -1,4 +1,6 @@ #pragma once +#include "esphome/core/defines.h" +#ifdef USE_NETWORK #include #include #include @@ -140,3 +142,4 @@ using IPAddresses = std::array; } // namespace network } // namespace esphome +#endif diff --git a/esphome/components/network/util.h b/esphome/components/network/util.h index 5377d44f2f..b518696e68 100644 --- a/esphome/components/network/util.h +++ b/esphome/components/network/util.h @@ -1,5 +1,6 @@ #pragma once - +#include "esphome/core/defines.h" +#ifdef USE_NETWORK #include #include "ip_address.h" @@ -16,3 +17,4 @@ IPAddresses get_ip_addresses(); } // namespace network } // namespace esphome +#endif diff --git a/esphome/components/partition/light_partition.h b/esphome/components/partition/light_partition.h index bd90b4c4f1..55ad0ca9dc 100644 --- a/esphome/components/partition/light_partition.h +++ b/esphome/components/partition/light_partition.h @@ -79,7 +79,7 @@ class PartitionLightOutput : public light::AddressableLight { int32_t seg_off = index - seg.get_dst_offset(); // offset within the src int32_t src_off; - if (seg.is_reversed()) { + if (seg.is_reversed()) { // NOLINT(bugprone-branch-clone) src_off = seg.get_src_offset() + seg.get_size() - seg_off - 1; } else { src_off = seg.get_src_offset() + seg_off; diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index d79cde0b18..dde0d1d5a5 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -1,9 +1,10 @@ #pragma once +#include "esphome/core/defines.h" +#ifdef USE_WIFI #include "esphome/components/network/ip_address.h" #include "esphome/core/automation.h" #include "esphome/core/component.h" -#include "esphome/core/defines.h" #include "esphome/core/helpers.h" #include @@ -442,3 +443,4 @@ template class WiFiDisableAction : public Action { } // namespace wifi } // namespace esphome +#endif diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 61a4940d01..db3c962837 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -50,7 +50,6 @@ #define USE_LVGL_ROTARY_ENCODER #define USE_MDNS #define USE_MEDIA_PLAYER -#define USE_MQTT #define USE_NEXTION_TFT_UPLOAD #define USE_NUMBER #define USE_ONLINE_IMAGE_PNG_SUPPORT @@ -72,8 +71,14 @@ #define USE_UART_DEBUGGER #define USE_UPDATE #define USE_VALVE + +// Things which do not work for zephyr +#ifndef USE_ZEPHYR +#define USE_MQTT +#define USE_NETWORK #define USE_WIFI #define USE_WIFI_AP +#endif // Arduino-specific feature flags #ifdef USE_ARDUINO diff --git a/script/clang-tidy b/script/clang-tidy index 3f40932fad..0ffaa32b96 100755 --- a/script/clang-tidy +++ b/script/clang-tidy @@ -236,7 +236,44 @@ def main(): files = split_list(files, args.split_num)[args.split_at - 1] if args.all_headers and args.split_at in (None, 1): - build_all_include() + triplet = os.path.basename(idedata["cxx_path"])[:-4] + exclude_components = [] + if "zephyr" in triplet: + exclude_components = [ + "api", + "web_server_base", + "web_server", + "prometheus", + "captive_portal", + "socket", + "voice_assistant", + "homeassistant", + "bluetooth_proxy", + "wake_on_lan", + "esphome", + "e131", + "haier", + "improv_serial", + "lvgl", + "fingerprint_grow", + "md5", + "mlx90393", + "mqtt", + "online_image", + "sgp4x", + "wireguard", + "tuya", + "status", + "nextion", + "mqtt", + "improv_base", + "http_request", + "ota", + "wifi_info", + "wifi_signal", + "bedjet", + ] + build_all_include(exclude_components) files.insert(0, temp_header_file) tmpdir = None diff --git a/script/helpers.py b/script/helpers.py index d06565ad7a..450c58e82a 100644 --- a/script/helpers.py +++ b/script/helpers.py @@ -29,7 +29,7 @@ def print_error_for_file(file, body): print() -def build_all_include(): +def build_all_include(exclude_components): # Build a cpp file that includes all header files in this repo. # Otherwise header-only integrations would not be tested by clang-tidy headers = [] @@ -37,6 +37,9 @@ def build_all_include(): filetypes = (".h",) ext = os.path.splitext(path)[1] if ext in filetypes: + parts = path.split("/components/") + if len(parts) > 1 and parts[1].split("/")[0] in exclude_components: + continue path = os.path.relpath(path, root_path) include_p = path.replace(os.path.sep, "/") headers.append(f'#include "{include_p}"')