Skip to content

Add clang format #119

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ def generate(ctx, lang):
'rm -Rf %s/*' % config["languages"][lang]["src"],
'/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 %s' % (config["languages"][lang]["repo-slug"], lang, config["languages"][lang]["src"], config["languages"][lang].get('generator-args', '') ),
'cp LICENSE %s/LICENSE' % config["languages"][lang]["src"],
'test -d "templates/{0}-files" && cp -rT "templates/{0}-files" "{1}" || true'.format(lang, config["languages"][lang]["src"]),
],
}
] + validate(lang) + [
Expand Down Expand Up @@ -229,10 +230,18 @@ def generate(ctx, lang):
def validate(lang):
steps = {
"cpp-qt-client": [
{
"name": "validate-cpp-format",
"image": "xianpengshen/clang-tools:17",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There appears to be no decent docker image to be around.
I'd suggest that we push https://github.com/owncloud-ci/git-clang-format-lint to the registry.

"commands": [
"git clang-format -force"
]
},
{
"name": "validate-cpp",
"image": "owncloudci/client",
"commands": [
"git clang-format -force",
"mkdir build-qt",
"cd build-qt",
"cmake -GNinja -S ../%s/client" % config["languages"][lang]["src"],
Expand Down
62 changes: 62 additions & 0 deletions templates/cpp-qt-client-files/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright (C) 2016 Olivier Goffart <[email protected]>
#
# You may use this file under the terms of the 3-clause BSD license.
# See the file LICENSE from this package for details.

# This is the clang-format configuration style to be used by Qt,
# based on the rules from https://wiki.qt.io/Qt_Coding_Style and
# https://wiki.qt.io/Coding_Conventions

---
# Webkit style was loosely based on the Qt style
BasedOnStyle: WebKit

Standard: c++17
ColumnLimit: 160

# Disable reflow of qdoc comments: indentation rules are different.
# Translation comments are also excluded
CommentPragmas: "^!|^:"

# We want a space between the type and the star for pointer types
PointerBindsToType: false

# We want to break before the operators, but not before a '='
BreakBeforeBinaryOperators: NonAssignment

# Braces are usually attached, but not after functions or classes declaration
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false

# The coding style does not specify the following, but this is what gives
# results closest to the existing code.
AlignAfterOpenBracket: DontAlign
AlwaysBreakTemplateDeclarations: true

# Ideally we should also allow less short function in a single line, but
# clang-format does not handle that
AllowShortFunctionsOnASingleLine: Inline

SortIncludes: true

# macros for which the opening brace stays attached
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, forever, Q_FOREVER, QBENCHMARK, QBENCHMARK_ONCE ]

# Allow two empty lines for structuring
MaxEmptyLinesToKeep: 2
KeepEmptyLinesAtTheStartOfBlocks: false

# Properly format c++11 initializer
SpaceBeforeCpp11BracedList: false
Cpp11BracedListStyle: true