Add dist_http_archive() to make it easier to synchronize distdir with http_archive

More for #12081

For dependencies specified in distdir.bzl, we can now include them in Bazel's WORKSPACE with a simpler invocation that can not go out of sync.  For example, this

```
dist_http_archive(
  name = "io_bazel_rules_sass",
)
```
instead of
```
http_archive(
  name = "io_bazel_rules_sass",
  sha256 = "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647",
  strip_prefix = "rules_sass-1.25.0",
  urls = [
    "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",
  ],
)
```

Also, convert two more packages only used at Bazel build time to the new style.
Next steps:
- convert other repositories which are not needed at run time to this format
- add ability to generate WORKSPACE files used by tests from DISTDIR #12734
- convert rules libraries to this format

Closes #12722.

PiperOrigin-RevId: 350140996
diff --git a/distdir_deps.bzl b/distdir_deps.bzl
index c1a84f1..b0a4dc6 100644
--- a/distdir_deps.bzl
+++ b/distdir_deps.bzl
@@ -13,9 +13,41 @@
 # limitations under the License.
 """List the distribution dependencies we need to build Bazel."""
 
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
+def dist_http_archive(name, **kwargs):
+    """Wraps http_archive but takes sha and urls from DIST_DEPS.
+
+    dist_http_archive wraps an http_archive invocation, but looks up relevant
+    information from DIST_DEPS so the user does not have to specify it. It
+    always strips sha256 and urls from kwargs.
+
+    Args:
+      name: repo name
+      **kwargs: see http_archive for allowed args.
+    """
+    info = DIST_DEPS[name]
+    if "patches" not in kwargs:
+        kwargs["patches"] = info.get("patches")
+    if "strip_prefix" not in kwargs:
+        kwargs["strip_prefix"] = info.get("strip_prefix")
+    http_archive(
+        name = name,
+        sha256 = info["sha256"],
+        urls = info["urls"],
+        **kwargs
+    )
+
 DIST_DEPS = {
-    # This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/cpp/cc_configure.WORKSPACE.
-    # This must be kept in sync with src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.
+    ########################################
+    #
+    # Runtime language dependencies
+    #
+    ########################################
+    # 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.
+    #       Perhaps it should be.
     "rules_cc": {
         "archive": "b1c40e1de81913a3c40e5948f78719c28152486d.zip",
         "sha256": "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd",
@@ -26,6 +58,11 @@
         ],
         "need_in_test_WORKSPACE": True,
     },
+    ########################################
+    #
+    # Build time dependencies
+    #
+    ########################################
     "rules_pkg": {
         "archive": "rules_pkg-0.2.4.tar.gz",
         "sha256": "4ba8f4ab0ff85f2484287ab06c0d871dcb31cc54d439457d28fd4ae14b18450a",
@@ -34,4 +71,23 @@
             "https://github.com/bazelbuild/rules_pkg/releases/download/0.2.4/rules_pkg-0.2.4.tar.gz",
         ],
     },
+    # for Stardoc
+    "io_bazel_rules_sass": {
+        "archive": "1.25.0.zip",
+        "sha256": "c78be58f5e0a29a04686b628cf54faaee0094322ae0ac99da5a8a8afca59a647",
+        "strip_prefix": "rules_sass-1.25.0",
+        "urls": [
+            "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",
+        ],
+    },
+    # for Stardoc
+    "build_bazel_rules_nodejs": {
+        "archive": "rules_nodejs-2.2.2.tar.gz",
+        "sha256": "f2194102720e662dbf193546585d705e645314319554c6ce7e47d8b59f459e9c",
+        "urls": [
+            "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",
+        ],
+    },
 }