p3p / MarlinSimUI

Marlin Simulator UI
Other
9 stars 12 forks source link

HAL_PATH(src/HAL, tft/tft_spi.h) compilation error #26

Closed lukasradek closed 1 year ago

lukasradek commented 1 year ago

HAL_PATH(src/HAL, tft/tft_spi.h) results insrc/HAL/HAL/... path with one HAL too many.

Simulator doesn't compile because of that. I have found that in multiple places in MarlinFirmware codebase.

thinkyhead commented 1 year ago

The more complete and backward-compatible solution for external libraries that want to use Marlin HAL paths is to implement their own macros:

#ifndef MY_XSTR
#define MY_XSTR_(M) #M
#define MY_XSTR(M) MY_XSTR_(M)
#endif
#ifndef SIM_SRC
#define SIM_SRC ../../../../../Marlin/src
#endif
#ifndef SIM_HAL
#define SIM_HAL SIM_SRC/HAL
#endif
#define MARLIN_HAL_PATH(PATH) HAL_PATH(SIM_HAL, PATH)
#define MARLIN_PATH(PATH) MY_XSTR(SIM_SRC/PATH)

…and then add the following to Marlin's build flags for any environment that imports the library like so…

build_flags=-DSIM_SRC=${platformio.src_dir}/src -DSIM_HAL=SIM_SRC

I recently did this for the benefit of the ESP32Lib which had the same issue.

lukasradek commented 1 year ago

Absolutely. My PR was just a bell-ring and a quickfix since I don't have any insight in Marlin & Sim integration. I was hoping @p3p will fix it better than I can 🙂.

thinkyhead commented 1 year ago

If you merge this PR https://github.com/lukasradek/MarlinSimUI/pull/1 that should be good enough for the current situation. If we want backward-compatibility then we can try other tricks, like suggested above.