bazel-compile-commands-extractor icon indicating copy to clipboard operation
bazel-compile-commands-extractor copied to clipboard

Fix for header-only compile actions by Bazel

Open mikael-s-persson opened this issue 1 year ago • 11 comments

Fix for header-only compile actions by Bazel

This PR fixes, as far as I can tell, the issues related to #199 where Bazel adds header-only / syntax-only compilation actions that produce dummy output files (.processed). I believe this is part of Bazel open-sourcing more of its capabilities for preprocessing headers and handling pre-compiled modules.

The fix is based on #209 and makes the following changes:

  • Adds '.h', '.inl', '.hh', '.hpp', '.hxx' to the list of expected source files for C and C++.
  • Add '.processed' to the list of expected output file extensions for compiler actions.
  • Removes '-fsyntax-only' or '/Zs' from the compilation arguments when running the preprocessor-only compilation step to silence any warnings about unused compiler arguments.

This fix was tested in this repo: https://github.com/mikael-s-persson/evdevpp And also tested and used for a while in other private repos. This seems to produce clean, non-racy outputs. AFAICT, the resulting compile_commands.json file contains everything it should, including the headers.

Fixes #199

mikael-s-persson avatar Sep 18 '24 15:09 mikael-s-persson