Skip to content

Commit 3ec0bcb

Browse files
chandlercjonmeow
andauthored
Improve building of generated sources for ClangD (#6046)
We have grown more generation rules, so try to use a regex instead of listing all of them. Also, manually add the runfiles C++ library that isn't "generated", but is symlinked into the source tree only when built. --------- Co-authored-by: Jon Ross-Perkins <[email protected]>
1 parent 12ddfb9 commit 3ec0bcb

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

scripts/create_compdb.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def _build_generated_files(
3939
# files but aren't classified as "generated file".
4040
kinds_query = (
4141
"filter("
42-
' ".*\\.(h|cpp|cc|c|cxx|def|inc)$",'
43-
' kind("(generated file|generate_llvm_tools_def|manifest_as_cpp)",'
42+
' ".*\\.(h|hpp|hxx|cpp|cc|c|cxx|def|inc|s|S)$",'
43+
' kind("(.*generate.*|manifest_as_cpp)",'
4444
# tree_sitter is excluded here because it causes the query to failure on
4545
# `@platforms`.
4646
" deps(//... except //utils/tree_sitter/...))"
@@ -66,6 +66,9 @@ def _build_generated_files(
6666
subprocess.check_call(
6767
[bazel, "build", "--keep_going", "--remote_download_outputs=toplevel"]
6868
+ generated_file_labels
69+
# We also need the Bazel C++ runfiles that aren't "generated", but are
70+
# not linked into place until built.
71+
+ ["@bazel_tools//tools/cpp/runfiles:runfiles"]
6972
)
7073

7174

@@ -95,7 +98,15 @@ def main() -> None:
9598
"Generating compile_commands.json (may take a few minutes)...",
9699
flush=True,
97100
)
98-
subprocess.run([bazel, "run", "@hedron_compile_commands//:refresh_all"])
101+
subprocess.run(
102+
[
103+
bazel,
104+
"run",
105+
"@hedron_compile_commands//:refresh_all",
106+
"--",
107+
"--notool_deps",
108+
]
109+
)
99110

100111

101112
if __name__ == "__main__":

0 commit comments

Comments
 (0)