Skip to content

Commit 1e8f3ff

Browse files
committed
Add clang format
1 parent f00252b commit 1e8f3ff

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

.drone.star

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ def generate(ctx, lang):
167167
'rm -Rf %s/*' % config["languages"][lang]["src"],
168168
'/usr/local/bin/docker-entrypoint.sh generate --enable-post-process-file -i api/openapi-spec/v1.0.yaml $${TEMPLATE_ARG} --additional-properties=packageName=libregraph --git-user-id=owncloud --git-repo-id=%s -g %s -o %s' % (config["languages"][lang]["repo-slug"], lang, config["languages"][lang]["src"]),
169169
'cp LICENSE %s/LICENSE' % config["languages"][lang]["src"],
170+
'test -d "templates/{0}-files" && cp -rT "templates/{0}-files" "{1}" || true'.format(lang, config["languages"][lang]["src"]),
170171
],
171172
}
172173
] + validate(lang) + [
@@ -228,10 +229,18 @@ def generate(ctx, lang):
228229
def validate(lang):
229230
steps = {
230231
"cpp-qt-client": [
232+
{
233+
"name": "validate-cpp-format",
234+
"image": "xianpengshen/clang-tools:17",
235+
"commands": [
236+
"git clang-format -force"
237+
]
238+
},
231239
{
232240
"name": "validate-cpp",
233241
"image": "owncloudci/client",
234242
"commands": [
243+
"git clang-format -force",
235244
"mkdir build-qt",
236245
"cd build-qt",
237246
"cmake -GNinja -S ../%s/client" % config["languages"][lang]["src"],
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# Copyright (C) 2016 Olivier Goffart <[email protected]>
2+
#
3+
# You may use this file under the terms of the 3-clause BSD license.
4+
# See the file LICENSE from this package for details.
5+
6+
# This is the clang-format configuration style to be used by Qt,
7+
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
8+
# https://wiki.qt.io/Coding_Conventions
9+
10+
---
11+
# Webkit style was loosely based on the Qt style
12+
BasedOnStyle: WebKit
13+
14+
Standard: c++17
15+
ColumnLimit: 160
16+
17+
# Disable reflow of qdoc comments: indentation rules are different.
18+
# Translation comments are also excluded
19+
CommentPragmas: "^!|^:"
20+
21+
# We want a space between the type and the star for pointer types
22+
PointerBindsToType: false
23+
24+
# We want to break before the operators, but not before a '='
25+
BreakBeforeBinaryOperators: NonAssignment
26+
27+
# Braces are usually attached, but not after functions or classes declaration
28+
BreakBeforeBraces: Custom
29+
BraceWrapping:
30+
AfterClass: true
31+
AfterControlStatement: false
32+
AfterEnum: false
33+
AfterFunction: true
34+
AfterNamespace: false
35+
AfterObjCDeclaration: false
36+
AfterStruct: true
37+
AfterUnion: false
38+
BeforeCatch: false
39+
BeforeElse: false
40+
IndentBraces: false
41+
42+
# The coding style does not specify the following, but this is what gives
43+
# results closest to the existing code.
44+
AlignAfterOpenBracket: DontAlign
45+
AlwaysBreakTemplateDeclarations: true
46+
47+
# Ideally we should also allow less short function in a single line, but
48+
# clang-format does not handle that
49+
AllowShortFunctionsOnASingleLine: Inline
50+
51+
SortIncludes: true
52+
53+
# macros for which the opening brace stays attached
54+
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]
55+
56+
# Allow two empty lines for structuring
57+
MaxEmptyLinesToKeep: 2
58+
KeepEmptyLinesAtTheStartOfBlocks: false
59+
60+
# Properly format c++11 initializer
61+
SpaceBeforeCpp11BracedList: false
62+
Cpp11BracedListStyle: true

0 commit comments

Comments
 (0)