Skip to content
Snippets Groups Projects
Commit 3f568c6d authored by Administrator's avatar Administrator
Browse files

Add script to run clang-tidy on a source directory

The script allows to run clang-tidy on the complete project by passing the path
to the CbmRoot source directory or only a subdirectory by passing the path to
the subdirectory.
Some of the compilation units should not be tested by clang-tidy.
Exclude checking the dictionaries G__*.cxx since they generated by root-cling.
Exclude all targets from the external directory. This isn't our code and must
not be checked by us.
parent e9c5b3da
No related branches found
No related tags found
1 merge request!1333Add the possibility to use clang-tidy with CbmRoot
Pipeline #24215 passed
#!/bin/bash
# Copyright (C) 2023 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
# SPDX-License-Identifier: GPL-3.0-only
# First commited by Florian Uhlig
# Extract files with an existing compilation unit from the compile command database
# which are in the passed directory or in case only one file is passed check if the
# file is in the compilation database
# For all found files run clang-tidy to fix the problems found. Exclude files from
# the external directory and root-cling generated dictionaries.
source_directory=$1
build_directory=$2
CLANG_TIDY_BIN=${FAIRROOT_CLANG_TIDY_BIN:-clang-tidy}
FILES=$(grep '"file"' $build_directory/compile_commands.json | grep "$source_directory" | cut -d: -f2 | cut -d\" -f2)
for file in $FILES; do
if [[ $file =~ "/external/" ]]; then
continue
fi
if [[ $file =~ "G__" ]]; then
continue
fi
echo "Run clang-tidy on $file"
$CLANG_TIDY_BIN --fix -p $build_directory $file
done;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment