fork/rules_rust

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

UebelAndreAdded bzlmod support to core rules_rust (#3034)69ddb09d

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