From fd7581f8babebdd9eeb13cc4a9800dbb80f893a4 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Dec 2021 16:08:28 +0100 Subject: [PATCH 1/3] Added formatting scripts 1. Added .clang-format file which contains information for the clang-format tool on how to format source files 2. Added shell helper script to apply all changes on HAL soures, test sources and primary sources The shell script was not applied yet. This should be done shortly before introducing the release. Also, it might be good idea to provide instructions on how to set up the formatter for Eclipse --- .clang-format | 7 +++++++ scripts/apply-clang-format.sh | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 .clang-format create mode 100755 scripts/apply-clang-format.sh diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..a3cf6a1f --- /dev/null +++ b/.clang-format @@ -0,0 +1,7 @@ +--- +BasedOnStyle: Google +IndentWidth: 2 +--- +Language: Cpp +ColumnWidth: 100 +--- diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh new file mode 100755 index 00000000..36f5ee92 --- /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 | xargs clang-format --style=file -i +find ./hal -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i +find ./tests -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i From 15dddd7fc407fa72d752c76c64279944986b2dc1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 1 Dec 2021 16:17:27 +0100 Subject: [PATCH 2/3] small README section for formatting --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 312bc077..5feda92c 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](doc/README-highlevel.md#top)
From e952a82b6565292d649260b1441383b1d484f706 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Dec 2021 13:14:57 +0100 Subject: [PATCH 3/3] small tweaks and fixes --- .clang-format | 2 +- scripts/apply-clang-format.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.clang-format b/.clang-format index a3cf6a1f..ec53b72b 100644 --- a/.clang-format +++ b/.clang-format @@ -3,5 +3,5 @@ BasedOnStyle: Google IndentWidth: 2 --- Language: Cpp -ColumnWidth: 100 +ColumnLimit: 100 --- diff --git a/scripts/apply-clang-format.sh b/scripts/apply-clang-format.sh index 36f5ee92..27202324 100755 --- a/scripts/apply-clang-format.sh +++ b/scripts/apply-clang-format.sh @@ -3,6 +3,6 @@ if [[ ! -f README.md ]]; then cd .. fi -find ./src -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i -find ./hal -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i -find ./tests -iname *.h -o -iname *.cpp | xargs clang-format --style=file -i +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