xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/hello_lib/BUILD.bazel (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifanload(
2*d4726bddSHONG Yifan    "@rules_rust//rust:defs.bzl",
3*d4726bddSHONG Yifan    "rust_doc",
4*d4726bddSHONG Yifan    "rust_doc_test",
5*d4726bddSHONG Yifan    "rust_library",
6*d4726bddSHONG Yifan    "rust_shared_library",
7*d4726bddSHONG Yifan    "rust_static_library",
8*d4726bddSHONG Yifan    "rust_test",
9*d4726bddSHONG Yifan)
10*d4726bddSHONG Yifan
11*d4726bddSHONG Yifanpackage(default_visibility = ["//visibility:public"])
12*d4726bddSHONG Yifan
13*d4726bddSHONG Yifanrust_library(
14*d4726bddSHONG Yifan    name = "hello_lib",
15*d4726bddSHONG Yifan    srcs = [
16*d4726bddSHONG Yifan        "src/greeter.rs",
17*d4726bddSHONG Yifan        "src/lib.rs",
18*d4726bddSHONG Yifan    ],
19*d4726bddSHONG Yifan    crate_features = ["default"],
20*d4726bddSHONG Yifan    rustc_flags = ["--cap-lints=allow"],
21*d4726bddSHONG Yifan)
22*d4726bddSHONG Yifan
23*d4726bddSHONG Yifanrust_shared_library(
24*d4726bddSHONG Yifan    name = "hello_cdylib",
25*d4726bddSHONG Yifan    srcs = [
26*d4726bddSHONG Yifan        "src/greeter.rs",
27*d4726bddSHONG Yifan        "src/lib.rs",
28*d4726bddSHONG Yifan    ],
29*d4726bddSHONG Yifan)
30*d4726bddSHONG Yifan
31*d4726bddSHONG Yifanrust_static_library(
32*d4726bddSHONG Yifan    name = "hello_staticlib",
33*d4726bddSHONG Yifan    srcs = [
34*d4726bddSHONG Yifan        "src/greeter.rs",
35*d4726bddSHONG Yifan        "src/lib.rs",
36*d4726bddSHONG Yifan    ],
37*d4726bddSHONG Yifan)
38*d4726bddSHONG Yifan
39*d4726bddSHONG Yifan# Regression test for #368: static lib with dependencies fail.
40*d4726bddSHONG Yifanrust_static_library(
41*d4726bddSHONG Yifan    name = "hello_test_staticlib",
42*d4726bddSHONG Yifan    srcs = [
43*d4726bddSHONG Yifan        "tests/greeting.rs",
44*d4726bddSHONG Yifan    ],
45*d4726bddSHONG Yifan    deps = [":hello_lib"],
46*d4726bddSHONG Yifan)
47*d4726bddSHONG Yifan
48*d4726bddSHONG Yifan# Regression test for #368: cdylib lib with dependencies fail.
49*d4726bddSHONG Yifanrust_shared_library(
50*d4726bddSHONG Yifan    name = "hello_test_cdylib",
51*d4726bddSHONG Yifan    srcs = [
52*d4726bddSHONG Yifan        "tests/greeting.rs",
53*d4726bddSHONG Yifan    ],
54*d4726bddSHONG Yifan    deps = [":hello_lib"],
55*d4726bddSHONG Yifan)
56*d4726bddSHONG Yifan
57*d4726bddSHONG Yifanrust_test(
58*d4726bddSHONG Yifan    name = "hello-lib-test",
59*d4726bddSHONG Yifan    crate = ":hello_lib",
60*d4726bddSHONG Yifan)
61*d4726bddSHONG Yifan
62*d4726bddSHONG Yifanrust_test(
63*d4726bddSHONG Yifan    name = "greeting_test",
64*d4726bddSHONG Yifan    srcs = ["tests/greeting.rs"],
65*d4726bddSHONG Yifan    deps = [":hello_lib"],
66*d4726bddSHONG Yifan)
67*d4726bddSHONG Yifan
68*d4726bddSHONG Yifanrust_doc(
69*d4726bddSHONG Yifan    name = "hello_lib_doc",
70*d4726bddSHONG Yifan    crate = ":hello_lib",
71*d4726bddSHONG Yifan)
72*d4726bddSHONG Yifan
73*d4726bddSHONG Yifanrust_doc_test(
74*d4726bddSHONG Yifan    name = "hello_lib_doc_test",
75*d4726bddSHONG Yifan    crate = ":hello_lib",
76*d4726bddSHONG Yifan)
77