New WidgetRegistry - Only include non disabled widgets in the compiled binary #319
No reviewers
Labels
No labels
bug
conflicts
documentation
DO NOT MERGE
duplicate
enhancement
good first issue
hardware
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
greg/info-orbs!319
Loading…
Reference in a new issue
No description provided.
Delete branch "dreed47/compile-optimizations"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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.
Actually, disabled widgets should not increase the compiled size, because they will not be linked.
This will work, even if you
#includethem, i.e. you do not need to#ifthe#include(just the WidgetSet->add).That being said, I'm fine with moving
addWidgets()to a separate file as this will make themain.cppcleaner.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.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.