-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Use clang-format to lint C++ code
- Loading branch information
Showing
4 changed files
with
72 additions
and
35 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Config for clang-format version 16 | ||
|
||
# Standard | ||
BasedOnStyle: llvm | ||
Standard: c++14 | ||
|
||
# Indentation | ||
IndentWidth: 2 | ||
ColumnLimit: 100 | ||
|
||
# Includes | ||
SortIncludes: true | ||
SortUsingDeclarations: true | ||
|
||
# Pointer and reference alignment | ||
PointerAlignment: Left | ||
ReferenceAlignment: Left | ||
ReflowComments: true | ||
|
||
# Line breaking options | ||
BreakBeforeBraces: Attach | ||
BreakConstructorInitializers: BeforeColon | ||
AllowShortFunctionsOnASingleLine: Empty | ||
IndentCaseLabels: true | ||
NamespaceIndentation: Inner | ||
|
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Validate C++ | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- '.github/workflows/validate-cpp.yml' | ||
- 'cpp/**' | ||
- 'android/src/main/cpp/**' | ||
- 'ios/**' | ||
pull_request: | ||
paths: | ||
- '.github/workflows/validate-cpp.yml' | ||
- 'cpp/**' | ||
- 'android/src/main/cpp/**' | ||
- 'ios/**' | ||
|
||
jobs: | ||
lint: | ||
name: Check clang-format | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
path: | ||
- 'cpp' | ||
- 'android/src/main/cpp' | ||
- 'ios' | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Run clang-format style check | ||
uses: jidicula/clang-format-action@v4.11.0 | ||
with: | ||
clang-format-version: '16' | ||
check-path: ${{ matrix.path }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
|
||
if which clang-format >/dev/null; then | ||
find cpp ios android/src/main/cpp -type f \( -name "*.h" -o -name "*.cpp" -o -name "*.m" -o -name "*.mm" \) -print0 | while read -d $'\0' file; do | ||
echo "-> cpp-lint $file" | ||
clang-format -i "$file" | ||
done | ||
else | ||
echo "warning: clang-format not installed, download from https://clang.llvm.org/docs/ClangFormat.html (or run brew install clang-format)" | ||
fi |