-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBUILD.bazel
131 lines (118 loc) · 3.36 KB
/
BUILD.bazel
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@rules_rust//crate_universe:defs.bzl", "crates_vendor")
load("@rules_rust//cargo:cargo_build_script.bzl", "cargo_build_script")
load("@rules_rust//rust:defs.bzl",
"rust_binary",
"rust_clippy",
"rust_library",
"rustfmt_test",
"rust_test",
)
load("//vendor:defs.bzl", "aliases", "all_crate_deps")
package(default_visibility = ["//visibility:private"])
exports_files(["Cargo.toml", "Cargo.Bazel.lock"], ["//visibility:public"])
exports_files(["proto/health.proto"])
bzl_library(
name = "bzl_lib",
srcs = glob(["**/*.bzl"]) + [
"//vendor:defs.bzl",
"//vendor:crates.bzl",
],
visibility = ["//:__pkg__"],
)
# Repin the third party Cargo dependencies
# $ bazel run //:crates_vendor -- --repin
crates_vendor(
name = "crates_vendor",
manifests = ["@grpc_health_check//:Cargo.toml"],
cargo_lockfile = "//:Cargo.Bazel.lock",
mode = "remote",
vendor_path = "vendor",
tags = ["manual"],
)
cargo_build_script(
name = "rust_grpc_health_check_build_script",
srcs = [":build.rs"],
build_script_env = select({
"@platforms//os:macos": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_macos_x86_64//:protoc)",
},
"@platforms//os:linux": {
"PROTOC": "$(execpath @com_google_protobuf_protoc_linux_x86_64//:protoc)",
},
}),
deps = all_crate_deps(build = True),
data = [
"proto/health.proto",
"proto/test.proto",
] + select({
"@platforms//os:macos": [
"@com_google_protobuf_protoc_macos_x86_64//:protoc",
],
"@platforms//os:linux": [
"@com_google_protobuf_protoc_linux_x86_64//:protoc",
],
}),
)
rust_binary(
name = "rust_grpc_health_check_binary",
aliases = aliases(),
srcs = [
"src/error.rs",
"src/input.rs",
"src/main.rs",
],
deps = [":rust_grpc_health_check_build_script"] + all_crate_deps(),
)
rust_test(
name = "rust_grpc_health_check_binary_test",
crate = ":rust_grpc_health_check_binary",
deps = all_crate_deps(),
)
rust_library(
name = "rust_integration_test_library",
testonly = True,
srcs = [
"tests/connection.rs",
"tests/lib.rs",
"tests/options.rs",
],
deps = [":rust_grpc_health_check_build_script"] + all_crate_deps(
normal = True,
normal_dev = True,
),
)
rust_test(
name = "rust_integration_test",
crate = ":rust_integration_test_library",
env = {
"CARGO_BIN_EXE_grpc-health-check": "$(rootpath //:rust_grpc_health_check_binary)",
},
data = [":rust_grpc_health_check_binary"],
)
rustfmt_test(
name = "rust_grpc_health_check_binary_fmt_test",
targets = [
":rust_grpc_health_check_binary",
":rust_grpc_health_check_binary_test",
":rust_integration_test_library",
":rust_integration_test",
],
)
rust_clippy(
name = "rust_grpc_health_check_binary_clippy_test",
testonly = True,
deps = [
":rust_grpc_health_check_binary",
":rust_grpc_health_check_binary_test",
":rust_integration_test_library",
":rust_integration_test",
],
)
genrule(
name = "binary",
srcs = [":rust_grpc_health_check_binary"],
outs = ["grpc-health-check"],
cmd = "cp $< $@",
visibility = ["//visibility:public"],
)