2 # SPDX-License-Identifier: GPL-2.0-or-later
4 ## usage: clangtidy-helper [list of cpp files]
6 ## Without arguments, run for all source files.
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