-
-
Notifications
You must be signed in to change notification settings - Fork 268
/
tidy.sh
executable file
·46 lines (38 loc) · 1.14 KB
/
tidy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# SPDX-License-Identifier: BSD-2-Clause
# SPDX-FileCopyrightText: Nicolas Carion <[email protected]>
if [ -f compile_commands.json ]; then
echo "Using the existing compilation db"
else
echo "Generating the compile db"
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .
fi
echo "Retrieving the list of files to process..."
git ls-files > file_list
touch to_process
touch headers
echo "Cleaning the list of files to process..."
for file in `cat file_list`;
do
if grep -Fq "${file}" compile_commands.json
then
echo $file >> to_process
fi
if echo $file | grep -q "\.[ih][p]*$"
then
echo $file >> headers
fi
done;
echo "Formatting source files"
parallel -j 8 clang-format -i -style=file {} :::: to_process
echo "Formatting header files"
parallel -j 8 clang-format -i -style=file {} :::: headers
echo "Linting"
parallel -j 8 clang-tidy -fix -config="" {} :::: to_process
echo "Reformatting source files"
parallel -j 8 clang-format -i -style=file {} :::: to_process
echo "Reformatting header files"
parallel -j 8 clang-format -i -style=file {} :::: headers
rm file_list
rm to_process
rm headers