-
Notifications
You must be signed in to change notification settings - Fork 639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert .ino -> .cpp #2228
Convert .ino -> .cpp #2228
Conversation
+7.5KB in size, can't exactly pin-point the reason though. Hopefully it is settings in-lining or I missed something like with ota.h, will check it out. |
Even for a single change, like in I have another project with esp8266 with bin size of 500kb, all with cpp files, some measurements on my system:
observations:
I think this approach of including everything in everything is not good coding practice, maybe for a short term transition period, but I cant wrap my head around the whole code architecture of |
The existing configuration lives in espurna/code/scripts/test_build.py Lines 87 to 90 in 62ad7da
PIO purges build directory on every .ini or build_flags change. test_build.py sets SRC_BUILD_FLAGS to include custom.h file and we re-use the same environment to produce different binaries 1st build (libs are already installed)
2nd build, not changing anything:
3rd, adding
Nothing is retrieved from cache :/ Previous .ino build was taking at most 10 seconds in the same conditions. I just wonder how exactly we can change the configuration in such a way that we have each .cpp depending on a specific .h. Perhaps having a single configuration header is not the way to go? If configuration is moved to a module header, for example, we can theoretically avoid the issue. We do spread configuration across multiple files though |
In any case, does this resolve the Intellisense issue? |
Having all the configuration in one place is very convenient for those who have little to no knowlege of the codebase but want their own custom build, IMO it is worth sacrificing some compile time, and this is only when config file changes which isn't that often. What I think is the main issue is too many modules depending on each other, which makes the code harder to understand, introduce bugs and makes well written/tested useful modules unusable outside I think the problem is mainly in two categories
For global defines, I think each module should have a default configuration, so If no options are provided it still should know what to do by default, eg the telnet module should have #ifndef TELNET_PORT
#define TELNET_PORT 23
#endif in its On how to change the default options, one way would be to use compile time defines using #ifdef DEFAULT_CONFIG_OVERRIDE
#include "global_configs.h"
#endif Also it would be preferred if the option for the module can be set by a class constructor or init function instead of the |
It seems to be working so far, but project wont build giving this
from the |
Hm. I can build the project via Build task, no issue there. platformio.ini is the file, there is [env] section: Line 123 in 1805d39
(https://github.com/mcspr/espurna/tree/refactoring/ino-cpp checked out in a new dir, just to be sure) |
4802394
to
70ea5d8
Compare
Just to be sure, I also tried arduino-cli to build:
|
I will look into headers configuration next, this is only for conversion itself. Although, flat config file seems to be the choice for some of embedded projects that I know of: |
Excellent job, everything seems to be working so far with very fast build times :) |
resolve #1306
@ali80
General approach is to:
espurna.h
with base headers included, each module-specific (relay.h
,gpio.h
) should include itThe goal is to avoid building unnecessary libs, which is what ldf seems to promise
ifndef
s with dependenciesPerhaps, we can avoid it and just stuff everything into espurna.h list, thus everything includes everything at once.
Not every module loads espurna.h header, so CI should fail now with the dependency issue described above.