Carlos Gomes Martinho | e7957bf | 2020-04-17 10:10:02 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # This script searches all source code files and formats them according to the .cmake-format style. |
| 4 | |
| 5 | cmakeFormat="cmake-format" |
| 6 | |
| 7 | if [ -z "$cmakeFormat" ] |
| 8 | then |
| 9 | echo "$cmakeFormat is not installed. Cannot format cmake files..." |
| 10 | echo "run: pip3 install cmake-format" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" |
| 15 | PROJECT_PATH=$SCRIPTPATH/../ |
| 16 | PROJECT_PATH="$( cd "$PROJECT_PATH" >/dev/null 2>&1 ; pwd -P )" |
| 17 | |
| 18 | echo "$cmakeFormat was found, going to format your cmake scripts..." >&2 |
| 19 | echo "formatting from root folder: $PROJECT_PATH" >&2 |
| 20 | |
| 21 | find "$PROJECT_PATH" \ |
| 22 | -not \( -path "*/build/*" -prune \) \ |
| 23 | -not \( -path "*/scripts/*" -prune \) \ |
| 24 | -not \( -path "*/.vscode/*" -prune \) \ |
| 25 | -not \( -path '*/cmake/LCov.cmake' -prune \) \ |
| 26 | -not \( -path '*/cmake/Coveralls.cmake' -prune \) \ |
| 27 | -not \( -path '*/cmake/CoverallsGenerateGcov.cmake' -prune \) \ |
| 28 | -not \( -path '*/cmake/CoverallsClear.cmake' -prune \) \ |
| 29 | -not \( -path '*/cmake/FindMbedTLS.cmake' -prune \) \ |
| 30 | \( -name *.cmake -o -name CMakeLists.txt ! -iname "*Find*" \) \ |
| 31 | | xargs $cmakeFormat -c cmake-format.yaml -i |
| 32 | |
| 33 | |
| 34 | echo "done formatting with cmake-format" |