Thanks @maxgerhardt, that worked perfectly. However I think maybe it needs to be post-stringifyable to satisfy the way the LVGL library expects a macro definition for where to find the master config file if not placed in the default location, which would be “[project folder]/.pio/libdeps/[my board]lv_conf.h.”
This file has to be hand crafted per project, so I want it located in the “src” folder with the rest of my code.
The LVGL library has a way to tell it the location of the config file, by defining a macro: LV_CONF_PATH.
In the LVGL library file “lv_conf_internal.h”, this section of code handles finding lv_conf.h:
/*If lv_conf.h is not skipped include it*/
#if !defined(LV_CONF_SKIP) || defined(LV_CONF_PATH)
#ifdef LV_CONF_PATH /*If there is a path defined for lv_conf.h use it*/
#define __LV_TO_STR_AUX(x) #x
#define __LV_TO_STR(x) __LV_TO_STR_AUX(x)
#include __LV_TO_STR(LV_CONF_PATH)
#undef __LV_TO_STR_AUX
#undef __LV_TO_STR
#elif defined(LV_CONF_INCLUDE_SIMPLE) /*Or simply include lv_conf.h is enabled*/
#include "lv_conf.h"
#else
#include "../../lv_conf.h" /*Else assume lv_conf.h is next to the lvgl folder*/
#endif
#if !defined(LV_CONF_H) && !defined(LV_CONF_SUPPRESS_DEFINE_CHECK)
/* #include will sometimes silently fail when __has_include is used */
/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80753 */
#pragma message("Possible failure to include lv_conf.h, please read the comment in this file if you get errors")
#endif
#endif
In file included from .pio/libdeps/my_esp32-2432S028R/lvgl/src/lv_init.h:16,
from .pio/libdeps/my_esp32-2432S028R/lvgl/lvgl.h:21,
from src/main.cpp:1:
.pio/libdeps/my_esp32-2432S028R/lvgl/src/lv_conf_internal.h:54:42: fatal error: \"D:/Projects/PlatformIO/ESP32/CYD/CYD_EEZ_Demo_B/src/lv_conf.h\": Invalid argument
#include __LV_TO_STR(LV_CONF_PATH)
^
compilation terminated.
My knowledge of complicated macros like this is minimal, and I’m struggling to figure out how to solve it, or even if it can be done.
If the stringified value of the LV_CONF_PATH variable is just #included, then you can take al ot of complexity out of this variable’s value by simply first adding the path where your wanted include file is with -I (global include search path) and then only saying -DLV_CONF_PATH="lv_conf.h".
In fact, this simplifies further with this code path
If lv_conf.h is not in the library itself, you can simple say
build_flags =
; make LVGL code try to include "lv_conf.h"
-DLV_CONF_INCLUDE_SIMPLE
; this folder has the lv_conf.h. Add it to the global include path
-Isrc/
Thanks @maxgerhardt for all your help. I got stuck down the rabbit hole trying to solve it the first way, I hadn’t noticed the LV_CONF_INCLUDE_SIMPLE method, which worked perfectly.
I now have: