diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..ec53b72b --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp +ColumnLimit: 100 +--- diff --git a/README.md b/README.md index 0facfc9a..73339ff6 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,12 @@ cmake --build . -- fsfw-tests_coverage -j The `coverage.py` script located in the `script` folder can also be used to do this conveniently. +## Formatting the sources + +The formatting is done by the `clang-format` tool. The configuration is contained within the +`.clang-format` file in the repository root. As long as `clang-format` is installed, you +can run the `apply-clang-format.sh` helper script to format all source files consistently. + ## Index [1. High-level overview](docs/README-highlevel.md#top)
diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh new file mode 100755 index 00000000..27202324 --- /dev/null +++ b/scripts/apply-clang-format.sh @@ -0,0 +1,8 @@ +#!/bin/bash +if [[ ! -f README.md ]]; then + cd .. +fi + +find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i +find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i +find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i