summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.clang-format92
-rw-r--r--Makefile.am4
-rw-r--r--cmake/CMakeLists.txt9
3 files changed, 105 insertions, 0 deletions
diff --git a/.clang-format b/.clang-format
new file mode 100644
index 000000000..248150212
--- /dev/null
+++ b/.clang-format
@@ -0,0 +1,92 @@
+---
+Language: Cpp
+# BasedOnStyle: GNU
+AccessModifierOffset: -2
+AlignAfterOpenBracket: AlwaysBreak
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlinesLeft: false
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: All
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: All
+AlwaysBreakAfterReturnType: AllDefinitions
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: false
+BinPackParameters: false
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: true
+BreakBeforeBinaryOperators: All
+BreakBeforeBraces: GNU
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+ColumnLimit: 120
+CommentPragmas: '^ IWYU pragma:'
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: true
+ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 3
+ - Regex: '^(<|"(gtest|isl|json)/)'
+ Priority: 4
+ - Regex: '.\*'
+ Priority: 2
+ - Regex: '^(<|"(config|config-)/)'
+ Priority: 1
+IndentCaseLabels: false
+IndentWidth: 2
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+NamespaceIndentation: None
+ObjCBlockIndentWidth: 2
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Right
+ReflowComments: true
+SortIncludes: false
+SpaceAfterCStyleCast: false
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: Always
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: true
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+Standard: Cpp03
+TabWidth: 8
+UseTab: Never
+...
+
diff --git a/Makefile.am b/Makefile.am
index 8ffa97bfd..4405d93dc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,5 +50,9 @@ DISTCHECK_CONFIGURE_FLAGS = \
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
+# TODO find clang-format
+clang-format:
+ clang-format -style=file -i $(find $(top_srcdir) -name '*.[ch]')
+
# Add rules for code-coverage testing, as defined by AX_CODE_COVERAGE
@CODE_COVERAGE_RULES@
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 3becfc90e..e67257784 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -661,6 +661,15 @@ add_custom_target(help-options
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
+find_program(CLANG_FORMAT_EXECUTABLE clang-format)
+if (CLANG_FORMAT_EXECUTABLE)
+ file(GLOB_RECURSE SOURCE_FILES RELATIVE_PATH "${CMAKE_SOURCE_DIR}/../*.[ch]")
+ add_custom_target(clang-format
+ clang-format -style=file -i ${SOURCE_FILES}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/..
+ )
+endif()
+
#
# create pkgconfig file
#