--- /dev/null
+---
+AccessModifierOffset: -2
+AlignAfterOpenBracket: Align
+AlignConsecutiveAssignments: false
+AlignConsecutiveDeclarations: false
+AlignEscapedNewlines: Left
+AlignOperands: true
+AlignTrailingComments: true
+AllowAllParametersOfDeclarationOnNextLine: true
+AllowShortBlocksOnASingleLine: false
+AllowShortCaseLabelsOnASingleLine: false
+AllowShortFunctionsOnASingleLine: None
+AllowShortIfStatementsOnASingleLine: false
+AllowShortLoopsOnASingleLine: false
+AlwaysBreakAfterDefinitionReturnType: None
+AlwaysBreakAfterReturnType: None
+AlwaysBreakBeforeMultilineStrings: false
+AlwaysBreakTemplateDeclarations: false
+BinPackArguments: true
+BinPackParameters: true
+BraceWrapping:
+ AfterClass: true
+ AfterControlStatement: true
+ AfterEnum: true
+ AfterFunction: true
+ AfterNamespace: true
+ AfterObjCDeclaration: true
+ AfterStruct: true
+ AfterUnion: true
+ AfterExternBlock: true
+ BeforeCatch: true
+ BeforeElse: true
+ IndentBraces: false
+ SplitEmptyFunction: true
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+BreakBeforeBinaryOperators: None
+BreakBeforeBraces: Allman
+BreakBeforeInheritanceComma: false
+BreakBeforeTernaryOperators: true
+BreakConstructorInitializersBeforeComma: false
+BreakConstructorInitializers: BeforeColon
+BreakStringLiterals: true
+ColumnLimit: 100
+CommentPragmas: '^ IWYU pragma:'
+CompactNamespaces: false
+ConstructorInitializerAllOnOneLineOrOnePerLine: false
+ConstructorInitializerIndentWidth: 4
+ContinuationIndentWidth: 4
+Cpp11BracedListStyle: false
+DerivePointerAlignment: false
+DisableFormat: false
+ExperimentalAutoDetectBinPacking: false
+FixNamespaceComments: false
+IncludeBlocks: Preserve
+IncludeCategories:
+ - Regex: '^"(llvm|llvm-c|clang|clang-c)/'
+ Priority: 2
+ - Regex: '^(<|"(gtest|gmock|isl|json)/)'
+ Priority: 3
+ - Regex: '.*'
+ Priority: 1
+IncludeIsMainRegex: '(Test)?$'
+IndentCaseLabels: false
+IndentPPDirectives: AfterHash
+IndentWidth: 4
+IndentWrappedFunctionNames: false
+KeepEmptyLinesAtTheStartOfBlocks: true
+MacroBlockBegin: ''
+MacroBlockEnd: ''
+MaxEmptyLinesToKeep: 1
+PenaltyBreakAssignment: 2
+PenaltyBreakBeforeFirstCallParameter: 19
+PenaltyBreakComment: 300
+PenaltyBreakFirstLessLess: 120
+PenaltyBreakString: 1000
+PenaltyExcessCharacter: 1000000
+PenaltyReturnTypeOnItsOwnLine: 60
+PointerAlignment: Left
+ReflowComments: true
+SortIncludes: false
+SortUsingDeclarations: true
+SpaceAfterCStyleCast: false
+SpaceAfterTemplateKeyword: true
+SpaceBeforeAssignmentOperators: true
+SpaceBeforeParens: ControlStatements
+SpaceInEmptyParentheses: false
+SpacesBeforeTrailingComments: 1
+SpacesInAngles: false
+SpacesInContainerLiterals: false
+SpacesInCStyleCastParentheses: false
+SpacesInParentheses: false
+SpacesInSquareBrackets: false
+TabWidth: 4
+UseTab: ForIndentation
+...
+Language: Cpp
+Standard: Auto
+NamespaceIndentation: All
+ForEachMacros:
+ - foreach
+ - Q_FOREACH
+ - BOOST_FOREACH
+...
+Language: ObjC
+PointerBindsToType: false
+ObjCSpaceAfterProperty: true
+SortIncludes: false
+ObjCBlockIndentWidth: 4
+ObjCSpaceAfterProperty: false
+ObjCSpaceBeforeProtocolList: true
+...
+Language: Java
+BreakAfterJavaFieldAnnotations: false
+...
+Language: JavaScript
+JavaScriptQuotes: Leave
+JavaScriptWrapImports: true
+...
+Language: Proto
+...
+Language: TableGen
+...
+Language: TextProto
+...
--- /dev/null
+# get all project files
+file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.c *.h *.m *.java)
+# minimum version required
+set(_CLANG_FORMAT_MINIMUM_VERSION 7.0.0)
+
+find_program(CLANG_FORMAT
+ NAMES
+ clang-format-8
+ clang-format-7
+ clang-format
+ )
+
+if (NOT CLANG_FORMAT)
+ message(WARNING "clang-format not found in path! code format target not available.")
+else()
+ execute_process(
+ COMMAND ${CLANG_FORMAT} "--version"
+ OUTPUT_VARIABLE _CLANG_FORMAT_VERSION
+ RESULT_VARIABLE _CLANG_FORMAT_VERSION_FAILED
+ )
+
+ if (_CLANG_FORMAT_VERSION_FAILED)
+ message(WARNING "A problem was encounterd with ${CLANG_FORMAT}")
+ return()
+ endif()
+
+ string(REGEX MATCH "([7-9]|[1-9][0-9])\\.[0-9]\\.[0-9]" CLANG_FORMAT_VERSION
+ "${_CLANG_FORMAT_VERSION}")
+
+ if (NOT CLANG_FORMAT_VERSION)
+ message(WARNING "problem parsing clang-fromat version for ${CLANG_FORMAT}")
+ return()
+ endif()
+
+ if (${CLANG_FORMAT_VERSION} VERSION_LESS ${_CLANG_FORMAT_MINIMUM_VERSION})
+ message(WARNING "clang-format version ${CLANG_FORMAT_VERSION} not supported")
+ message(WARNING "Minimum version required: ${_CLANG_FORMAT_MINIMUM_VERSION}")
+ return()
+ endif()
+
+ add_custom_target(
+ clangformat
+ COMMAND ${CLANG_FORMAT}
+ -style=file
+ -i
+ ${ALL_SOURCE_FILES}
+ )
+endif()
+++ /dev/null
-#!/bin/bash
-
-ASTYLE=$(which astyle)
-
-if [ ! -x "$ASTYLE" ]; then
- echo "No astyle found in path, please install."
- exit 1
-fi
-
-# Need at least astyle 2.03 due to bugs in older versions
-# indenting headers with extern "C"
-STR_VERSION=$($ASTYLE --version 2>&1)
-VERSION=$(echo $STR_VERSION | cut -d ' ' -f4)
-MAJOR_VERSION=$(echo $VERSION | cut -d'.' -f1)
-MINOR_VERSION=$(echo $VERSION | cut -d'.' -f2)
-
-if [ "$MAJOR_VERSION" -lt "2" ];
-then
- echo "Your version of astyle($VERSION) is too old, need at least 2.03"
- exit 1
-elif [ "$MAJOR_VERSION" -eq "2" ];
-then
- if [ "$MINOR_VERSION" -lt "3" ];
- then
- echo "Your version of astyle($VERSION) is too old, need at least 2.03"
- exit 1
- fi
-fi
-
-if [ $# -le 0 ]; then
- echo "Usage:"
- echo -e "\t$0 <file1> [<file2> ...]"
- exit 2
-fi
-
-$ASTYLE --lineend=linux --mode=c --indent=tab=4 --pad-header --pad-oper --style=allman --min-conditional-indent=0 \
- --indent-switches --indent-cases --indent-preprocessor -k1 --max-code-length=100 \
- --indent-col1-comments --delete-empty-lines --break-closing-brackets \
- --align-pointer=type --indent-labels -xe --break-after-logical \
- --unpad-paren --break-blocks $@
-
-exit $?