Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the clang-tidy script #128

Merged
merged 2 commits into from
May 1, 2018
Merged

Conversation

springmeyer
Copy link
Contributor

This fixes a longstanding issue in the scripts/clang-tidy.sh script. Previously if the build failed it would leave behind an empty build/compile_commands.json. Then - when you went to run the tidy target again - the script logic would see that build/compile_commands.json existed and
would avoid running the build again, leading clang-tidy to spuriously report nothing.

This change improves the script to avoid the possibility that it 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.

/cc @AllieOop for final PR. This PR is a subset created via https://github.com/mapbox/node-cpp-skel/pull/118/files#diff-297d66ab0c294f76d1a7ab83006a7383

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.
@springmeyer
Copy link
Contributor Author

fe692a0 is based on some learning trying to debug hanging clang-tidy jobs in another repo. I think what was happening was:

  • without a command like tee the output from make was being pushed to a file
  • if make took a long time travis would not see any output in stdout
  • travis would kill the process since it seemed hung

So, using tee ensures that the normal build output is still streamed to travis logs, but also to a file (so that we can then generate the compile_commands.json when needed).

/cc @GretaCB

@sssoleileraaa
Copy link

sssoleileraaa commented May 1, 2018

Ah, I see. Thanks for the clear explanation of how tee solves the problem of travis seeing no output during a long make. And this also addresses the issue we discussed in the larger PR. Good find.

lgtm!

@springmeyer springmeyer merged commit 2883650 into master May 1, 2018
@springmeyer springmeyer deleted the robustify-clang-tidy-script branch May 1, 2018 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants