From 7a2d7fdd19093c2170cbafdda7427c8a869f0dd7 Mon Sep 17 00:00:00 2001 From: Expaso Date: Mon, 13 Feb 2023 03:43:52 +0100 Subject: [PATCH] Fixed PlatformIO Build on DEV (#4422) Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com> --- esphome/components/bedjet/bedjet_hub.cpp | 4 ++++ esphome/components/bedjet/bedjet_hub.h | 3 +-- esphome/components/ble_client/automation.cpp | 4 ++++ esphome/components/ble_client/automation.h | 4 ++-- esphome/components/esp32/post_build.py.script | 24 +++++++++++++------ esphome/components/mqtt/mqtt_light.cpp | 2 ++ esphome/core/defines.h | 2 +- platformio.ini | 1 + 8 files changed, 32 insertions(+), 12 deletions(-) diff --git a/esphome/components/bedjet/bedjet_hub.cpp b/esphome/components/bedjet/bedjet_hub.cpp index f90ca5cf54..fbd2876dc9 100644 --- a/esphome/components/bedjet/bedjet_hub.cpp +++ b/esphome/components/bedjet/bedjet_hub.cpp @@ -1,3 +1,5 @@ +#ifdef USE_ESP32 + #include "bedjet_hub.h" #include "bedjet_child.h" #include "bedjet_const.h" @@ -541,3 +543,5 @@ void BedJetHub::register_child(BedJetClient *obj) { } // namespace bedjet } // namespace esphome + +#endif diff --git a/esphome/components/bedjet/bedjet_hub.h b/esphome/components/bedjet/bedjet_hub.h index fb757dfdf8..e4af2bca51 100644 --- a/esphome/components/bedjet/bedjet_hub.h +++ b/esphome/components/bedjet/bedjet_hub.h @@ -1,4 +1,5 @@ #pragma once +#ifdef USE_ESP32 #include "esphome/components/ble_client/ble_client.h" #include "esphome/components/esp32_ble_tracker/esp32_ble_tracker.h" @@ -14,8 +15,6 @@ #include "esphome/components/time/real_time_clock.h" #endif -#ifdef USE_ESP32 - #include namespace esphome { diff --git a/esphome/components/ble_client/automation.cpp b/esphome/components/ble_client/automation.cpp index 395950dd26..429f906a5f 100644 --- a/esphome/components/ble_client/automation.cpp +++ b/esphome/components/ble_client/automation.cpp @@ -1,3 +1,5 @@ +#ifdef USE_ESP32 + #include "automation.h" #include @@ -73,3 +75,5 @@ void BLEWriterClientNode::gattc_event_handler(esp_gattc_cb_event_t event, esp_ga } // namespace ble_client } // namespace esphome + +#endif diff --git a/esphome/components/ble_client/automation.h b/esphome/components/ble_client/automation.h index ef38333698..45ddba9782 100644 --- a/esphome/components/ble_client/automation.h +++ b/esphome/components/ble_client/automation.h @@ -1,13 +1,13 @@ #pragma once +#ifdef USE_ESP32 + #include #include #include "esphome/core/automation.h" #include "esphome/components/ble_client/ble_client.h" -#ifdef USE_ESP32 - namespace esphome { namespace ble_client { class BLEClientConnectTrigger : public Trigger<>, public BLEClientNode { diff --git a/esphome/components/esp32/post_build.py.script b/esphome/components/esp32/post_build.py.script index 406516a102..c941bdb386 100644 --- a/esphome/components/esp32/post_build.py.script +++ b/esphome/components/esp32/post_build.py.script @@ -1,15 +1,25 @@ # Source https://github.com/letscontrolit/ESPEasy/pull/3845#issuecomment-1005864664 -import os -if os.environ.get("ESPHOME_USE_SUBPROCESS") is None: - import esptool -else: - import subprocess -from SCons.Script import ARGUMENTS - # pylint: disable=E0602 Import("env") # noqa +import os +import shutil + +if os.environ.get("ESPHOME_USE_SUBPROCESS") is None: + try: + import esptool + except ImportError: + env.Execute("$PYTHONEXE -m pip install esptool") +else: + import subprocess +from SCons.Script import ARGUMENTS + +# Copy over the default sdkconfig. +from os import path +if path.exists("./sdkconfig.defaults"): + os.makedirs(".temp", exist_ok=True) + shutil.copy("./sdkconfig.defaults", "./.temp/sdkconfig-esp32-idf") def esp32_create_combined_bin(source, target, env): verbose = bool(int(ARGUMENTS.get("PIOVERBOSE", "0"))) diff --git a/esphome/components/mqtt/mqtt_light.cpp b/esphome/components/mqtt/mqtt_light.cpp index e2480acd62..f970da7d8c 100644 --- a/esphome/components/mqtt/mqtt_light.cpp +++ b/esphome/components/mqtt/mqtt_light.cpp @@ -3,6 +3,7 @@ #include "mqtt_const.h" +#ifdef USE_JSON #ifdef USE_MQTT #ifdef USE_LIGHT @@ -83,3 +84,4 @@ void MQTTJSONLightComponent::dump_config() { #endif #endif // USE_MQTT +#endif // USE_JSON diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 01fc16cc02..c3738c0365 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -25,6 +25,7 @@ #define USE_FAN #define USE_GRAPH #define USE_HOMEASSISTANT_TIME +#define USE_JSON #define USE_LIGHT #define USE_LOCK #define USE_LOGGER @@ -50,7 +51,6 @@ // Arduino-specific feature flags #ifdef USE_ARDUINO #define USE_CAPTIVE_PORTAL -#define USE_JSON #define USE_NEXTION_TFT_UPLOAD #define USE_PROMETHEUS #define USE_WEBSERVER diff --git a/platformio.ini b/platformio.ini index b92a1407ed..ef5820c4ad 100644 --- a/platformio.ini +++ b/platformio.ini @@ -185,6 +185,7 @@ build_flags = [env:esp32-arduino] extends = common:esp32-arduino board = esp32dev +board_build.partitions = huge_app.csv build_flags = ${common:esp32-arduino.build_flags} ${flags:runtime.build_flags}