blob: 6eb2cdbd9bd7fa66428131879a0795c3e3f0659e [file] [log] [blame]
Adam Snaider0967b812023-11-02 15:29:43 -07001load(
2 "@rules_rust//rust:defs.bzl",
3 _rust_binary = "rust_binary",
4 _rust_doc = "rust_doc",
5 _rust_doc_test = "rust_doc_test",
6 _rust_library = "rust_library",
7 _rust_test = "rust_test",
8)
9load("@com_github_google_flatbuffers//:build_defs.bzl", _flatbuffer_rust_library = "flatbuffer_rust_library")
10
Adam Snaider0967b812023-11-02 15:29:43 -070011def rust_doc_test(target_compatible_with = ["//tools/platforms/rust:has_support"], tags = [], **kwargs):
12 # TODO(james): Attempting to execute this remotely results
13 # in complaints about overly large files.
14 _rust_doc_test(
15 tags = tags + ["no-remote-exec"],
16 target_compatible_with = target_compatible_with,
17 **kwargs
18 )
19
20def rust_doc(target_compatible_with = ["//tools/platforms/rust:has_support"], **kwargs):
21 _rust_doc(
22 target_compatible_with = target_compatible_with,
23 **kwargs
24 )
25
Adam Snaider5f000672023-11-02 16:04:30 -070026def rust_binary(target_compatible_with = ["//tools/platforms/rust:has_support"], rustc_flags = [], **kwargs):
27 _rust_binary(
28 target_compatible_with = select({
29 Label("//conditions:default"): target_compatible_with,
30 Label("//tools:has_msan"): ["@platforms//:incompatible"],
31 }),
32 # TODO: Make Rust play happy with pic vs nopic. Details at:
33 # https://github.com/bazelbuild/rules_rust/issues/118
34 rustc_flags = rustc_flags + ["-Crelocation-model=static"],
35 **kwargs
36 )
37
38def rust_library(target_compatible_with = ["//tools/platforms/rust:has_support"], docs = True, **kwargs):
39 _rust_library(
40 target_compatible_with = select({
41 Label("//conditions:default"): target_compatible_with,
42 Label("//tools:has_msan"): ["@platforms//:incompatible"],
43 }),
44 **kwargs
45 )
46
47 if docs:
48 rust_doc(
49 name = kwargs["name"] + "_doc",
50 crate = kwargs["name"],
51 rustdoc_flags = ["--document-private-items"],
52 target_compatible_with = ["//tools/platforms/rust:has_support"],
53 )
54
55def rust_test(target_compatible_with = ["//tools/platforms/rust:has_support"], rustc_flags = [], **kwargs):
56 _rust_test(
57 target_compatible_with = select({
58 Label("//conditions:default"): target_compatible_with,
59 Label("//tools:has_msan"): ["@platforms//:incompatible"],
60 }),
61 rustc_flags = rustc_flags + ["-Crelocation-model=static"],
62 **kwargs
63 )
64
Adam Snaider0967b812023-11-02 15:29:43 -070065def flatbuffer_rust_library(target_compatible_with = ["//tools/platforms/rust:has_support"], **kwargs):
66 _flatbuffer_rust_library(
67 target_compatible_with = select({
68 Label("//conditions:default"): target_compatible_with,
69 Label("//tools:has_msan"): ["@platforms//:incompatible"],
70 }),
71 **kwargs
72 )