Cameron Martin | eaf5138 | 2023-03-29 09:56:01 +0100 | [diff] [blame] | 1 | """Bzlmod module extensions that are only used internally""" |
| 2 | |
| 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 4 | load("//bindgen:repositories.bzl", "rust_bindgen_dependencies") |
| 5 | load("//crate_universe:repositories.bzl", "crate_universe_dependencies") |
| 6 | load("//proto/prost:repositories.bzl", "rust_prost_dependencies") |
Matt | 5f06994 | 2024-04-04 02:38:38 +1100 | [diff] [blame] | 7 | load("//proto/protobuf:repositories.bzl", "rust_proto_protobuf_dependencies") |
Cameron Martin | eaf5138 | 2023-03-29 09:56:01 +0100 | [diff] [blame] | 8 | load("//rust/private:repository_utils.bzl", "TINYJSON_KWARGS") |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 9 | load("//test:deps.bzl", "rules_rust_test_deps") |
| 10 | load("//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies") |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 11 | load("//wasm_bindgen:repositories.bzl", "rust_wasm_bindgen_dependencies") |
Cameron Martin | eaf5138 | 2023-03-29 09:56:01 +0100 | [diff] [blame] | 12 | |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 13 | def _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 Martin | eaf5138 | 2023-03-29 09:56:01 +0100 | [diff] [blame] | 20 | http_archive(**TINYJSON_KWARGS) |
| 21 | |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 22 | direct_deps.extend(crate_universe_dependencies()) |
| 23 | direct_deps.extend(rust_prost_dependencies(bzlmod = True)) |
Matt | 5f06994 | 2024-04-04 02:38:38 +1100 | [diff] [blame] | 24 | direct_deps.extend(rust_proto_protobuf_dependencies(bzlmod = True)) |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 25 | direct_deps.extend(rust_bindgen_dependencies()) |
| 26 | direct_deps.extend(rust_analyzer_dependencies()) |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 27 | direct_deps.extend(rust_wasm_bindgen_dependencies()) |
| 28 | direct_deps.extend(rules_rust_test_deps()) |
| 29 | |
Matt | 44ffccb | 2023-12-13 00:52:58 +1100 | [diff] [blame] | 30 | # 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 Martin | 33fdddd | 2024-02-23 12:55:58 +0000 | [diff] [blame] | 38 | # 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. |
UebelAndre | a5f7464 | 2024-08-26 11:36:41 -0700 | [diff] [blame] | 40 | # TODO: https://github.com/bazelbuild/rules_rust/issues/1120 |
Cameron Martin | 33fdddd | 2024-02-23 12:55:58 +0000 | [diff] [blame] | 41 | i = module_extension( |
Cameron Martin | eaf5138 | 2023-03-29 09:56:01 +0100 | [diff] [blame] | 42 | doc = "Dependencies for rules_rust", |
| 43 | implementation = _internal_deps_impl, |
| 44 | ) |