Skip to content

Commit 2be2db9

Browse files
author
Dane Springmeyer
committed
Improve the clang-tidy script
This fixes a problem in the script. Previously if the build failed it would leave behind an empty build/compile_commands.json. Then the script logic would see that and avoid running the build again, leading clang-tidy to spuriously report nothing. This change improves the script to avoid the possibility that is will write an empty `build/compile_commands.json` Context: The `scripts/generate_compile_commands.py` is needed to reformat the build out into this specific format (https://clang.llvm.org/docs/JSONCompilationDatabase.html). Some build systems can do this automatically (like cmake https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html) but here we use gyp, which cannot. So the `scripts/generate_compile_commands.py` is my attempt to bolt this functionality onto gyp.
1 parent 770f594 commit 2be2db9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

scripts/clang-tidy.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ if [[ ! -f build/compile_commands.json ]]; then
3030
mkdir -p build
3131
# Run make, pipe the output to the generate_compile_commands.py
3232
# and drop them in a place that clang-tidy will automatically find them
33-
make | scripts/generate_compile_commands.py > build/compile_commands.json
33+
RESULT=0
34+
make > /tmp/make-node-cpp-skel-build-output.txt || RESULT=$?
35+
if [[ ${RESULT} != 0 ]]; then
36+
echo "Build failed, could not generate compile commands for clang-tidy, aborting!"
37+
exit ${RESULT}
38+
else
39+
cat /tmp/make-node-cpp-skel-build-output.txt | scripts/generate_compile_commands.py > build/compile_commands.json
40+
fi
41+
3442
fi
3543

3644
# change into the build directory so that clang-tidy can find the files

0 commit comments

Comments
 (0)