Move more distfile dependencies to the new format.

1. Move more distfile dependencies to the new format.

The goal for this PR is to add all of the dependencies which are needed for building Bazel, but are not packaged with it. Essentially, the easy ones.
- Thus, this excludes the JDKs and some other Java tools because I don't know enough to reason about them yet.
- This also excludes dependencies which are explicitly used in WORKSPACE files for tests, like rules_proto. Those should each be done as standalone PRs because they impact the build structure.

2.  Change the format of the dependency list, so that we no longer presume everything in DIST_DEPS is in the //:additional_distfiles.  Now all the uses are called out explicitly in a "used_in" field. This allows us to eventually use the table for dependencies which are needed for our build and test, but do not have to be part of any distfiles, such as `bazel_website`.

Closes #12779.

PiperOrigin-RevId: 351097267
diff --git a/distdir_deps.bzl b/distdir_deps.bzl
index 05f9dca..44ffb76 100644
--- a/distdir_deps.bzl
+++ b/distdir_deps.bzl
@@ -19,6 +19,30 @@
     # Runtime language dependencies
     #
     ########################################
+    "platforms": {
+        "archive": "platforms-0.0.2.tar.gz",
+        "sha256": "48a2d8d343863989c232843e01afc8a986eb8738766bfd8611420a7db8f6f0c3",
+        "urls": [
+            "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.2/platforms-0.0.2.tar.gz",
+            "https://github.com/bazelbuild/platforms/releases/download/0.0.2/platforms-0.0.2.tar.gz",
+        ],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    "bazel_toolchains": {
+        "archive": "bazel-toolchains-3.1.0.tar.gz",
+        "sha256": "726b5423e1c7a3866a3a6d68e7123b4a955e9fcbe912a51e0f737e6dab1d0af2",
+        "strip_prefix": "bazel-toolchains-3.1.0",
+        "urls": [
+            "https://mirror.bazel.build/github.com/bazelbuild/bazel-toolchains/releases/download/3.1.0/bazel-toolchains-3.1.0.tar.gz",
+            "https://github.com/bazelbuild/bazel-toolchains/releases/download/3.1.0/bazel-toolchains-3.1.0.tar.gz",
+        ],
+        "used_in": [
+            "additional_distfiles",
+        ],
+    },
     # Keep in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/cc_configure.WORKSPACE.
     # Keep in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
     # Note: This is not in sync with src/test/java/com/google/devtools/build/lib/blackbox/framework/BlackBoxTestEnvironment.java.
@@ -31,7 +55,10 @@
             "https://mirror.bazel.build/github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
             "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
         ],
-        "need_in_test_WORKSPACE": True,
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
     },
     "rules_java": {
         "archive": "7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip",
@@ -45,14 +72,85 @@
             "additional_distfiles",
             "test_WORKSPACE_files",
         ],
-        "need_in_test_WORKSPACE": True,
     },
-
-    ########################################
+    #################################################
     #
-    # Build time dependencies
+    # Dependencies which are part of the Bazel binary
     #
-    ########################################
+    #################################################
+    "com_google_protobuf": {
+        "archive": "v3.13.0.tar.gz",
+        "sha256": "9b4ee22c250fe31b16f1a24d61467e40780a3fbb9b91c3b65be2a376ed913a1a",
+        "strip_prefix": "protobuf-3.13.0",
+        "urls": [
+            "https://mirror.bazel.build/github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz",
+            "https://github.com/protocolbuffers/protobuf/archive/v3.13.0.tar.gz",
+        ],
+        "patch_args": ["-p1"],
+        "patches": ["//third_party/protobuf:3.13.0.patch"],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    "com_github_grpc_grpc": {
+        "archive": "v1.32.0.tar.gz",
+        "sha256": "f880ebeb2ccf0e47721526c10dd97469200e40b5f101a0d9774eb69efa0bd07a",
+        "strip_prefix": "grpc-1.32.0",
+        "urls": [
+            "https://mirror.bazel.build/github.com/grpc/grpc/archive/v1.32.0.tar.gz",
+            "https://github.com/grpc/grpc/archive/v1.32.0.tar.gz",
+        ],
+        "patch_args": ["-p1"],
+        "patches": [
+            "//third_party/grpc:grpc_1.32.0.patch",
+        ],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    "c-ares": {
+        "archive": "e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz",
+        "sha256": "e8c2751ddc70fed9dc6f999acd92e232d5846f009ee1674f8aee81f19b2b915a",
+        "urls": [
+            "https://mirror.bazel.build/github.com/c-ares/c-ares/archive/e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz",
+            "https://github.com/c-ares/c-ares/archive/e982924acee7f7313b4baa4ee5ec000c5e373c30.tar.gz",
+        ],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    "re2": {
+        "archive": "aecba11114cf1fac5497aeb844b6966106de3eb6.tar.gz",
+        "sha256": "9f385e146410a8150b6f4cb1a57eab7ec806ced48d427554b1e754877ff26c3e",
+        "urls": [
+            "https://mirror.bazel.build/github.com/google/re2/archive/aecba11114cf1fac5497aeb844b6966106de3eb6.tar.gz",
+            "https://github.com/google/re2/archive/aecba11114cf1fac5497aeb844b6966106de3eb6.tar.gz",
+        ],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    "abseil-cpp": {
+        "archive": "df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
+        "sha256": "f368a8476f4e2e0eccf8a7318b98dafbe30b2600f4e3cf52636e5eb145aba06a",
+        "urls": [
+            "https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
+            "https://github.com/abseil/abseil-cpp/archive/df3ea785d8c30a9503321a3d35ee7d35808f190d.tar.gz",
+        ],
+        "used_in": [
+            "additional_distfiles",
+            "test_WORKSPACE_files",
+        ],
+    },
+    ###################################################
+    #
+    # Build time dependencies for testing and packaging
+    #
+    ###################################################
     "rules_pkg": {
         "archive": "rules_pkg-0.2.4.tar.gz",
         "sha256": "4ba8f4ab0ff85f2484287ab06c0d871dcb31cc54d439457d28fd4ae14b18450a",
@@ -60,6 +158,9 @@
             "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
             "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
         ],
+        "used_in": [
+            "additional_distfiles",
+        ],
     },
     # for Stardoc
     "io_bazel_rules_sass": {
@@ -70,6 +171,9 @@
             "https://mirror.bazel.build/github.com/bazelbuild/rules_sass/archive/1.25.0.zip",
             "https://github.com/bazelbuild/rules_sass/archive/1.25.0.zip",
         ],
+        "used_in": [
+            "additional_distfiles",
+        ],
     },
     # for Stardoc
     "build_bazel_rules_nodejs": {
@@ -79,6 +183,9 @@
             "https://mirror.bazel.build/github.com/bazelbuild/rules_nodejs/releases/download/2.2.2/rules_nodejs-2.2.2.tar.gz",
             "https://github.com/bazelbuild/rules_nodejs/releases/download/2.2.2/rules_nodejs-2.2.2.tar.gz",
         ],
+        "used_in": [
+            "additional_distfiles",
+        ],
     },
 }
 
@@ -142,7 +249,7 @@
 
 gen_workspace_stanza = rule(
     implementation = _gen_workspace_stanza_impl,
-    doc = "Use specifications from DIST_DEPS to generate WORKSPACE http_archive stanzas or to fill" +
+    doc = "Use specifications from DIST_DEPS to generate WORKSPACE http_archive stanzas or to" +
           "drop them into a template.",
     attrs = {
         "repos": attr.string_list(doc = "Set of repos to inlcude"),