Mark the bzlmod extension reproducible as appropriate (#2575)
@matts1 @fmeum PTAL :)
diff --git a/MODULE.bazel b/MODULE.bazel
index 32c0b55..91e944a 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -6,6 +6,10 @@
)
bazel_dep(
+ name = "bazel_features",
+ version = "1.9.1",
+)
+bazel_dep(
name = "bazel_skylib",
version = "1.5.0",
)
diff --git a/crate_universe/extension.bzl b/crate_universe/extension.bzl
index bbad6ab..4ec0e8c 100644
--- a/crate_universe/extension.bzl
+++ b/crate_universe/extension.bzl
@@ -1,5 +1,6 @@
"""Module extension for generating third-party crates for use in bazel."""
+load("@bazel_features//:features.bzl", "bazel_features")
load("@bazel_skylib//lib:structs.bzl", "structs")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
@@ -279,6 +280,8 @@
cargo_bazel = get_cargo_bazel_runner(module_ctx, cargo_bazel_output)
all_repos = []
+ reproducible = True
+
for mod in module_ctx.modules:
module_annotations = {}
repo_specific_annotations = {}
@@ -331,6 +334,11 @@
_generate_hub_and_spokes(module_ctx, cargo_bazel, cfg, annotations, cargo_lockfile = cargo_lockfile, manifests = manifests)
for cfg in mod.tags.from_specs:
+ # We don't have a Cargo.lock so the resolution can change.
+ # We could maybe make this reproducible by using `-minimal-version` during resolution.
+ # See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#minimal-versions
+ reproducible = False
+
annotations = _annotations_for_repo(
module_annotations,
repo_specific_annotations.get(cfg.name),
@@ -343,6 +351,12 @@
if repo not in local_repos:
fail("Annotation specified for repo %s, but the module defined repositories %s" % (repo, local_repos))
+ metadata_kwargs = {}
+ if bazel_features.external_deps.extension_metadata_has_reproducible:
+ metadata_kwargs["reproducible"] = reproducible
+
+ return module_ctx.extension_metadata(**metadata_kwargs)
+
_from_cargo = tag_class(
doc = "Generates a repo @crates from a Cargo.toml / Cargo.lock pair",
attrs = dict(