diff --git a/examples/all_deps_vendor/MODULE.bazel b/examples/all_deps_vendor/MODULE.bazel index 0a11e0a2c7..15df9af3ae 100644 --- a/examples/all_deps_vendor/MODULE.bazel +++ b/examples/all_deps_vendor/MODULE.bazel @@ -37,4 +37,10 @@ register_toolchains("@rust_toolchains//:all") ############################################################################### # R U S T C R A T E S ############################################################################### -use_extension("@rules_rust//crate_universe:extensions.bzl", "crate") + +deps = use_extension("//:extensions.bzl", "rust_example") +use_repo( + deps, + "basic", + "basic__bzip2-0.3.3", +) diff --git a/examples/all_deps_vendor/basic/3rdparty/BUILD.bazel b/examples/all_deps_vendor/basic/3rdparty/BUILD.bazel index 7ac4b7731c..ac779da9d5 100644 --- a/examples/all_deps_vendor/basic/3rdparty/BUILD.bazel +++ b/examples/all_deps_vendor/basic/3rdparty/BUILD.bazel @@ -7,7 +7,7 @@ crates_vendor( gen_build_script = True, )], }, - cargo_lockfile = "Cargo.Bazel.lock", + cargo_lockfile = "Cargo.lock", generate_build_scripts = False, mode = "remote", packages = { diff --git a/examples/all_deps_vendor/basic/3rdparty/Cargo.Bazel.lock b/examples/all_deps_vendor/basic/3rdparty/Cargo.lock similarity index 100% rename from examples/all_deps_vendor/basic/3rdparty/Cargo.Bazel.lock rename to examples/all_deps_vendor/basic/3rdparty/Cargo.lock diff --git a/examples/all_deps_vendor/extensions.bzl b/examples/all_deps_vendor/extensions.bzl new file mode 100644 index 0000000000..80bf3e4581 --- /dev/null +++ b/examples/all_deps_vendor/extensions.bzl @@ -0,0 +1,23 @@ +"""Bzlmod module extensions""" + +load("//basic/3rdparty/crates:crates.bzl", basic_crate_repositories = "crate_repositories") + +def _rust_example_impl(module_ctx): + # This should contain the subset of WORKSPACE.bazel that defines + # repositories. + direct_deps = [] + + direct_deps.extend(basic_crate_repositories()) + + # 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 = [], + ) + +rust_example = module_extension( + doc = "Dependencies for the rules_rust examples.", + implementation = _rust_example_impl, +) diff --git a/examples/android/MODULE.bazel b/examples/android/MODULE.bazel index d9fb2d5b51..e168382fee 100644 --- a/examples/android/MODULE.bazel +++ b/examples/android/MODULE.bazel @@ -13,6 +13,10 @@ local_path_override( path = "../..", ) +bazel_dep( + name = "platforms", + version = "0.0.10", +) bazel_dep( name = "rules_cc", version = "0.0.17", diff --git a/examples/ffi/MODULE.bazel b/examples/ffi/MODULE.bazel index d870323ce7..92a8bdb5cb 100644 --- a/examples/ffi/MODULE.bazel +++ b/examples/ffi/MODULE.bazel @@ -17,6 +17,10 @@ bazel_dep( name = "platforms", version = "0.0.10", ) +bazel_dep( + name = "rules_cc", + version = "0.0.17", +) ############################################################################### # T O O L C H A I N S diff --git a/examples/hello_world/BUILD.bazel b/examples/hello_world/BUILD.bazel index fb4b7501cc..b0b7151c09 100644 --- a/examples/hello_world/BUILD.bazel +++ b/examples/hello_world/BUILD.bazel @@ -1,5 +1,6 @@ load("@bazel_skylib//rules:build_test.bzl", "build_test") load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc") +load("@rules_shell//shell:sh_test.bzl", "sh_test") package(default_visibility = ["//visibility:public"]) diff --git a/examples/hello_world/MODULE.bazel b/examples/hello_world/MODULE.bazel index 677363a3cb..942830fe38 100644 --- a/examples/hello_world/MODULE.bazel +++ b/examples/hello_world/MODULE.bazel @@ -22,6 +22,10 @@ bazel_dep( name = "bazel_skylib", version = "1.7.1", ) +bazel_dep( + name = "rules_shell", + version = "0.3.0", +) # To do third party dependencies, you have multiple options: diff --git a/examples/musl_cross_compiling/MODULE.bazel b/examples/musl_cross_compiling/MODULE.bazel index 4dfd688899..d798abafe6 100644 --- a/examples/musl_cross_compiling/MODULE.bazel +++ b/examples/musl_cross_compiling/MODULE.bazel @@ -20,6 +20,10 @@ bazel_dep( name = "rules_shell", version = "0.3.0", ) +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) RUST_EDITION = "2021" diff --git a/test/no_std/MODULE.bazel b/test/no_std/MODULE.bazel index 430e6f3755..d3f5e3552c 100644 --- a/test/no_std/MODULE.bazel +++ b/test/no_std/MODULE.bazel @@ -9,6 +9,11 @@ local_path_override( path = "../..", ) +bazel_dep( + name = "rules_cc", + version = "0.0.17", +) + rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") rust.toolchain( edition = "2021",