fork/rules_rust

git clone https://git.julia.blue/fork/rules_rust

UebelAndreMoved rust extension rules into a separate `rules_rust_ext` workspace. (#3007)2bad96d9

cleanup
1.5 KiB34 linesraw
1"""Bzlmod module extensions that are only used internally"""
2
3load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4load("//crate_universe:repositories.bzl", "crate_universe_dependencies")
5load("//rust/private:repository_utils.bzl", "TINYJSON_KWARGS")
6load("//tools/rust_analyzer:deps.bzl", "rust_analyzer_dependencies")
7
8def _internal_deps_impl(module_ctx):
9    # This should contain the subset of WORKSPACE.bazel that defines
10    # repositories.
11
12    # We don't want rules_rust_dependencies, as they contain things like
13    # rules_cc, which is already declared in MODULE.bazel.
14    direct_deps = [struct(repo = "rules_rust_tinyjson", is_dev_dep = False)]
15    http_archive(**TINYJSON_KWARGS)
16
17    direct_deps.extend(crate_universe_dependencies())
18    direct_deps.extend(rust_analyzer_dependencies())
19
20    # is_dev_dep is ignored here. It's not relevant for internal_deps, as dev
21    # dependencies are only relevant for module extensions that can be used
22    # by other MODULES.
23    return module_ctx.extension_metadata(
24        root_module_direct_deps = [repo.repo for repo in direct_deps],
25        root_module_direct_dev_deps = [],
26    )
27
28# This is named a single character to reduce the size of path names when running build scripts, to reduce the chance
29# of hitting the 260 character windows path name limit.
30# TODO: https://github.com/bazelbuild/rules_rust/issues/1120
31i = module_extension(
32    doc = "Dependencies for rules_rust",
33    implementation = _internal_deps_impl,
34)