Skip to content
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

Clang format #824

Merged
merged 52 commits into from
Jun 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
9f9aa1d
initial attempt to integrate clang-format
2bndy5 Oct 27, 2021
8434bb9
ammend CI changes about format checking
2bndy5 Oct 27, 2021
562f6b3
same format for all but arduino examples; force LF
2bndy5 Oct 27, 2021
86a0756
less CI logs verbosity; check pico examples fmt
2bndy5 Oct 27, 2021
521b867
don't check pico examples' format in linux CI
2bndy5 Oct 27, 2021
af523a0
Merge branch 'master' into clang-format
2bndy5 Jan 22, 2022
d8d5d93
format changes from rebasing on master
2bndy5 Jan 22, 2022
bfa2b37
re-format RF24.h
2bndy5 Jan 22, 2022
839b299
ensure the configure script uses LF endings
2bndy5 Jan 22, 2022
276bdda
attempt to get delta size reports
2bndy5 Jan 22, 2022
fa40e3f
try getting a report for a push event
2bndy5 Jan 22, 2022
94899dc
[no ci] revert get reports for push events
2bndy5 Jan 22, 2022
b6c3c69
get report for PR sync event
2bndy5 Jan 22, 2022
63651fc
report only atmega328p, atsamd21, attinyx5 chips
2bndy5 Jan 22, 2022
a0418c3
fix typo
2bndy5 Jan 22, 2022
8e3cbfc
only upload size delta reports for certain jobs
2bndy5 Jan 22, 2022
51da30e
I still hate yaml
2bndy5 Jan 22, 2022
101ee58
ran spell check; revert trigers on Arduino CI
2bndy5 Jan 26, 2022
56dd8da
fmt clang format conf
2bndy5 Jan 26, 2022
5f2c6b6
Merge branch 'master' into clang-format
2bndy5 Jan 30, 2022
191a175
re-fmt changes from master
2bndy5 Jan 30, 2022
8b9bdba
fmt new example
2bndy5 Jan 30, 2022
cce8d99
initial attempt to integrate clang-format
2bndy5 Oct 27, 2021
d1d3e3b
ammend CI changes about format checking
2bndy5 Oct 27, 2021
0baf220
same format for all but arduino examples; force LF
2bndy5 Oct 27, 2021
933200e
less CI logs verbosity; check pico examples fmt
2bndy5 Oct 27, 2021
b890e0c
don't check pico examples' format in linux CI
2bndy5 Oct 27, 2021
84cda9e
format changes from rebasing on master
2bndy5 Jan 22, 2022
50c4c95
ensure the configure script uses LF endings
2bndy5 Jan 22, 2022
1991822
attempt to get delta size reports
2bndy5 Jan 22, 2022
32ca531
try getting a report for a push event
2bndy5 Jan 22, 2022
fa79128
[no ci] revert get reports for push events
2bndy5 Jan 22, 2022
ba78ddf
get report for PR sync event
2bndy5 Jan 22, 2022
2216af8
report only atmega328p, atsamd21, attinyx5 chips
2bndy5 Jan 22, 2022
761ad62
fix typo
2bndy5 Jan 22, 2022
de1c38e
only upload size delta reports for certain jobs
2bndy5 Jan 22, 2022
34c4a1c
I still hate yaml
2bndy5 Jan 22, 2022
ed4277c
ran spell check; revert trigers on Arduino CI
2bndy5 Jan 26, 2022
8ae051c
fmt clang format conf
2bndy5 Jan 26, 2022
ee361ee
re-fmt changes from master
2bndy5 Jan 30, 2022
ea1e6df
fmt new example
2bndy5 Jan 30, 2022
592a6c4
complete rebase on updated master branch
2bndy5 Mar 12, 2022
7405e3d
Merge branch 'clang-format' of https://github.com/nRF24/RF24 into cla…
2bndy5 Mar 12, 2022
0a1ed59
ran clang-format on utility/pigpio/**
2bndy5 Mar 12, 2022
3821eac
format according to C++11 std
2bndy5 Mar 21, 2022
b29b509
Merge branch 'master' into clang-format
2bndy5 Jun 16, 2022
6322854
ran clang-format on printf.h
2bndy5 Jun 16, 2022
ec691ff
update workflows to run quicker
2bndy5 Jun 16, 2022
7ccb52d
fix bad yaml syntax
2bndy5 Jun 16, 2022
c68cefa
ubuntu-latest runners have clang-tools v12 already
2bndy5 Jun 16, 2022
dde9825
fix arduino link in contributing doc
2bndy5 Jun 16, 2022
595de69
remove old astyle config
2bndy5 Jun 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# See options listed at https://releases.llvm.org/12.0.1/tools/clang/docs/ClangFormatStyleOptions.html
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: Consecutive
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: None
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: DontAlign
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortEnumsOnASingleLine: true
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: ["__capability", "__output", "__ununsed"]
BinPackArguments: true
BinPackParameters: true
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: MultiLine
AfterEnum: true
AfterFunction: true
AfterNamespace: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakBeforeBinaryOperators: All
BreakBeforeConceptDeclarations: true
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakStringLiterals: true
ColumnLimit: 0
# CommentPragmas are a regex pattern indicating the comment is not be touched by the formatter
CommentPragmas: "^ Include gaurd .*"
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DeriveLineEnding: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineBeforeAccessModifier: Always
# ---
# only in v13+
# EmptyLineAfterAccessModifier: Leave
# ---
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
SortPriority: 0
CaseSensitive: false
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
Priority: 3
SortPriority: 0
CaseSensitive: false
- Regex: ".*"
Priority: 1
SortPriority: 0
CaseSensitive: false
IncludeIsMainRegex: "(Test)?$"
IncludeIsMainSourceRegex: ""
# ---
# only in v13+
# IndentAccessModifiers: false
# ---
IndentCaseLabels: true
IndentCaseBlocks: false
IndentGotoLabels: false
IndentPPDirectives: BeforeHash
IndentExternBlock: AfterExternBlock
IndentRequires: false
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ""
MacroBlockEnd: ""
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
# ---
# only in v13+
# ReferenceAlignment: Right
# ---
ReflowComments: true
# ---
# only in v13+
# ShortNamespaceLines: 0
# ---
# Sort**** is about sorting include/using statements alphabetically
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceAroundPointerQualifiers: Default
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyBlock: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInConditionalStatement: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpaceBeforeSquareBrackets: false
Standard: c++11
StatementAttributeLikeMacros: [emit]
StatementMacros: [Q_UNUSED, QT_REQUIRE_VERSION]
TabWidth: 4
UseCRLF: false
UseTab: Never
WhitespaceSensitiveMacros:
- PRIPSTR
- STRINGIZE
- PP_STRINGIZE
- BOOST_PP_STRINGIZE
- NS_SWIFT_NAME
- CF_SWIFT_NAME
12 changes: 12 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.py text eol=lf
*.rst text eol=lf
*.sh text eol=lf
*.h text eol=lf
*.cpp text eol=lf
*.c text eol=lf
configure text eol=lf
93 changes: 79 additions & 14 deletions .github/workflows/build_arduino.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,37 @@ on:
- ".github/workflows/build_arduino.yml"
- "examples/**"
- "!examples/old_backups/**"
env:
# convenient variable used multiple times
SKETCHES_REPORTS: sketches-reports

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check code formatting
uses: per1234/artistic-style-action@main
with:
options-file-path: ./examples/examples_formatter.conf
name-patterns: |
- '*.ino'
- '*.cpp'
- '*.hpp'
- '*.h'
target-paths: |
- examples
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino \
--ignore='examples/old_backups'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1
build:
needs: check_formatting
runs-on: ubuntu-latest
Expand Down Expand Up @@ -83,7 +95,16 @@ jobs:
- "arduino:megaavr:uno2018"
# - "arduino:megaavr:nano4809" # board not found
- "arduino:sam:arduino_due_x_dbg"

# By default, don't generate size deltas data.
enable-deltas-report:
- false
# Generate size deltas data for this board
include:
- fqbn: arduino:avr:nano
enable-deltas-report: true
- fqbn: arduino:samd:mkrzero
enable-deltas-report: true


steps:
- name: Checkout
Expand Down Expand Up @@ -112,6 +133,17 @@ jobs:
# - examples/old_backups/recipes/nordic_fob
# - examples/old_backups/recipes/pingpair_maple
fqbn: ${{ matrix.fqbn }}
enable-deltas-report: ${{ matrix.enable-deltas-report }}
sketches-report-path: ${{ env.SKETCHES_REPORTS }}

# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
if: ${{ matrix.enable-deltas-report }}
uses: actions/upload-artifact@v2
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

attiny:
needs: check_formatting
runs-on: ubuntu-latest
Expand Down Expand Up @@ -143,6 +175,13 @@ jobs:
- ATTinyCore:avr:attiny1634
- ATTinyCore:avr:attiny1634opti
- ATTinyCore:avr:attinyx313
# By default, don't generate size deltas data.
enable-deltas-report:
- false
# Generate size deltas data for this board
include:
- fqbn: ATTinyCore:avr:attinyx5
enable-deltas-report: true

steps:
- name: Checkout
Expand All @@ -159,3 +198,29 @@ jobs:
- examples/rf24_ATTiny/rf24ping85
- examples/rf24_ATTiny/timingSearch3pin
fqbn: ${{ matrix.fqbn }}
enable-deltas-report: ${{ matrix.enable-deltas-report }}
sketches-report-path: ${{ env.SKETCHES_REPORTS }}

# This step is needed to pass the size data to the report job
- name: Upload sketches report to workflow artifact
if: ${{ matrix.enable-deltas-report }}
uses: actions/upload-artifact@v2
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

# When using a matrix to compile for multiple boards, it's necessary to use a separate job for the deltas report
report:
needs: [build, attiny]
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Download sketches reports artifact
uses: actions/download-artifact@v2
with:
name: ${{ env.SKETCHES_REPORTS }}
path: ${{ env.SKETCHES_REPORTS }}

- uses: arduino/report-size-deltas@v1
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS }}
28 changes: 28 additions & 0 deletions .github/workflows/build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,35 @@ env:
BUILD_TYPE: Release

jobs:
check_formatting:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--ignore='examples|examples_pico|utility/RPi/bcm2835.h|utility/RPi/bcm2835.c'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

####################### using Makefile #############################
build:
needs: check_formatting
runs-on: ubuntu-latest

strategy:
Expand Down Expand Up @@ -144,6 +171,7 @@ jobs:

####################### using CMake ################################
using_cmake:
needs: check_formatting
runs-on: ubuntu-latest

env:
Expand Down
35 changes: 22 additions & 13 deletions .github/workflows/build_platformIO.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,28 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Check code formatting
uses: per1234/artistic-style-action@main
with:
options-file-path: ./examples/examples_formatter.conf
name-patterns: |
- '*.ino'
- '*.cpp'
- '*.hpp'
- '*.h'
target-paths: |
- examples
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
# Ubuntu 20.04.4 LTS reunners ship with clang-tools v12
# - name: Install clang-tools
# uses: KyleMayes/install-llvm-action@v1
# with:
# version: 12
- name: Install linter python package
run: python3 -m pip install git+https://github.com/cpp-linter/cpp-linter-action@v1
- name: run linter as a python package
id: linter
run: |
cpp-linter \
--version=12 \
--style=file \
--tidy-checks='-*' \
--files-changed-only='False' \
--extensions=ino \
--ignore='examples/old_backups'
- name: Linter checks failed?
if: steps.linter.outputs.checks-failed > 0
run: exit 1

build:
needs: [check_formatting, validate_lib_json]
Expand Down
Loading