Skip to content

Commit a0eada1

Browse files
committed
Improve source extraction heuristic notes
1 parent 90255e0 commit a0eada1

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

refresh.template.py

+1
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,7 @@ def _get_files(compile_action):
562562
# However, parsing the command line this way is our best simple option. The other alternatives seem worse:
563563
# You can't just filter the args to those that end with source-file extensions. The problem is that sometimes header search directories have source-file extensions. Horrible, but unfortunately true. See https://github.com/hedronvision/bazel-compile-commands-extractor/pull/37 for context and history.
564564
# Parsing the clang invocation properly to get the positional file arguments is hard and not future-proof if new flags are added. Consider a new flag -foo. Does it also capture the next argument after it?
565+
# Similarly, you can't just further filter the args to those that don't begin with - and aren't directories...because they can be generated directories. Indeed the example from the PR (above) is.
565566
# You might be tempted to crawl the inputs depset in the aquery output structure, but it's a fair amount of recursive code and there are other erroneous source files there, at least when building for Android in Bazel 5.1. You could fix this by intersecting the set of source files in the inputs with those listed as arguments on the command line, but I can imagine perverse, problematic cases here. It's a lot more code to still have those caveats.
566567
# You might be tempted to get the source files out of the action message listed (just) in aquery --output=text output, but the message differs for external workspaces and tools. Plus paths with spaces are going to be hard because it's space delimited. You'd have to make even stronger assumptions than the -c.
567568
# Concretely, the message usually has the form "action 'Compiling foo.cpp'"" -> foo.cpp. But it also has "action 'Compiling src/tools/launcher/dummy.cc [for tool]'" -> external/bazel_tools/src/tools/launcher/dummy.cc

0 commit comments

Comments
 (0)