1# Copyright 2022 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15load("@rules_proto//proto:defs.bzl", "proto_library") 16load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test") 17load("@rules_python//python:proto.bzl", "py_proto_library") 18load("//pw_build:pigweed.bzl", "pw_cc_binary") 19load("//pw_build:selects.bzl", "TARGET_COMPATIBLE_WITH_HOST_SELECT") 20 21pw_cc_binary( 22 name = "server", 23 srcs = ["server.cc"], 24 deps = [ 25 ":config_cc_proto", 26 "//pw_assert", 27 "//pw_chrono:system_clock", 28 "//pw_log", 29 "//pw_rpc/system_server", 30 "//pw_stream", 31 "//pw_stream:std_file_stream", 32 "//pw_thread:thread", 33 "//pw_transfer", 34 "@com_google_protobuf//:protobuf", 35 ], 36) 37 38py_binary( 39 name = "proxy", 40 srcs = ["proxy.py"], 41 deps = [ 42 ":config_pb2", 43 "//pw_hdlc/py:pw_hdlc", 44 "//pw_transfer:transfer_proto_pb2", 45 "//pw_transfer/py:pw_transfer", 46 "@com_google_protobuf//:protobuf_python", 47 ], 48) 49 50py_test( 51 name = "proxy_test", 52 srcs = [ 53 "proxy.py", 54 "proxy_test.py", 55 ], 56 imports = ["."], 57 main = "proxy_test.py", 58 deps = [ 59 ":config_pb2", 60 "//pw_hdlc/py:pw_hdlc", 61 "//pw_rpc:internal_packet_proto_pb2", 62 "//pw_transfer:transfer_proto_pb2", 63 "//pw_transfer/py:pw_transfer", 64 ], 65) 66 67proto_library( 68 name = "config_proto", 69 srcs = ["config.proto"], 70 deps = ["//pw_protobuf:status_proto"], 71) 72 73cc_proto_library( 74 name = "config_cc_proto", 75 # cc_proto_library pulls in the regular proto library, which is only 76 # needed for host tests. 77 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 78 deps = [":config_proto"], 79) 80 81py_proto_library( 82 name = "config_pb2", 83 deps = [":config_proto"], 84) 85 86java_proto_library( 87 name = "config_java_proto", 88 deps = [":config_proto"], 89) 90 91pw_cc_binary( 92 name = "cpp_client", 93 testonly = True, 94 srcs = ["client.cc"], 95 deps = [ 96 ":config_cc_proto", 97 "//pw_log", 98 "//pw_rpc:integration_testing", 99 "//pw_status", 100 "//pw_stream:std_file_stream", 101 "//pw_sync:binary_semaphore", 102 "//pw_thread:thread", 103 "//pw_transfer", 104 "//pw_transfer:client", 105 "@com_google_protobuf//:protobuf", 106 ], 107) 108 109py_library( 110 name = "integration_test_fixture", 111 testonly = True, 112 srcs = [ 113 "test_fixture.py", 114 ], 115 data = [ 116 ":cpp_client", 117 ":java_client", 118 ":proxy", 119 ":python_client", 120 ":server", 121 ], 122 imports = ["."], 123 deps = [ 124 ":config_pb2", 125 "//pw_protobuf:status_proto_pb2", 126 "@com_google_protobuf//:protobuf_python", 127 "@rules_python//python/runfiles", 128 ], 129) 130 131# Uses ports 3310 and 3311. 132py_test( 133 name = "cross_language_large_write_test", 134 # Actually 1 hour, see 135 # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner 136 timeout = "eternal", 137 srcs = [ 138 "cross_language_large_write_test.py", 139 ], 140 tags = [ 141 # This test is not run in CQ because it's too slow. 142 "manual", 143 "integration", 144 ], 145 deps = [ 146 ":integration_test_fixture", 147 "@python_packages_parameterized//:pkg", 148 ], 149) 150 151# Uses ports 3306 and 3307. 152py_test( 153 name = "cross_language_large_read_test", 154 # Actually 1 hour, see 155 # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner 156 timeout = "eternal", 157 srcs = [ 158 "cross_language_large_read_test.py", 159 ], 160 tags = [ 161 # This test is not run in CQ because it's too slow. 162 "manual", 163 "integration", 164 ], 165 deps = [ 166 ":integration_test_fixture", 167 "@python_packages_parameterized//:pkg", 168 ], 169) 170 171# Uses ports 3304 and 3305. 172py_test( 173 name = "cross_language_medium_read_test", 174 timeout = "moderate", 175 srcs = [ 176 "cross_language_medium_read_test.py", 177 ], 178 tags = [ 179 "integration", 180 ], 181 deps = [ 182 ":config_pb2", 183 ":integration_test_fixture", 184 "@com_google_protobuf//:protobuf_python", 185 "@python_packages_parameterized//:pkg", 186 ], 187) 188 189# Uses ports 3316 and 3317. 190py_test( 191 name = "cross_language_medium_write_test", 192 timeout = "long", 193 srcs = [ 194 "cross_language_medium_write_test.py", 195 ], 196 tags = [ 197 "integration", 198 ], 199 deps = [ 200 ":config_pb2", 201 ":integration_test_fixture", 202 "@com_google_protobuf//:protobuf_python", 203 "@python_packages_parameterized//:pkg", 204 ], 205) 206 207# Uses ports 3302 and 3303. 208py_test( 209 name = "cross_language_small_test", 210 timeout = "moderate", 211 srcs = [ 212 "cross_language_small_test.py", 213 ], 214 tags = [ 215 "integration", 216 ], 217 deps = [ 218 ":config_pb2", 219 ":integration_test_fixture", 220 "@python_packages_parameterized//:pkg", 221 ], 222) 223 224# Uses ports 3308 and 3309. 225py_test( 226 name = "multi_transfer_test", 227 timeout = "moderate", 228 srcs = [ 229 "multi_transfer_test.py", 230 ], 231 tags = [ 232 "integration", 233 ], 234 deps = [ 235 ":config_pb2", 236 ":integration_test_fixture", 237 "@python_packages_parameterized//:pkg", 238 ], 239) 240 241# Uses ports 3312 and 3313. 242py_test( 243 name = "expected_errors_test", 244 timeout = "long", 245 srcs = ["expected_errors_test.py"], 246 tags = [ 247 "integration", 248 ], 249 deps = [ 250 ":config_pb2", 251 ":integration_test_fixture", 252 "//pw_protobuf:status_proto_pb2", 253 "@com_google_protobuf//:protobuf_python", 254 "@python_packages_parameterized//:pkg", 255 ], 256) 257 258# Uses ports 3314 and 3315. 259py_test( 260 name = "legacy_binaries_test", 261 timeout = "moderate", 262 srcs = ["legacy_binaries_test.py"], 263 data = [ 264 "@pw_transfer_test_binaries//:all", 265 ], 266 tags = [ 267 "integration", 268 ], 269 # Legacy binaries were only built for linux-x86_64. 270 target_compatible_with = ["@platforms//os:linux"], 271 deps = [ 272 ":config_pb2", 273 ":integration_test_fixture", 274 "//pw_protobuf:status_proto_pb2", 275 "@python_packages_parameterized//:pkg", 276 "@rules_python//python/runfiles", 277 ], 278) 279 280java_binary( 281 name = "java_client", 282 srcs = ["JavaClient.java"], 283 main_class = "JavaClient", 284 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 285 deps = [ 286 ":config_java_proto", 287 "//pw_hdlc/java/main/dev/pigweed/pw_hdlc", 288 "//pw_log/java/main/dev/pigweed/pw_log", 289 "//pw_rpc/java/main/dev/pigweed/pw_rpc:client", 290 "//pw_transfer/java/main/dev/pigweed/pw_transfer:client", 291 "@com_google_protobuf//:protobuf_java", 292 "@maven//:com_google_flogger_flogger_system_backend", 293 "@maven//:com_google_guava_guava", 294 ], 295) 296 297py_binary( 298 name = "python_client", 299 srcs = ["python_client.py"], 300 deps = [ 301 ":config_pb2", 302 "//pw_hdlc/py:pw_hdlc", 303 "//pw_rpc/py:pw_rpc", 304 "//pw_transfer:transfer_proto_pb2", 305 "//pw_transfer/py:pw_transfer", 306 "@com_google_protobuf//:protobuf_python", 307 "@python_packages_pyserial//:pkg", 308 ], 309) 310