From 835cb13b317589c595dfdda9daea3b2f59d6116b Mon Sep 17 00:00:00 2001 From: Christian Hoffmann Date: Sat, 22 May 2021 18:31:08 +0200 Subject: [PATCH] Jamulus.pro: Implement `(n)make clang_format` This simplifies submission of properly formatted code for users with no editor/IDE integration of clang-format (#1702). --- .clang-format-ignore | 6 +++++- .github/workflows/coding-style-check.yml | 2 ++ CONTRIBUTING.md | 3 +++ Jamulus.pro | 9 +++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.clang-format-ignore b/.clang-format-ignore index 4b7b414bb9..ae3fd2306b 100644 --- a/.clang-format-ignore +++ b/.clang-format-ignore @@ -1,3 +1,7 @@ -# exclude third party code from clang-format checks +# Exclude third party code from clang-format checks. +# +# This file is used by the clang-format-lint-action on Github. +# When updating this list, remember to update Jamulus.pro's CLANG_SOURCES +# as well. ./libs ./windows/nsProcess diff --git a/.github/workflows/coding-style-check.yml b/.github/workflows/coding-style-check.yml index e1b5751c00..2501bb8c92 100644 --- a/.github/workflows/coding-style-check.yml +++ b/.github/workflows/coding-style-check.yml @@ -18,4 +18,6 @@ jobs: - uses: DoozyX/clang-format-lint-action@2a28e3a8d9553f244243f7e1ff94f6685dff87be with: clangFormatVersion: 10 + # When updating the extension list, remember to update + # Jamulus.pro's CLANG_SOURCES as well. extensions: 'cpp,h,mm' diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index da0d2eaef4..3ec0552393 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -19,6 +19,9 @@ If a feature or function can be achieved in another way by another system or met - Space before and after `(` and `)`, except no space between `)` and `;`, and no space before an empty `()`. - All bodies of `if`, `else`, `while`, `for`, etc., to be enclosed in braces `{` and `}`, on separate lines. +You can use your editor's or IDE's clang-format support to accomplish that. +On the command line, you can run `make clang_format` to do the same before committing. + Do not use diff/patch to send your code changes but create a Github fork of the Jamulus code and create a Pull Request when you are done. Please run a local build test. Make sure there are no errors. After opening a pull request, keep an eye on the CI checks for quality or compile issues and fix them as required. diff --git a/Jamulus.pro b/Jamulus.pro index 9afc875aba..3101a8d043 100644 --- a/Jamulus.pro +++ b/Jamulus.pro @@ -1171,3 +1171,12 @@ contains(CONFIG, "disable_version_check") { message(The version check is disabled.) DEFINES += DISABLE_VERSION_CHECK } + +# Enable formatting all code via `make clang_format`. +# Note: When extending the list of file extensions or when adding new code directories, +# be sure to update .github/workflows/coding-style-check.yml and .clang-format-ignore as well. +CLANG_FORMAT_SOURCES = $$files(*.cpp, true) $$files(*.mm, true) $$files(*.h, true) +CLANG_FORMAT_SOURCES = $$find(CLANG_FORMAT_SOURCES, ^\(android|ios|mac|linux|src|windows\)/) +CLANG_FORMAT_SOURCES ~= s!^\(windows/\(nsProcess|ASIOSDK2\)/|src/res/qrc_resources\.cpp\)\S*$!!g +clang_format.commands = 'clang-format -i $$CLANG_FORMAT_SOURCES' +QMAKE_EXTRA_TARGETS += clang_format