• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1load("@rules_rust//crate_universe:defs.bzl", "crate", "crates_vendor", "render_config")
2load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_test")
3
4crates_vendor(
5    name = "crates_vendor",
6    annotations = {
7        "axum": [crate.annotation(
8            compile_data_glob = ["**/*.md"],
9        )],
10    },
11    mode = "remote",
12    packages = {
13        "axum": crate.spec(
14            version = "0.4.0",
15        ),
16        "hyper": crate.spec(
17            features = ["full"],
18            version = "0.14.22",
19        ),
20        "mime": crate.spec(
21            version = "0.3",
22        ),
23        "serde_json": crate.spec(
24            version = "1.0",
25        ),
26        # TODO: This dependency is added and pinned forward due to the
27        # following issue: https://github.com/hyperium/hyper/issues/3038
28        "socket2": crate.spec(
29            features = ["all"],
30            version = "0.4.7",
31        ),
32        "tokio": crate.spec(
33            features = ["full"],
34            version = "1.26.0",
35        ),
36        "tower": crate.spec(
37            features = ["util"],
38            version = "0.4",
39        ),
40        "tower-http": crate.spec(
41            features = ["trace"],
42            version = "0.2.1",
43        ),
44        "tracing": crate.spec(
45            version = "0.1",
46        ),
47        "tracing-subscriber": crate.spec(
48            version = "0.3",
49        ),
50    },
51    # Demonstrate that `crates_vendor` can accept a render_config. To regen this target, simply
52    # navigate to this directory and run `bazel run //vendor_remote_pkgs:crates_vendor`.
53    render_config = render_config(
54        regen_command = "See https://github.com/bazelbuild/rules_rust/blob/main/examples/crate_universe/vendor_local_pkgs/BUILD.bazel",
55    ),
56    repository_name = "crates_vendor_pkgs",
57)
58
59rust_binary(
60    name = "vendor_remote",
61    srcs = glob(["**/*.rs"]),
62    edition = "2018",
63    deps = [
64        "@crates_vendor_pkgs//:axum",
65        "@crates_vendor_pkgs//:hyper",
66        "@crates_vendor_pkgs//:mime",
67        "@crates_vendor_pkgs//:serde_json",
68        "@crates_vendor_pkgs//:tokio",
69        "@crates_vendor_pkgs//:tower",
70        "@crates_vendor_pkgs//:tower-http",
71        "@crates_vendor_pkgs//:tracing",
72        "@crates_vendor_pkgs//:tracing-subscriber",
73    ],
74)
75
76rust_test(
77    name = "unit_test",
78    crate = ":vendor_remote",
79    edition = "2018",
80)
81