Mitigate hazardous boost::adaptors::reversed
[inkscape.git] / buildtools / clangtidy-helper.sh
blob3782465d5a1cbc43aeba4545aa020d762df805f6
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-later
3 ##
4 ## usage: clangtidy-helper [list of cpp files]
5 ##
6 ## Without arguments, run for all source files.
7 ##
9 set -e
11 mkdir -p build
12 cd build
14 export CC="ccache clang"
15 export CXX="ccache clang++"
17 cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
19 #remove 3rdparty files from analysis, and only do those in inkscape_base target
20 jq -c '.[] | select( .file | contains("3rdparty") | not) | select(.command | contains("CMakeFiles/inkscape_base")) ' compile_commands.json | jq -s > compile_commands2.json
21 #treat 3rdparty code as system headers
22 sed -e 's/-I\([^ ]*\)\/src\/3rdparty/-isystem \1\/src\/3rdparty/g' compile_commands2.json > compile_commands.json && rm compile_commands2.json
24 run-clang-tidy -fix "$@" > /dev/null || true
26 # revert all fixes in protected directories
27 git checkout --recurse-submodules ../src/3rdparty
29 git diff | tee clang_tidy_diff
31 if [[ -s clang_tidy_diff ]]; then
32 exit 1