Przeglądaj źródła

Update check_deps roots (#5311)

- Add pkg rules to the search, specifically so that we can pull the full
release tar instead of the busybox binary.
- Shift the tree_sitter exclusion to the script, so that it's easier to
use the script.
- tcmalloc_if_linux_opt isn't really interesting (it's referenced by
.bazelrc).
- Misc tiny changes to the query, just to simplify it.
Jon Ross-Perkins 1 rok temu
rodzic
commit
838417e358

+ 2 - 4
bazel/check_deps/BUILD

@@ -13,10 +13,8 @@ load("@rules_python//python:defs.bzl", "py_test")
 filegroup(
     name = "non_test_cc_rules",
     data = [
-        "//toolchain/install:carbon-busybox",
-        # The tree sitter rules can't be queried; evaluation fails on
-        # @platforms.
-        # "//utils/tree_sitter",
+        "//toolchain/install:carbon_toolchain_tar_gz_rule",
+        "//toolchain/install:carbon_toolchain_tar_rule",
     ],
     tags = ["manual"],
 )

+ 12 - 4
bazel/check_deps/update_roots.py

@@ -21,6 +21,17 @@ from pathlib import Path
 os.chdir(Path(__file__).parents[2])
 
 print("Compute non-test C++ root targets...")
+query_arg = (
+    "let non_tests = attr("
+    "    testonly, 0, //..."
+    # Exclude tree_sitter because its @platforms dependency errors in
+    # query. Note if it ends up in releases, we might want to do more,
+    # but that should also be caught by check_deps.py.
+    "    except //utils/tree_sitter/..."
+    # Exclude tcmalloc as an optional external library.
+    "    except //bazel/malloc:tcmalloc_if_linux_opt"
+    ") in kind('(cc|pkg)_.* rule', deps($non_tests))"
+)
 non_test_cc_roots_query = subprocess.check_output(
     [
         "./scripts/run_bazel.py",
@@ -29,10 +40,7 @@ non_test_cc_roots_query = subprocess.check_output(
         "--noimplicit_deps",
         "--notool_deps",
         "--output=minrank",
-        (
-            'let non_tests = kind("cc.* rule", attr(testonly, 0, //...))'
-            ' in kind("cc.* rule", deps($non_tests))'
-        ),
+        query_arg,
     ],
     universal_newlines=True,
 )

+ 1 - 0
toolchain/diagnostics/BUILD

@@ -116,6 +116,7 @@ cc_test(
 
 cc_library(
     name = "null_diagnostics",
+    testonly = 1,
     hdrs = ["null_diagnostics.h"],
     deps = [
         ":diagnostic_emitter",