fork/rules_rust

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

Daniel Wagner-HallAdd example with a non-workspace Cargo.toml (#3019)0f0b3543

main
1.6 KiB75 linesraw
1load("@bazel_skylib//rules:build_test.bzl", "build_test")
2load("@rules_rust//rust:defs.bzl", "rust_binary", "rust_doc")
3
4package(default_visibility = ["//visibility:public"])
5
6rust_binary(
7    name = "hello_world_from_workspace_transient",
8    srcs = ["src/main.rs"],
9    deps = [
10        "@crates_in_workspace//:anyhow",
11    ],
12)
13
14rust_binary(
15    name = "hello_world_from_workspace_vendored",
16    srcs = ["src/main.rs"],
17    deps = [
18        "//third-party-in-workspace/crates:anyhow",
19    ],
20)
21
22rust_binary(
23    name = "hello_world_without_workspace_transient",
24    srcs = ["src/main.rs"],
25    deps = [
26        "@crates_without_workspace//:anyhow",
27    ],
28)
29
30[
31    rust_doc(
32        name = "hello_world_{}_doc".format(target),
33        crate = ":hello_world_{}".format(target),
34    )
35    for target in [
36        "from_workspace_transient",
37        "from_workspace_vendored",
38        "without_workspace_transient",
39    ]
40]
41
42[
43    sh_test(
44        name = "hello_world_{}_test".format(target),
45        srcs = ["hello_world_test.sh"],
46        args = [
47            "$(rlocationpath :hello_world_{})".format(target),
48        ],
49        data = [
50            ":hello_world_{}".format(target),
51        ],
52        deps = [
53            "@bazel_tools//tools/bash/runfiles",
54        ],
55    )
56    for target in [
57        "from_workspace_transient",
58        "from_workspace_vendored",
59        "without_workspace_transient",
60    ]
61]
62
63build_test(
64    name = "gen_rust_project",
65    targets = [
66        "@rules_rust//tools/rust_analyzer:gen_rust_project",
67    ],
68)
69
70build_test(
71    name = "rust_fmt",
72    targets = [
73        "@rules_rust//:rustfmt",
74    ],
75)