Add formatting tools

This commit is contained in:
karl 2020-12-16 19:59:21 +01:00
parent a09e50f5ec
commit db6c5215df
2 changed files with 25 additions and 0 deletions

12
.clang-format Normal file
View File

@ -0,0 +1,12 @@
---
BasedOnStyle: LLVM
AllowShortBlocksOnASingleLine: 'true'
AllowShortCaseLabelsOnASingleLine: 'true'
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLambdasOnASingleLine: Inline
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakBeforeMultilineStrings: 'true'
IndentWidth: '4'
...

13
tools/format.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
clang_format_command="clang-format"
clang_tidy_command="run-clang-tidy"
fi
if [[ "$OSTYPE" == "linux"* ]]; then
clang_format_command="clang-format-11"
clang_tidy_command="run-clang-tidy-11"
fi
eval "$clang_format_command -i *.h *.cpp -style=file"
eval "$clang_tidy_command -fix"