xref: /aosp_15_r20/external/bazelbuild-rules_rust/test/rust/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifanload("@bazel_tools//tools/build_rules:test_rules.bzl", "rule_test")
2*d4726bddSHONG Yifanload("//rust:defs.bzl", "rust_binary", "rust_library", "rust_test")
3*d4726bddSHONG Yifan
4*d4726bddSHONG Yifanpackage(default_visibility = ["//visibility:public"])
5*d4726bddSHONG Yifan
6*d4726bddSHONG Yifanrust_library(
7*d4726bddSHONG Yifan    name = "hello_lib",
8*d4726bddSHONG Yifan    srcs = [
9*d4726bddSHONG Yifan        "src/greeter.rs",
10*d4726bddSHONG Yifan        "src/lib.rs",
11*d4726bddSHONG Yifan    ],
12*d4726bddSHONG Yifan    data = ["greeting.txt"],
13*d4726bddSHONG Yifan    edition = "2018",
14*d4726bddSHONG Yifan    deps = ["//tools/runfiles"],
15*d4726bddSHONG Yifan)
16*d4726bddSHONG Yifan
17*d4726bddSHONG Yifanrust_binary(
18*d4726bddSHONG Yifan    name = "hello_world",
19*d4726bddSHONG Yifan    srcs = ["src/main.rs"],
20*d4726bddSHONG Yifan    edition = "2018",
21*d4726bddSHONG Yifan    deps = [":hello_lib"],
22*d4726bddSHONG Yifan)
23*d4726bddSHONG Yifan
24*d4726bddSHONG Yifanrust_test(
25*d4726bddSHONG Yifan    name = "hello_lib_test",
26*d4726bddSHONG Yifan    crate = ":hello_lib",
27*d4726bddSHONG Yifan)
28*d4726bddSHONG Yifan
29*d4726bddSHONG Yifanrule_test(
30*d4726bddSHONG Yifan    name = "hello_lib_rule_test",
31*d4726bddSHONG Yifan    generates = ["libhello_lib-683707109.rlib"],
32*d4726bddSHONG Yifan    rule = ":hello_lib",
33*d4726bddSHONG Yifan)
34*d4726bddSHONG Yifan
35*d4726bddSHONG Yifanrule_test(
36*d4726bddSHONG Yifan    name = "hello_world_rule_test",
37*d4726bddSHONG Yifan    generates = select({
38*d4726bddSHONG Yifan        "//rust/platform:windows": ["hello_world.exe"],
39*d4726bddSHONG Yifan        "//conditions:default": ["hello_world"],
40*d4726bddSHONG Yifan    }),
41*d4726bddSHONG Yifan    rule = "//test/rust:hello_world",
42*d4726bddSHONG Yifan)
43