-
Notifications
You must be signed in to change notification settings - Fork 228
Jamulus.pro: Implement (n)make clang_format
#2258
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
Jamulus.pro: Implement (n)make clang_format
#2258
Conversation
Jamulus.pro
Outdated
# Enable formatting all code via `make clang_format`. | ||
# Note: When extending the list of file extensions or when changing the excludes, | ||
# be sure to update .github/workflows/coding-style-check.yml and .clang-format-ignore as well. | ||
CLANG_SOURCES = $$files(*.cpp, true) $$files(*.h, true) |
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.
Should we include MacOS and iOS *.mm
files?
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.
In general, probably yes, but I'd rather do this in (or after) the existing PR #1871 after all of the actual details have been figured out.
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.
Aha!
@hoffie, I downloaded this branch and tested on my windows machine using the command: nmake clang_format |
make clang-format
(n)make clang-format
Thanks, even better. I think this is the more relevant test case for Windows, but I didn't think of it. Thanks! |
I've just tried out this PR on my Ubuntu 20 VM, which I have used for various builds, including Android and the
So I think either it needs to exclude My run died on |
8571728
to
aacd36f
Compare
Thanks. I didn't think about android at all. :( I really wanted to avoid whitelisting specific directories, but I no longer think that blacklisting is feasible either. I've therefore updated the code to scan for all .cpp/.h files, filter them by the directory list you gave and remove some special cases in addition (nsProcess, qrc_resources.cpp). |
Marking Windows as tested by henk. |
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.
Tested in macOS VM and it worked. The commit should say (n)make clang_format not (n)make clang-format since the command to run it is not make clang-format
(n)make clang-format
(n)make clang_format
aacd36f
to
68df675
Compare
Thanks for testing and the hint. Commit description updated. |
I think the last missing thing is adding it to the CONTRIBUTING.md file. Maybe we could also modify the PR template to hint at running (n)make clang_format right next to the checkbox with the style guide - or we could remove the style guide checkbox all together since the CI already checks it for us. |
Needs a rebase (and should be merged…) |
68df675
to
5ac4ff2
Compare
Rebased.
Added.
Yes, we can do that, but I'd rather get done with this PR and I'd say that it'd be better done in a separate one. |
This simplifies submission of properly formatted code for users with no editor/IDE integration of clang-format (jamulussoftware#1702).
5ac4ff2
to
835cb13
Compare
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'm assuming the regex syntax is right or it wouldn't work. Right? (|
rather than \|
is what made me wonder.)
I have confirmed that the excludes work, but you are right, this is suspicious. I'll check that again and mark it as Draft again. |
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'm assuming the regex syntax is right or it wouldn't work. Right? (
|
rather than\|
is what made me wonder.)I have confirmed that the excludes work, but you are right, this is suspicious. I'll check that again and mark it as Draft again.
Looks fine to me. The clang_format
target in the generated Makefile
includes all the source files that it should, and none of the ones it shouldn't. I tested it by changing an indent setting in .clang-format
and then doing:
make clang_format
# show what git says changed
git status
# show what source files were unchanged
find . -type f \( -name \*.cpp -o -name \*.h -o -name \*.mm \) ! -newer .clang-format -ls
@hoffie is this ready? For me everything seemed to work fine. |
I've done some further tests.
The So: We are used to either (Extended) POSIX regular expression syntax (brackets and pipes escaped) or PCRE-style dialects (brackets and piped unescaped). What we are seeing here is a mixture, but it's not due to the regexp syntax itself (which seems PCRE-like), but rather due to the fact that the pattern has to go through the As we now have a logical explanation, I'm merging this. CHANGELOG: Code: Add |
Short description of changes
This simplifies submission of properly formatted code for users with no editor/IDE integration of clang-format (#1702).
It had previously been submitted as #1741 with larger scope (auto-fixing on build). This part has been removed.
Context: Fixes an issue?
Pays in on #1702.
Does this change need documentation? What needs to be documented and how?
Status of this Pull Request
Ready to be tested/reviewed.
What is missing until this pull request can be merged?
make clang_format
):Checklist
My code follows the style guideno relevant style guide