Jelajahi Sumber

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 <jperkins@google.com>
Chandler Carruth 7 bulan lalu
induk
melakukan
3ec0bcb4fd
1 mengubah file dengan 14 tambahan dan 3 penghapusan
  1. 14 3
      scripts/create_compdb.py

+ 14 - 3
scripts/create_compdb.py

@@ -39,8 +39,8 @@ def _build_generated_files(
     # files but aren't classified as "generated file".
     kinds_query = (
         "filter("
-        ' ".*\\.(h|cpp|cc|c|cxx|def|inc)$",'
-        ' kind("(generated file|generate_llvm_tools_def|manifest_as_cpp)",'
+        ' ".*\\.(h|hpp|hxx|cpp|cc|c|cxx|def|inc|s|S)$",'
+        ' kind("(.*generate.*|manifest_as_cpp)",'
         # tree_sitter is excluded here because it causes the query to failure on
         # `@platforms`.
         "      deps(//... except //utils/tree_sitter/...))"
@@ -66,6 +66,9 @@ def _build_generated_files(
     subprocess.check_call(
         [bazel, "build", "--keep_going", "--remote_download_outputs=toplevel"]
         + generated_file_labels
+        # We also need the Bazel C++ runfiles that aren't "generated", but are
+        # not linked into place until built.
+        + ["@bazel_tools//tools/cpp/runfiles:runfiles"]
     )
 
 
@@ -95,7 +98,15 @@ def main() -> None:
         "Generating compile_commands.json (may take a few minutes)...",
         flush=True,
     )
-    subprocess.run([bazel, "run", "@hedron_compile_commands//:refresh_all"])
+    subprocess.run(
+        [
+            bazel,
+            "run",
+            "@hedron_compile_commands//:refresh_all",
+            "--",
+            "--notool_deps",
+        ]
+    )
 
 
 if __name__ == "__main__":