xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/deps.bzl (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan"""A module defining dependencies of the `rules_rust` tests"""
2*d4726bddSHONG Yifan
3*d4726bddSHONG Yifanload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4*d4726bddSHONG Yifanload("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5*d4726bddSHONG Yifanload("//test/generated_inputs:external_repo.bzl", "generated_inputs_in_external_repo")
6*d4726bddSHONG Yifanload("//test/load_arbitrary_tool:load_arbitrary_tool_test.bzl", "load_arbitrary_tool_test")
7*d4726bddSHONG Yifanload("//test/unit/toolchain:toolchain_test_utils.bzl", "rules_rust_toolchain_test_target_json_repository")
8*d4726bddSHONG Yifan
9*d4726bddSHONG Yifan_LIBC_BUILD_FILE_CONTENT = """\
10*d4726bddSHONG Yifanload("@rules_rust//rust:defs.bzl", "rust_library")
11*d4726bddSHONG Yifan
12*d4726bddSHONG Yifanrust_library(
13*d4726bddSHONG Yifan    name = "libc",
14*d4726bddSHONG Yifan    srcs = glob(["src/**/*.rs"]),
15*d4726bddSHONG Yifan    edition = "2015",
16*d4726bddSHONG Yifan    rustc_flags = [
17*d4726bddSHONG Yifan        # In most cases, warnings in 3rd party crates are not interesting as
18*d4726bddSHONG Yifan        # they're out of the control of consumers. The flag here silences
19*d4726bddSHONG Yifan        # warnings. For more details see:
20*d4726bddSHONG Yifan        # https://doc.rust-lang.org/rustc/lints/levels.html
21*d4726bddSHONG Yifan        "--cap-lints=allow",
22*d4726bddSHONG Yifan    ],
23*d4726bddSHONG Yifan    visibility = ["//visibility:public"],
24*d4726bddSHONG Yifan)
25*d4726bddSHONG Yifan"""
26*d4726bddSHONG Yifan
27*d4726bddSHONG Yifandef rules_rust_test_deps():
28*d4726bddSHONG Yifan    """Load dependencies for rules_rust tests
29*d4726bddSHONG Yifan
30*d4726bddSHONG Yifan    Returns:
31*d4726bddSHONG Yifan        list[struct(repo=str, is_dev_dep=bool)]: A list of the repositories
32*d4726bddSHONG Yifan        defined by this macro.
33*d4726bddSHONG Yifan    """
34*d4726bddSHONG Yifan
35*d4726bddSHONG Yifan    direct_deps = load_arbitrary_tool_test()
36*d4726bddSHONG Yifan    direct_deps.extend(generated_inputs_in_external_repo())
37*d4726bddSHONG Yifan
38*d4726bddSHONG Yifan    maybe(
39*d4726bddSHONG Yifan        http_archive,
40*d4726bddSHONG Yifan        name = "libc",
41*d4726bddSHONG Yifan        build_file_content = _LIBC_BUILD_FILE_CONTENT,
42*d4726bddSHONG Yifan        sha256 = "1ac4c2ac6ed5a8fb9020c166bc63316205f1dc78d4b964ad31f4f21eb73f0c6d",
43*d4726bddSHONG Yifan        strip_prefix = "libc-0.2.20",
44*d4726bddSHONG Yifan        urls = [
45*d4726bddSHONG Yifan            "https://mirror.bazel.build/github.com/rust-lang/libc/archive/0.2.20.zip",
46*d4726bddSHONG Yifan            "https://github.com/rust-lang/libc/archive/0.2.20.zip",
47*d4726bddSHONG Yifan        ],
48*d4726bddSHONG Yifan    )
49*d4726bddSHONG Yifan
50*d4726bddSHONG Yifan    maybe(
51*d4726bddSHONG Yifan        rules_rust_toolchain_test_target_json_repository,
52*d4726bddSHONG Yifan        name = "rules_rust_toolchain_test_target_json",
53*d4726bddSHONG Yifan        target_json = Label("//test/unit/toolchain:toolchain-test-triple.json"),
54*d4726bddSHONG Yifan    )
55*d4726bddSHONG Yifan
56*d4726bddSHONG Yifan    maybe(
57*d4726bddSHONG Yifan        http_archive,
58*d4726bddSHONG Yifan        name = "com_google_googleapis",
59*d4726bddSHONG Yifan        urls = [
60*d4726bddSHONG Yifan            "https://github.com/googleapis/googleapis/archive/18becb1d1426feb7399db144d7beeb3284f1ccb0.zip",
61*d4726bddSHONG Yifan        ],
62*d4726bddSHONG Yifan        strip_prefix = "googleapis-18becb1d1426feb7399db144d7beeb3284f1ccb0",
63*d4726bddSHONG Yifan        sha256 = "b8c487191eb942361af905e40172644eab490190e717c3d09bf83e87f3994fff",
64*d4726bddSHONG Yifan    )
65*d4726bddSHONG Yifan
66*d4726bddSHONG Yifan    maybe(
67*d4726bddSHONG Yifan        http_archive,
68*d4726bddSHONG Yifan        name = "rules_python",
69*d4726bddSHONG Yifan        sha256 = "778aaeab3e6cfd56d681c89f5c10d7ad6bf8d2f1a72de9de55b23081b2d31618",
70*d4726bddSHONG Yifan        strip_prefix = "rules_python-0.34.0",
71*d4726bddSHONG Yifan        url = "https://github.com/bazelbuild/rules_python/releases/download/0.34.0/rules_python-0.34.0.tar.gz",
72*d4726bddSHONG Yifan    )
73*d4726bddSHONG Yifan
74*d4726bddSHONG Yifan    direct_deps.extend([
75*d4726bddSHONG Yifan        struct(repo = "libc", is_dev_dep = True),
76*d4726bddSHONG Yifan        struct(repo = "rules_rust_toolchain_test_target_json", is_dev_dep = True),
77*d4726bddSHONG Yifan        struct(repo = "com_google_googleapis", is_dev_dep = True),
78*d4726bddSHONG Yifan        struct(repo = "rules_python", is_dev_dep = True),
79*d4726bddSHONG Yifan    ])
80*d4726bddSHONG Yifan
81*d4726bddSHONG Yifan    return direct_deps
82