From ff48f53989f7886c167364e04df72f79039a9bac Mon Sep 17 00:00:00 2001 From: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com> Date: Tue, 22 Oct 2024 14:05:39 +1100 Subject: [PATCH] [image] Fix compile time problem with host image not using lvgl (#7654) --- esphome/components/image/image.h | 7 +------ esphome/components/lvgl/lvgl_proxy.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 esphome/components/lvgl/lvgl_proxy.h diff --git a/esphome/components/image/image.h b/esphome/components/image/image.h index ae5a7a814d..a8a8aab2c2 100644 --- a/esphome/components/image/image.h +++ b/esphome/components/image/image.h @@ -3,12 +3,7 @@ #include "esphome/components/display/display.h" #ifdef USE_LVGL -// required for clang-tidy -#ifndef LV_CONF_H -#define LV_CONF_SKIP 1 // NOLINT -#endif // LV_CONF_H - -#include +#include "esphome/components/lvgl/lvgl_proxy.h" #endif // USE_LVGL namespace esphome { diff --git a/esphome/components/lvgl/lvgl_proxy.h b/esphome/components/lvgl/lvgl_proxy.h new file mode 100644 index 0000000000..0ccd80e541 --- /dev/null +++ b/esphome/components/lvgl/lvgl_proxy.h @@ -0,0 +1,17 @@ +#pragma once +/** +* This header is for use in components that might or might not use LVGL. There is a platformio bug where +the mere mention of a header file, even if ifdefed, causes the build to fail. This is a workaround, since if this +file is included in the build, LVGL is always included. +*/ +#ifdef USE_LVGL +// required for clang-tidy +#ifndef LV_CONF_H +#define LV_CONF_SKIP 1 // NOLINT +#endif // LV_CONF_H + +#include +namespace esphome { +namespace lvgl {} // namespace lvgl +} // namespace esphome +#endif // USE_LVGL