-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Non-relative includes, restructure, add missing includes #805
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
Conversation
| #include <app_timer.h> | ||
| // FreeRTOS library | ||
| #include <task.h> | ||
| // standard libraries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the comments are necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They add a bit of structure for future contributions to keep the include order. And it would have been helpful for my first exploration of the source code. For example I had no idea, that <task.h> is part of FreeRTOS. With the comment this is explicitly listet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like a dev documentation addition instead of each file.
|
Includes were sorted once a while ago, I don't see a reason to redo that part with the potential downside that InfiniTime's code conflicts with any of the libraries'. Original sort order |
|
One advantage of the new ordering is, that I was able to find some missing includes, that were hidden by the previous ordering. I don't understand the comment about conflicting library code, all the targets still compile. Would you please be so kind to explain this point to me so I can understand as well? |
Yes, at the moment. There'd be a potential for conflicts or nasty bugs when we define something and it ends up being used in a library, because ours comes first instead of being last. |
|
I think we won't (and shouldn't) define so short and generic macros, that they get picked up in libraries. Those changes would be bad code for me (personally). Even if that happens we could move those specific library includes up and still get the "include-what-you-use"-checkings Another way to argue is, that library defines could bleed into our headers and subtly break stuff. I think the argument works in both directions sorry for being pedantic about this. I just think it is "more right" and more resilient with the new ordering. In the end it's your project and your guidelines and I'll adhere to them (after a proper discussion 😁 ) |
Yes, but from the direction of libraries to us it's less error prone. |
Yes absolutely. Basically the thing is that I see a very minor upside to not changing the order (fewer changes + our code affects only our own), but I think e.g. @geekbozu or @Riksu9000 should break the tie here. |
|
I would agree with @Avamander here. I don't see enough reason to change it. |
|
reverted ordering commit, readd the found missing standard includes |
|
Since we're already restructuring, maybe the different sections should be separated by an empty line, which would make the sorting order more obvious and then clang-tidy wouldn't suggest sorting them in a different way. |
|
If every include must be non relative, it should be mentioned here https://github.com/InfiniTimeOrg/InfiniTime/blob/develop/doc/contribute.md#coding-style |
|
moving up the file header include to the top, one example from #include "displayapp/screens/WatchFaceAnalog.h"
#include <lvgl/lvgl.h>
#include "displayapp/screens/BatteryIcon.h"
#include "displayapp/screens/BleIcon.h"
#include "displayapp/screens/Symbols.h"
#include "displayapp/screens/NotificationIcon.h"Is this OK? Or should there be a space before and after the |
@Riksu9000 is this Ok? 0d745a0 |
Avamander
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems fine now. Someone should take a look as well.
|
Oh no, a conflict, if you fix that and we can merge, we can avoid breaking this PR with each and every other PR. |
0d745a0 to
e42fbce
Compare
|
rebased and conflict resolved |
e42fbce to
41cb6eb
Compare
|
rebased on current develop (after v1.7.0 release) |
Don't use relative imports like `../foo.h` as those depend on the relative position of both files. Rather than that use imports relative to the `src` directory, which explicitly is part of the include directories.
41cb6eb to
3a41bff
Compare
|
rebased on |
|
@Avamander Is something still missing, did I forget something? Or is it just limited free time for this awesome hobby? :) |
|
Everything seems to be in order, I think it's in the queue waiting for a merge. |
I'm sorry for the time it took for me to have a look at your PR! I am currently the only one that is allowed to merge PRs to develop (that might change in the future) and I couldn't allocate much time to InfiniTime recently! However, I think you did a great job cleaning the includes of the project! Thank you for that! |
|
@JF002 Thanks 🎉 Happy it's merged InfiniTime is a hobby-project. If there is no personal time left to work on it, then it is ok as well ;) It's true, that waiting for feedback for weeks was bad for motivation, but now I'm happy my contribution got merged. I'm VERY grateful to you, that you created InfiniTime. Better take some personal time, than burning out on the project In short: thank you @JF002 :) |
|
@NeroBurner Thank you so much for your kind words! Do not forget I'm not alone in this adventure! There are so many contributors and enthousiasts and users that supports the project! Thank to all of them! |
This is a two-part PR, first use relative includes, and secondly restructure all includes.
The non-relative includes are needed for me in #743 to inject my header-stubs for the simulator and is a more robust coding style for header files
First commit message:
Don't use relative imports like
../foo.has those depend on therelative position of both files. Rather than that use imports relative
to the
srcdirectory, which explicitly is part of the includedirectories.
Second commit message:
Update the include structure:
#include "foo.h"for headers from the InfiniTime project (exceptbundled libraries)
#include <foo.h>for everything else (external libraries or standardlibrary)
Change the include order from the most project specific down to the most
generic include. This helps to enforce, that our headers include what
they use. For example if
foo.husesstd::arraybut forgets theinclude. This won't be cought if
main.cppincludes<array>beforefoo.h.For example
DeviceInformationService.hdid miss<stdint>include foruint16_tandBootloaderVersion.hmissed<stddef>forsize_t.As last example
InfiniPaint.cppmissed include<algorithm>forstd::fill.The following include order is used: