-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
feat(code-format): 2 enhancements #7311
base: master
Are you sure you want to change the base?
feat(code-format): 2 enhancements #7311
Conversation
- code-format.cfg doesn't work on Windows because it edits every single source file and changes the line endings. Git, perceives this as a change, and makes Windows users have to RESET 672 files just in the ./src/ directory and I didn't count the number in the other directories. Resetting files can be dangerous to work in progress. Especially when it involves that many files. Rationale: Git -- out of the box, with default configuration -- automatically stores source files in its repository with LF-only (Linux) line endings. On Windows, each time a file content moves from repository to working directory, its line endings are converted to the line endings native to the platform it is running on. And each time file content is moved from working directory to repository, the line endings are converted back into LF-only (Linux). This is a desirable trait and works very well when Windows and Linux users share source files. This change follows in that spirit and makes it so `AStyle` does NOT try to edit all source files -- only the files that need formatting. I believe this follows the spirit of how it was meant to work. - code-format.py -- added some command-line argument options that allow `AStyle` to be limited to only certain directories if one already knows that's where it should look. This saves time -- important when time is precious. Simultaneously, giving it no arguments makes it run on all 4 directories as it did before. Normal users, or anyone running this from a script will see no change.
============== cc: @kisvegabor |
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.
Oh, I didn't how this Window-Linux magic is happening. Thank you! It makes sense.
For code formatting in use this pre-commit hook so for me only the changed file are formatted on every commit. So I never run the code formatter manually.
In light of that do we need the extra arguments to code-format.py
?
"Need" -- technically no. I found it useful on my system when I needed it to examine only one directory. So I offered it in case you liked it. I initially wanted to try to limit the number of source files I was having to reset under my local LVGL repository, but without the forced LF-only line endings, that problem is now solved, so for me it would only be a convenience. If you like I can re-submit without those changes. And also without the comments in |
code-format.cfg doesn't work on Windows because it makes
astyle
edit every single source file and changes the line endings. Git, perceives this as a change, and makes Windows users have to RESET 672 files just in the ./src/ directory and I didn't count the number in the other directories. Resetting files can be dangerous to work in progress. Especially when it involves that many files.Rationale: Git -- out of the box, with default configuration -- automatically stores source files in its repository with LF-only (Linux) line endings. On Windows, each time a file content moves from repository to working directory, its line endings are converted to the line endings native to the platform it is running on. And each time file content is moved from working directory to repository, the line endings are converted back into LF-only (Linux). This is a desirable trait and works seamlessly (no one knows its even happening) when Windows and Linux users share source files. This change follows in that spirit and makes it so
AStyle
does NOT try to edit all source files -- only the files that need formatting. I believe this follows the spirit of how it was meant to work.code-format.py -- added some command-line argument options that allow
AStyle
to be limited to only certain directories if one already knows that's where it should look. This saves time -- important when time is precious. Simultaneously, giving it no arguments makes it run on all 4 directories as it did before. Normal users, or anyone running this from a script will see no change.This enhancement was not discussed or asked for, but because it works so nicely on Windows when configured this way, it is submitted in hopes that those in charge will like it too, as it helps accommodate Windows users contribution to LVGL.
cc: @kisvegabor
Notes
.py
and.cfg
files.lv_conf_template.h
run lv_conf_internal_gen.py and update Kconfig. n/ascripts/code-format.py
(astyle v3.4.12
needs to installed by runningcd scripts; ./install_astyle.sh
) and follow the Code Conventions. n/a