lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright lowRISC contributors. |
| 3 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 4 | # SPDX-License-Identifier: Apache-2.0 |
| 5 | |
| 6 | find sw hw \ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 7 | \( -name '*.cpp' \ |
| 8 | -o -name '*.cc' \ |
| 9 | -o -name '*.c' \ |
| 10 | -o -name '*.h' \) \ |
| 11 | -exec clang-format -i {} \; |
| 12 | |
| 13 | # Report on missing curly braces for loops and control statements. |
| 14 | # clang-format cannot fix them for us, so this requires manual work. |
| 15 | braces_missing=$( |
| 16 | find sw hw \ |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 17 | \( -name '*.cpp' \ |
| 18 | -o -name '*.cc' \ |
| 19 | -o -name '*.c' \ |
| 20 | -o -name '*.h' \) \ |
| 21 | -exec grep -Hn -P '(^|\s)((if|while|for) \(.+\)|else\s*)$' {} \; |
| 22 | ) |
| 23 | if [ ! -z "$braces_missing" ]; then |
| 24 | echo ERROR: Curly braces are missing from the following control or loop |
| 25 | echo statements. Please add them manually and re-run this script. |
| 26 | echo |
| 27 | echo "$braces_missing" |
| 28 | exit 1 |
| 29 | fi |