blob: 9c17d939572ad7c3f5bb1fbc16cc634281e4b3a5 [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
11def rust_binary(target_compatible_with = ["//tools/platforms/rust:has_support"], rustc_flags = [], **kwargs):
12 _rust_binary(
13 target_compatible_with = select({
14 Label("//conditions:default"): target_compatible_with,
15 Label("//tools:has_msan"): ["@platforms//:incompatible"],
16 }),
17 # TODO: Make Rust play happy with pic vs nopic. Details at:
18 # https://github.com/bazelbuild/rules_rust/issues/118
19 rustc_flags = rustc_flags + ["-Crelocation-model=static"],
20 **kwargs
21 )
22
23def rust_library(target_compatible_with = ["//tools/platforms/rust:has_support"], **kwargs):
24 _rust_library(
25 target_compatible_with = select({
26 Label("//conditions:default"): target_compatible_with,
27 Label("//tools:has_msan"): ["@platforms//:incompatible"],
28 }),
29 **kwargs
30 )
31
32def rust_test(target_compatible_with = ["//tools/platforms/rust:has_support"], rustc_flags = [], **kwargs):
33 _rust_test(
34 target_compatible_with = select({
35 Label("//conditions:default"): target_compatible_with,
36 Label("//tools:has_msan"): ["@platforms//:incompatible"],
37 }),
38 rustc_flags = rustc_flags + ["-Crelocation-model=static"],
39 **kwargs
40 )
41
42def rust_doc_test(target_compatible_with = ["//tools/platforms/rust:has_support"], tags = [], **kwargs):
43 # TODO(james): Attempting to execute this remotely results
44 # in complaints about overly large files.
45 _rust_doc_test(
46 tags = tags + ["no-remote-exec"],
47 target_compatible_with = target_compatible_with,
48 **kwargs
49 )
50
51def rust_doc(target_compatible_with = ["//tools/platforms/rust:has_support"], **kwargs):
52 _rust_doc(
53 target_compatible_with = target_compatible_with,
54 **kwargs
55 )
56
57def flatbuffer_rust_library(target_compatible_with = ["//tools/platforms/rust:has_support"], **kwargs):
58 _flatbuffer_rust_library(
59 target_compatible_with = select({
60 Label("//conditions:default"): target_compatible_with,
61 Label("//tools:has_msan"): ["@platforms//:incompatible"],
62 }),
63 **kwargs
64 )