8af4767a9622175edcbe44c6702d25e4dfec4cb9
[tinc] / .ci / tidy / run.sh
1 #!/bin/sh
2
3 set -eu
4
5 # Which paths to ignore.
6 paths='src/solaris src/mingw'
7
8 case "$(uname -s)" in
9 Linux)
10   paths="$paths src/bsd"
11   ;;
12
13 FreeBSD)
14   paths="$paths src/linux src/bsd/tunemu.c"
15   ;;
16
17 Darwin)
18   paths="$paths src/linux src/vde_device.c"
19   ;;
20
21 *) exit 1 ;;
22 esac
23
24 path_filters=''
25 for path in $paths; do
26   path_filters=" $path_filters ! ( -path $path -prune ) "
27 done
28
29 if ! [ -f compile_commands.json ]; then
30   # Running compiledb directly on this doesn't work on FreeBSD for some reason.
31   make -j2 all extra
32   compiledb -n make check
33 fi
34
35 echo >&2 "Running clang-tidy without $paths"
36
37 # This is fine, our paths are relative and do not contain any whitespace.
38 # shellcheck disable=SC2086
39 find src \
40   $path_filters \
41   -name '*.c' \
42   -exec clang-tidy --header-filter='.*' '{}' +