blob: 62d0b73a2390b07c5888f6b50db4d91bf2fc780f [file] [log] [blame]
Cameron Martineaf51382023-03-29 09:56:01 +01001"""Bzlmod module extensions that are only used internally"""
2
3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
Matt44ffccb2023-12-13 00:52:58 +11004load("//bindgen:repositories.bzl", "rust_bindgen_dependencies")
5load("//crate_universe:repositories.bzl", "crate_universe_dependencies")
6load("//proto/prost:repositories.bzl", "rust_prost_dependencies")
Matt5f069942024-04-04 02:38:38 +11007load("//proto/protobuf:repositories.bzl", "rust_proto_protobuf_dependencies")
Cameron Martineaf51382023-03-29 09:56:01 +01008load("//rust/private:repository_utils.bzl", "TINYJSON_KWARGS")
Matt44ffccb2023-12-13 00:52:58 +11009load("//test:deps.bzl", "rules_rust_test_deps")
10load("//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
Matt44ffccb2023-12-13 00:52:58 +110011load("//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies")
Cameron Martineaf51382023-03-29 09:56:01 +010012
Matt44ffccb2023-12-13 00:52:58 +110013def _internal_deps_impl(module_ctx):
14 # This should contain the subset of WORKSPACE.bazel that defines
15 # repositories.
16
17 # We don't want rules_rust_dependencies, as they contain things like
18 # rules_cc, which is already declared in MODULE.bazel.
19 direct_deps = [struct(repo = "rules_rust_tinyjson", is_dev_dep = False)]
Cameron Martineaf51382023-03-29 09:56:01 +010020 http_archive(**TINYJSON_KWARGS)
21
Matt44ffccb2023-12-13 00:52:58 +110022 direct_deps.extend(crate_universe_dependencies())
23 direct_deps.extend(rust_prost_dependencies(bzlmod = True))
Matt5f069942024-04-04 02:38:38 +110024 direct_deps.extend(rust_proto_protobuf_dependencies(bzlmod = True))
Matt44ffccb2023-12-13 00:52:58 +110025 direct_deps.extend(rust_bindgen_dependencies())
26 direct_deps.extend(rust_analyzer_dependencies())
Matt44ffccb2023-12-13 00:52:58 +110027 direct_deps.extend(rust_wasm_bindgen_dependencies())
28 direct_deps.extend(rules_rust_test_deps())
29
Matt44ffccb2023-12-13 00:52:58 +110030 # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev
31 # dependencies are only relevant for module extensions that can be used
32 # by other MODULES.
33 return module_ctx.extension_metadata(
34 root_module_direct_deps = [repo.repo for repo in direct_deps],
35 root_module_direct_dev_deps = [],
36 )
37
Cameron Martin33fdddd2024-02-23 12:55:58 +000038# This is named a single character to reduce the size of path names when running build scripts, to reduce the chance
39# of hitting the 260 character windows path name limit.
UebelAndrea5f74642024-08-26 11:36:41 -070040# TODO: https://github.com/bazelbuild/rules_rust/issues/1120
Cameron Martin33fdddd2024-02-23 12:55:58 +000041i = module_extension(
Cameron Martineaf51382023-03-29 09:56:01 +010042 doc = "Dependencies for rules_rust",
43 implementation = _internal_deps_impl,
44)