Skip to content

Commit 2a113d7

Browse files
committed
Github run clang format
1 parent 273a6cb commit 2a113d7

File tree

5 files changed

+192
-2
lines changed

5 files changed

+192
-2
lines changed

.clang-format

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
2+
# please use clang-format version 8 or later
3+
4+
Standard: Cpp11
5+
AccessModifierOffset: -8
6+
AlignAfterOpenBracket: Align
7+
AlignConsecutiveAssignments: false
8+
AlignConsecutiveDeclarations: false
9+
AlignEscapedNewlines: Left
10+
AlignOperands: true
11+
AlignTrailingComments: true
12+
#AllowAllArgumentsOnNextLine: false # requires clang-format 9
13+
#AllowAllConstructorInitializersOnNextLine: false # requires clang-format 9
14+
AllowAllParametersOfDeclarationOnNextLine: false
15+
AllowShortBlocksOnASingleLine: false
16+
AllowShortCaseLabelsOnASingleLine: false
17+
AllowShortFunctionsOnASingleLine: Inline
18+
AllowShortIfStatementsOnASingleLine: false
19+
#AllowShortLambdasOnASingleLine: Inline # requires clang-format 9
20+
AllowShortLoopsOnASingleLine: false
21+
AlwaysBreakAfterDefinitionReturnType: None
22+
AlwaysBreakAfterReturnType: None
23+
AlwaysBreakBeforeMultilineStrings: false
24+
AlwaysBreakTemplateDeclarations: false
25+
BinPackArguments: true
26+
BinPackParameters: true
27+
BraceWrapping:
28+
AfterClass: false
29+
AfterControlStatement: false
30+
AfterEnum: false
31+
AfterFunction: true
32+
AfterNamespace: false
33+
AfterObjCDeclaration: false
34+
AfterStruct: false
35+
AfterUnion: false
36+
AfterExternBlock: false
37+
BeforeCatch: false
38+
BeforeElse: false
39+
IndentBraces: false
40+
SplitEmptyFunction: true
41+
SplitEmptyRecord: true
42+
SplitEmptyNamespace: true
43+
BreakBeforeBinaryOperators: None
44+
BreakBeforeBraces: Custom
45+
BreakBeforeTernaryOperators: true
46+
BreakConstructorInitializers: BeforeColon
47+
BreakStringLiterals: false # apparently unpredictable
48+
ColumnLimit: 80
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
51+
ConstructorInitializerIndentWidth: 8
52+
ContinuationIndentWidth: 8
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
FixNamespaceComments: false
57+
ForEachMacros:
58+
- 'json_object_foreach'
59+
- 'json_object_foreach_safe'
60+
- 'json_array_foreach'
61+
IncludeBlocks: Preserve
62+
IndentCaseLabels: false
63+
IndentPPDirectives: None
64+
IndentWidth: 8
65+
IndentWrappedFunctionNames: false
66+
KeepEmptyLinesAtTheStartOfBlocks: true
67+
MaxEmptyLinesToKeep: 1
68+
NamespaceIndentation: None
69+
#ObjCBinPackProtocolList: Auto # requires clang-format 7
70+
ObjCBlockIndentWidth: 8
71+
ObjCSpaceAfterProperty: true
72+
ObjCSpaceBeforeProtocolList: true
73+
74+
PenaltyBreakAssignment: 10
75+
PenaltyBreakBeforeFirstCallParameter: 30
76+
PenaltyBreakComment: 10
77+
PenaltyBreakFirstLessLess: 0
78+
PenaltyBreakString: 10
79+
PenaltyExcessCharacter: 100
80+
PenaltyReturnTypeOnItsOwnLine: 60
81+
82+
PointerAlignment: Right
83+
ReflowComments: false
84+
SortIncludes: false
85+
SortUsingDeclarations: false
86+
SpaceAfterCStyleCast: false
87+
#SpaceAfterLogicalNot: false # requires clang-format 9
88+
SpaceAfterTemplateKeyword: false
89+
SpaceBeforeAssignmentOperators: true
90+
#SpaceBeforeCtorInitializerColon: true # requires clang-format 7
91+
#SpaceBeforeInheritanceColon: true # requires clang-format 7
92+
SpaceBeforeParens: ControlStatements
93+
#SpaceBeforeRangeBasedForLoopColon: true # requires clang-format 7
94+
SpaceInEmptyParentheses: false
95+
SpacesBeforeTrailingComments: 1
96+
SpacesInAngles: false
97+
SpacesInCStyleCastParentheses: false
98+
SpacesInContainerLiterals: false
99+
SpacesInParentheses: false
100+
SpacesInSquareBrackets: false
101+
#StatementMacros: # requires clang-format 8
102+
# - 'Q_OBJECT'
103+
TabWidth: 8
104+
#TypenameMacros: # requires clang-format 9
105+
# - 'DARRAY'
106+
UseTab: ForContinuationAndIndentation
107+
---
108+
Language: ObjC

.github/workflows/clang-format.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Clang Format Check
2+
3+
on: [push, pull_request]
4+
jobs:
5+
ubuntu64:
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v2
10+
with:
11+
submodules: 'recursive'
12+
13+
- name: Install clang format
14+
run: |
15+
# gets us newer clang
16+
sudo bash -c "cat >> /etc/apt/sources.list" << LLVMAPT
17+
# 3.8
18+
deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main
19+
deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main
20+
LLVMAPT
21+
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
22+
sudo apt-get -qq update
23+
sudo apt-get install -y clang-format-8
24+
- name: Check the Formatting
25+
run: |
26+
./formatcode.sh
27+
./CI/check-format.sh
28+
macos64:
29+
runs-on: macos-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
with:
34+
submodules: 'recursive'
35+
36+
- name: Install clang-format
37+
run: |
38+
brew install clang-format
39+
- name: Check the Formatting
40+
run: |
41+
./formatcode.sh
42+
./CI/check-format.sh

CI/check-format.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
dirty=$(git ls-files --modified)
3+
4+
set +x
5+
if [[ $dirty ]]; then
6+
echo "================================="
7+
echo "Files were not formatted properly"
8+
echo "$dirty"
9+
echo "================================="
10+
exit 1
11+
fi

formatcode.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/usr/bin/env bash
2+
# Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh
3+
4+
set +x
5+
set -o errexit
6+
set -o pipefail
7+
set -o nounset
8+
9+
# Runs the Clang Formatter in parallel on the code base.
10+
# Return codes:
11+
# - 1 there are files to be formatted
12+
# - 0 everything looks fine
13+
14+
# Get CPU count
15+
OS=$(uname)
16+
NPROC=1
17+
if [[ $OS = "Linux" || $OS = "Darwin" ]] ; then
18+
NPROC=$(getconf _NPROCESSORS_ONLN)
19+
fi
20+
21+
# Discover clang-format
22+
if type clang-format-8 2> /dev/null ; then
23+
CLANG_FORMAT=clang-format-8
24+
else
25+
CLANG_FORMAT=clang-format
26+
fi
27+
28+
find . -type d -type f -o -name '*.h' -or -name '*.hpp' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \
29+
| xargs -I{} -P ${NPROC} ${CLANG_FORMAT} -i -style=file -fallback-style=none {}

linux-keyboard-helpers.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,8 @@ static uint32_t KeyboardCodeFromXKeysym(unsigned int keysym)
665665
case XK_ugrave:
666666
case XK_Ugrave:
667667
case XK_brokenbar:
668-
return VKEY_OEM_102; // international backslash key in 102
669-
// keyboard.
668+
// international backslash key in 102 keyboard
669+
return VKEY_OEM_102;
670670

671671
// When evdev is in use, /usr/share/X11/xkb/symbols/inet maps F13-18
672672
// keys to the special XF86XK symbols to support Microsoft Ergonomic

0 commit comments

Comments
 (0)