-
Notifications
You must be signed in to change notification settings - Fork 41
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
Fix for old clang-format #199
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
From clang-format docs:
Since the fprime
.clang-format
lives infprime/.clang-format
, this will not be able to catch the format file if you are formatting a file outside offprime/
(i.e. in your project, say inHelloWorldProject/Components/MyComponent/
)Ways I can think of to deal with this:
.clang-format
be copied to the project's root when runningfprime-bootstrap project
. This would mean projects could tweak with how they like their formatting, which may be good. But I am not sure I like the idea of duplicating the file...Let me know what you think! Or if you can think of better alternatives
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.
Am I missing something? I pulled up clang-format 10.0.0 documentation (https://releases.llvm.org/10.0.0/tools/clang/docs/ClangFormat.html) and it says that
-style=file
is supported.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.
@LeStarch the difference is between
--style=file
, which recurses up directories until it finds a.clang-format
and--style=file:<path-to-clang-format>
which uses the file at the given path.We currently use the latter, pointing to
<project>/fprime/.clang-format
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.
@thomas-bc I see. The above means literally
--style=file
and the new is literally--style=file:/some/path
now I see.I am in-favor of cloning configuration out of fprime into projects (e.g.
fprime/config
->project/config
,fprime/.clang-format
->project/.clang-format
, ect). Although this makes the upgrade path harder, it makes the customization story much easier.If you @thomas-bc concur, we can merge this, and fix the project creation in a separate PR.
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 am also liking the first option, since it will allow third parties to use their own
.clang-format
andfprime-util format
if needed.I would have liked to have an option on
fprime-util
to specify the.clang-format
file to be used as an optional parameter. This could work easily with version of clang-tidy >= 14.0, but not for the older versions. The only way I found to do so, is to copy temporarily the.clang-format
file in the folder of the formatted file, but I don't think it's worth it.If you think it is something worth having, I can later work on adding a version check and allow the user to specify the style file only if the version of clang-tidy is >= 14.0.
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.
What is the behavior in this case? If it fails, then the solution is obvious: add a .clang-format. If it formats with the default clang-format, good it has a defined format.
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 meant to say
--fallback-style
from clang-format: https://clang.llvm.org/docs/ClangFormat.htmlThere 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.
Could we not just accept "LLVM" as a reasonable fallback style for projects that don't define a .clang-format? It is the default after all.
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 also do like your idea of having
fprime-util format
check the existence of a.clang-format
file at the root of the project and if it doesn't exist -> automatically create one.This gently pushes for best practice, and will ensure older projects get up to speed on this new file that should be at the root of the project.
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 wasn't suggesting that, but it is a good idea!