blob: a8671995c98c5917c1b0672d878f846af9c4eb63 [file] [log] [blame]
Carlos Gomes Martinhoe7957bf2020-04-17 10:10:02 +02001#!/bin/sh
2
3# This script searches all source code files and formats them according to the .cmake-format style.
4
5cmakeFormat="cmake-format"
6
7if [ -z "$cmakeFormat" ]
8then
9 echo "$cmakeFormat is not installed. Cannot format cmake files..."
10 echo "run: pip3 install cmake-format"
11 exit 1
12fi
13
14SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
15PROJECT_PATH=$SCRIPTPATH/../
16PROJECT_PATH="$( cd "$PROJECT_PATH" >/dev/null 2>&1 ; pwd -P )"
17
18echo "$cmakeFormat was found, going to format your cmake scripts..." >&2
19echo "formatting from root folder: $PROJECT_PATH" >&2
20
21find "$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
34echo "done formatting with cmake-format"