New WidgetRegistry - Only include non disabled widgets in the compiled binary#319
New WidgetRegistry - Only include non disabled widgets in the compiled binary#319dreed47 wants to merge 4 commits into
Conversation
|
Actually, disabled widgets should not increase the compiled size, because they will not be linked. That being said, I'm fine with moving |
I thought I saw a difference in the binary size between current and when I wrap the includes with '#if'. I don't have exact stats but i can check again later. But also, when i moved the widgets includes to '#if' I get compile errors because some libraries like TaskFactory and GlobalTime were no longer linked in so in dev they are getting linked in through their references in the widgets somehow. This change should make things more explicit. |
Current Issue:
As we add more widgets, our compiled binary grows because every widget is included in the compilation, even disabled ones.
Solution:
This change moves widget registration out of
main.cppand into a dedicated file (WidgetRegistry.cpp). Now:main.cppis cleaner—it just needs to callregisterWidgets(widgetSet, sm, config).This change also adds a couple build flags to the platformio.ini to help reduce the final binary size by eliminating unused code and data. And also switches the platformio.ini to use extends.
How to Add a New Widget:
WidgetRegistry.cppandconfig.system.h.This makes the build more efficient and keeps the codebase better organized.