diff --git a/MODULE.bazel b/MODULE.bazel index 29c537158e..8290c27bda 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -126,7 +126,6 @@ use_repo( "cargo_bazel.buildifier-linux-arm64", "cargo_bazel.buildifier-linux-s390x", "cargo_bazel.buildifier-windows-amd64.exe", - "cargo_bazel_bootstrap", "cui", "cui__anyhow-1.0.89", "cui__camino-1.1.9", @@ -162,6 +161,15 @@ use_repo( "cui__walkdir-2.5.0", ) +crate_universe_internal_non_repro_deps = use_extension( + "//crate_universe/private:internal_extensions.bzl", + "cu_nr", +) +use_repo( + crate_universe_internal_non_repro_deps, + "cargo_bazel_bootstrap", +) + crate_universe_internal_dev_deps = use_extension( "//crate_universe/private:internal_extensions.bzl", "cu_dev", diff --git a/crate_universe/private/internal_extensions.bzl b/crate_universe/private/internal_extensions.bzl index 1b8aa53e08..98a8f26ef9 100644 --- a/crate_universe/private/internal_extensions.bzl +++ b/crate_universe/private/internal_extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions that are only used internally""" +load("@bazel_features//:features.bzl", "bazel_features") load("//crate_universe:deps_bootstrap.bzl", "cargo_bazel_bootstrap") load("//crate_universe:repositories.bzl", "crate_universe_dependencies") load("//crate_universe/tools/cross_installer:cross_installer_deps.bzl", "cross_installer_deps") @@ -8,6 +9,31 @@ def _internal_deps_impl(module_ctx): direct_deps = [] direct_deps.extend(crate_universe_dependencies()) + + # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev + # dependencies are only relevant for module extensions that can be used + # by other MODULES. + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) + +# This is named a single character to reduce the size of path names when running build scripts, to reduce the chance +# of hitting the 260 character windows path name limit. +# TODO: https://github.com/bazelbuild/rules_rust/issues/1120 +cu = module_extension( + doc = "Dependencies for crate_universe.", + implementation = _internal_deps_impl, +) + +def _internal_non_reproducible_deps_impl(module_ctx): + direct_deps = [] + direct_deps.extend(cargo_bazel_bootstrap( rust_toolchain_cargo_template = "@rust_host_tools//:bin/{tool}", rust_toolchain_rustc_template = "@rust_host_tools//:bin/{tool}", @@ -25,9 +51,9 @@ def _internal_deps_impl(module_ctx): # This is named a single character to reduce the size of path names when running build scripts, to reduce the chance # of hitting the 260 character windows path name limit. # TODO: https://github.com/bazelbuild/rules_rust/issues/1120 -cu = module_extension( - doc = "Dependencies for crate_universe.", - implementation = _internal_deps_impl, +cu_nr = module_extension( + doc = "Dependencies for crate_universe (non reproducible).", + implementation = _internal_non_reproducible_deps_impl, ) def _internal_dev_deps_impl(module_ctx): diff --git a/extensions/bindgen/MODULE.bazel b/extensions/bindgen/MODULE.bazel index d39dbf37e8..79d401f0c1 100644 --- a/extensions/bindgen/MODULE.bazel +++ b/extensions/bindgen/MODULE.bazel @@ -9,6 +9,10 @@ bazel_dep( name = "rules_rust", version = "0.56.0", ) +bazel_dep( + name = "bazel_features", + version = "1.21.0", +) bazel_dep( name = "bazel_skylib", version = "1.7.1", @@ -30,6 +34,7 @@ rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( rust_ext, "rules_rust_bindgen__bindgen-cli-0.70.1", + "rules_rust_bindgen_deps", "rules_rust_bindgen_deps__bindgen-0.70.1", "rules_rust_bindgen_deps__clang-sys-1.8.1", "rules_rust_bindgen_deps__clap-4.5.17", diff --git a/extensions/bindgen/extensions.bzl b/extensions/bindgen/extensions.bzl index 48d12a32e4..f5b6bb73e6 100644 --- a/extensions/bindgen/extensions.bzl +++ b/extensions/bindgen/extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions""" +load("@bazel_features//:features.bzl", "bazel_features") load("//:repositories.bzl", "rust_bindgen_dependencies") def _rust_ext_impl(module_ctx): @@ -12,10 +13,15 @@ def _rust_ext_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) rust_ext = module_extension( doc = "Dependencies for the rules_rust_bindgen extension.", diff --git a/extensions/bindgen/repositories.bzl b/extensions/bindgen/repositories.bzl index 8e7d8ddc29..4c9ced05bc 100644 --- a/extensions/bindgen/repositories.bzl +++ b/extensions/bindgen/repositories.bzl @@ -16,7 +16,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("//3rdparty/crates:defs.bzl", "crate_repositories") +load("//3rdparty/crates:crates.bzl", "crate_repositories") BINDGEN_VERSION = "0.70.1" diff --git a/extensions/mdbook/MODULE.bazel b/extensions/mdbook/MODULE.bazel index 25fa27cab9..56002184c9 100644 --- a/extensions/mdbook/MODULE.bazel +++ b/extensions/mdbook/MODULE.bazel @@ -13,6 +13,10 @@ bazel_dep( name = "rules_cc", version = "0.0.17", ) +bazel_dep( + name = "bazel_features", + version = "1.21.0", +) bazel_dep( name = "bazel_skylib", version = "1.7.1", diff --git a/extensions/mdbook/extensions.bzl b/extensions/mdbook/extensions.bzl index a50123644c..40d1024116 100644 --- a/extensions/mdbook/extensions.bzl +++ b/extensions/mdbook/extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions""" +load("@bazel_features//:features.bzl", "bazel_features") load("//:repositories.bzl", "mdbook_register_toolchains") load("//private/3rdparty/crates:crates.bzl", "crate_repositories") @@ -14,10 +15,15 @@ def _rust_ext_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) rust_ext = module_extension( doc = "Dependencies for the rules_rust mdbook extension.", diff --git a/extensions/prost/MODULE.bazel b/extensions/prost/MODULE.bazel index 8f2746a4f9..d8f9cab462 100644 --- a/extensions/prost/MODULE.bazel +++ b/extensions/prost/MODULE.bazel @@ -13,6 +13,10 @@ bazel_dep( name = "platforms", version = "0.0.10", ) +bazel_dep( + name = "bazel_features", + version = "1.21.0", +) bazel_dep( name = "bazel_skylib", version = "1.7.1", diff --git a/extensions/prost/extensions.bzl b/extensions/prost/extensions.bzl index f3b956933c..84832edffb 100644 --- a/extensions/prost/extensions.bzl +++ b/extensions/prost/extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions""" +load("@bazel_features//:features.bzl", "bazel_features") load("//:repositories.bzl", "rust_prost_dependencies") def _rust_ext_impl(module_ctx): @@ -12,10 +13,15 @@ def _rust_ext_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) rust_ext = module_extension( doc = "Dependencies for the rules_rust prost extension.", diff --git a/extensions/protobuf/MODULE.bazel b/extensions/protobuf/MODULE.bazel index 7442229339..b64cf8daa3 100644 --- a/extensions/protobuf/MODULE.bazel +++ b/extensions/protobuf/MODULE.bazel @@ -9,6 +9,10 @@ bazel_dep( name = "rules_rust", version = "0.56.0", ) +bazel_dep( + name = "bazel_features", + version = "1.21.0", +) bazel_dep( name = "bazel_skylib", version = "1.7.1", @@ -40,6 +44,7 @@ bazel_dep( rust_ext = use_extension("//:extensions.bzl", "rust_ext") use_repo( rust_ext, + "rules_rust_protobuf_deps", "rules_rust_protobuf_deps__grpc-0.6.2", "rules_rust_protobuf_deps__grpc-compiler-0.6.2", "rules_rust_protobuf_deps__log-0.4.17", diff --git a/extensions/protobuf/extensions.bzl b/extensions/protobuf/extensions.bzl index 9a6df1c598..c135c5dc64 100644 --- a/extensions/protobuf/extensions.bzl +++ b/extensions/protobuf/extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions""" +load("@bazel_features//:features.bzl", "bazel_features") load("//:repositories.bzl", "rust_proto_protobuf_dependencies") def _rust_ext_impl(module_ctx): @@ -12,10 +13,15 @@ def _rust_ext_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) rust_ext = module_extension( doc = "Dependencies for the rules_rust protobuf extension.", diff --git a/extensions/protobuf/repositories.bzl b/extensions/protobuf/repositories.bzl index 6b7dfb80f9..6bdb247cf1 100644 --- a/extensions/protobuf/repositories.bzl +++ b/extensions/protobuf/repositories.bzl @@ -16,7 +16,7 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") -load("//3rdparty/crates:defs.bzl", "crate_repositories") +load("//3rdparty/crates:crates.bzl", "crate_repositories") def rust_proto_protobuf_dependencies(bzlmod = False): """Sets up dependencies for rules_rust's proto support. diff --git a/extensions/wasm_bindgen/MODULE.bazel b/extensions/wasm_bindgen/MODULE.bazel index 4d442373dd..5c0c4d2ddc 100644 --- a/extensions/wasm_bindgen/MODULE.bazel +++ b/extensions/wasm_bindgen/MODULE.bazel @@ -9,6 +9,10 @@ bazel_dep( name = "rules_rust", version = "0.56.0", ) +bazel_dep( + name = "bazel_features", + version = "1.21.0", +) bazel_dep( name = "bazel_skylib", version = "1.7.1", diff --git a/extensions/wasm_bindgen/extensions.bzl b/extensions/wasm_bindgen/extensions.bzl index bb7dd76865..1fd9ecb7ac 100644 --- a/extensions/wasm_bindgen/extensions.bzl +++ b/extensions/wasm_bindgen/extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions""" +load("@bazel_features//:features.bzl", "bazel_features") load("//:repositories.bzl", "rust_wasm_bindgen_dependencies") def _rust_ext_impl(module_ctx): @@ -12,10 +13,15 @@ def _rust_ext_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) rust_ext = module_extension( doc = "Dependencies for the rules_rust wasm_bindgen extension.", diff --git a/rust/private/internal_extensions.bzl b/rust/private/internal_extensions.bzl index 53ec3d646a..3691204017 100644 --- a/rust/private/internal_extensions.bzl +++ b/rust/private/internal_extensions.bzl @@ -1,5 +1,6 @@ """Bzlmod module extensions that are only used internally""" +load("@bazel_features//:features.bzl", "bazel_features") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("//rust/private:repository_utils.bzl", "TINYJSON_KWARGS") load("//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies") @@ -18,10 +19,15 @@ def _internal_deps_impl(module_ctx): # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev # dependencies are only relevant for module extensions that can be used # by other MODULES. - return module_ctx.extension_metadata( - root_module_direct_deps = [repo.repo for repo in direct_deps], - root_module_direct_dev_deps = [], - ) + metadata_kwargs = { + "root_module_direct_deps": [repo.repo for repo in direct_deps], + "root_module_direct_dev_deps": [], + } + + if bazel_features.external_deps.extension_metadata_has_reproducible: + metadata_kwargs["reproducible"] = True + + return module_ctx.extension_metadata(**metadata_kwargs) # This is named a single character to reduce the size of path names when running build scripts, to reduce the chance # of hitting the 260 character windows path name limit.