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("@com_google_protobuf//bazel:cc_proto_library.bzl", "cc_proto_library") 16load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library") 17load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library") 18load("@rules_java//java:defs.bzl", "java_binary") 19load("@rules_jvm_external//:defs.bzl", "artifact") 20load("@rules_python//python:defs.bzl", "py_library") 21load("@rules_python//python:proto.bzl", "py_proto_library") 22load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 23load("//pw_build:pw_cc_binary.bzl", "pw_cc_binary") 24load("//pw_build:python.bzl", "pw_py_binary", "pw_py_test") 25 26package(features = ["-layering_check"]) 27 28pw_cc_binary( 29 name = "server", 30 srcs = ["server.cc"], 31 deps = [ 32 ":config_cc_proto", 33 "//pw_assert:check", 34 "//pw_chrono:system_clock", 35 "//pw_log", 36 "//pw_rpc/system_server", 37 "//pw_stream", 38 "//pw_stream:std_file_stream", 39 "//pw_thread:thread", 40 "//pw_transfer", 41 "@com_google_protobuf//:protobuf", 42 ], 43) 44 45pw_py_binary( 46 name = "proxy", 47 srcs = ["proxy.py"], 48 deps = [ 49 ":config_pb2", 50 "//pw_hdlc/py:pw_hdlc", 51 "//pw_transfer:transfer_proto_pb2", 52 "//pw_transfer/py:pw_transfer", 53 "@com_google_protobuf//:protobuf_python", 54 ], 55) 56 57pw_py_test( 58 name = "proxy_test", 59 srcs = [ 60 "proxy.py", 61 "proxy_test.py", 62 ], 63 imports = ["."], 64 main = "proxy_test.py", 65 deps = [ 66 ":config_pb2", 67 "//pw_hdlc/py:pw_hdlc", 68 "//pw_rpc:internal_packet_proto_pb2", 69 "//pw_transfer:transfer_proto_pb2", 70 "//pw_transfer/py:pw_transfer", 71 ], 72) 73 74proto_library( 75 name = "config_proto", 76 srcs = ["config.proto"], 77 deps = ["//pw_protobuf:status_proto"], 78) 79 80cc_proto_library( 81 name = "config_cc_proto", 82 # cc_proto_library pulls in the regular proto library, which is only 83 # needed for host tests. 84 target_compatible_with = incompatible_with_mcu(), 85 deps = [":config_proto"], 86) 87 88py_proto_library( 89 name = "config_pb2", 90 deps = [":config_proto"], 91) 92 93java_proto_library( 94 name = "config_java_proto", 95 deps = [":config_proto"], 96) 97 98pw_cc_binary( 99 name = "cpp_client", 100 testonly = True, 101 srcs = ["client.cc"], 102 deps = [ 103 ":config_cc_proto", 104 "//pw_assert:check", 105 "//pw_log", 106 "//pw_rpc:integration_testing", 107 "//pw_status", 108 "//pw_stream:std_file_stream", 109 "//pw_sync:binary_semaphore", 110 "//pw_thread:thread", 111 "//pw_transfer", 112 "//pw_transfer:client", 113 "@com_google_protobuf//:protobuf", 114 ], 115) 116 117py_library( 118 name = "integration_test_fixture", 119 testonly = True, 120 srcs = [ 121 "test_fixture.py", 122 ], 123 data = [ 124 ":cpp_client", 125 ":java_client", 126 ":proxy", 127 ":python_client", 128 ":server", 129 ], 130 imports = ["."], 131 deps = [ 132 ":config_pb2", 133 "//pw_protobuf:status_proto_pb2", 134 "@com_google_protobuf//:protobuf_python", 135 "@rules_python//python/runfiles", 136 ], 137) 138 139# Uses ports 3310 and 3311. 140pw_py_test( 141 name = "cross_language_large_write_test", 142 # Actually 1 hour, see 143 # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner 144 timeout = "eternal", 145 srcs = [ 146 "cross_language_large_write_test.py", 147 ], 148 tags = [ 149 # This test is not run in CQ because it's too slow. 150 "manual", 151 "integration", 152 ], 153 deps = [ 154 ":integration_test_fixture", 155 "@python_packages//parameterized", 156 ], 157) 158 159# Uses ports 3306 and 3307. 160pw_py_test( 161 name = "cross_language_large_read_test", 162 # Actually 1 hour, see 163 # https://docs.bazel.build/versions/main/test-encyclopedia.html#role-of-the-test-runner 164 timeout = "eternal", 165 srcs = [ 166 "cross_language_large_read_test.py", 167 ], 168 tags = [ 169 # This test is not run in CQ because it's too slow. 170 "manual", 171 "integration", 172 ], 173 deps = [ 174 ":integration_test_fixture", 175 "@python_packages//parameterized", 176 ], 177) 178 179# Uses ports 3304 and 3305. 180pw_py_test( 181 name = "cross_language_medium_read_test", 182 timeout = "moderate", 183 srcs = [ 184 "cross_language_medium_read_test.py", 185 ], 186 tags = [ 187 "integration", 188 ], 189 deps = [ 190 ":config_pb2", 191 ":integration_test_fixture", 192 "@com_google_protobuf//:protobuf_python", 193 "@python_packages//parameterized", 194 ], 195) 196 197# Uses ports 3316 and 3317. 198pw_py_test( 199 name = "cross_language_medium_write_test", 200 timeout = "long", 201 srcs = [ 202 "cross_language_medium_write_test.py", 203 ], 204 tags = [ 205 "integration", 206 ], 207 deps = [ 208 ":config_pb2", 209 ":integration_test_fixture", 210 "@com_google_protobuf//:protobuf_python", 211 "@python_packages//parameterized", 212 ], 213) 214 215# Uses ports 3302 and 3303. 216pw_py_test( 217 name = "cross_language_small_test", 218 timeout = "moderate", 219 srcs = [ 220 "cross_language_small_test.py", 221 ], 222 tags = [ 223 "integration", 224 ], 225 deps = [ 226 ":config_pb2", 227 ":integration_test_fixture", 228 "@python_packages//parameterized", 229 ], 230) 231 232# Uses ports 3308 and 3309. 233pw_py_test( 234 name = "multi_transfer_test", 235 timeout = "moderate", 236 srcs = [ 237 "multi_transfer_test.py", 238 ], 239 tags = [ 240 "integration", 241 ], 242 deps = [ 243 ":config_pb2", 244 ":integration_test_fixture", 245 "@python_packages//parameterized", 246 ], 247) 248 249# Uses ports 3312 and 3313. 250pw_py_test( 251 name = "expected_errors_test", 252 timeout = "long", 253 srcs = ["expected_errors_test.py"], 254 tags = [ 255 "integration", 256 ], 257 deps = [ 258 ":config_pb2", 259 ":integration_test_fixture", 260 "//pw_protobuf:status_proto_pb2", 261 "@com_google_protobuf//:protobuf_python", 262 "@python_packages//parameterized", 263 ], 264) 265 266# Uses ports 3314 and 3315. 267pw_py_test( 268 name = "legacy_binaries_test", 269 timeout = "moderate", 270 srcs = ["legacy_binaries_test.py"], 271 data = [ 272 "@pw_transfer_test_binaries//:all", 273 ], 274 tags = [ 275 "integration", 276 ], 277 # Legacy binaries were only built for linux-x86_64. 278 target_compatible_with = ["@platforms//os:linux"], 279 deps = [ 280 ":config_pb2", 281 ":integration_test_fixture", 282 "//pw_protobuf:status_proto_pb2", 283 "@python_packages//parameterized", 284 "@rules_python//python/runfiles", 285 ], 286) 287 288java_binary( 289 name = "java_client", 290 srcs = ["JavaClient.java"], 291 main_class = "JavaClient", 292 target_compatible_with = incompatible_with_mcu(), 293 deps = [ 294 ":config_java_proto", 295 "//pw_hdlc/java/main/dev/pigweed/pw_hdlc", 296 "//pw_log/java/main/dev/pigweed/pw_log", 297 "//pw_rpc/java/main/dev/pigweed/pw_rpc:client", 298 "//pw_transfer/java/main/dev/pigweed/pw_transfer:client", 299 "@com_google_protobuf//:protobuf_java", 300 artifact("com.google.flogger:flogger-system-backend"), 301 artifact("com.google.guava:guava"), 302 ], 303) 304 305pw_py_binary( 306 name = "python_client", 307 srcs = ["python_client.py"], 308 deps = [ 309 ":config_pb2", 310 "//pw_hdlc/py:pw_hdlc", 311 "//pw_rpc/py:pw_rpc", 312 "//pw_transfer:transfer_proto_pb2", 313 "//pw_transfer/py:pw_transfer", 314 "@com_google_protobuf//:protobuf_python", 315 "@python_packages//pyserial", 316 ], 317) 318