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("//pw_build:pigweed.bzl", "pw_cc_binary", "pw_cc_library", "pw_cc_test") 16load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library") 17load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") 18load("@rules_proto//proto:defs.bzl", "proto_library") 19 20package(default_visibility = ["//visibility:public"]) 21 22licenses(["notice"]) 23 24pw_cc_library( 25 name = "config", 26 hdrs = ["public/pw_transfer/internal/config.h"], 27 includes = ["public"], 28 deps = [ 29 "//pw_chrono:system_clock", 30 ], 31) 32 33pw_cc_library( 34 name = "core", 35 srcs = [ 36 "chunk.cc", 37 "client_context.cc", 38 "context.cc", 39 "public/pw_transfer/internal/chunk.h", 40 "public/pw_transfer/internal/client_context.h", 41 "public/pw_transfer/internal/context.h", 42 "public/pw_transfer/internal/event.h", 43 "public/pw_transfer/internal/protocol.h", 44 "public/pw_transfer/internal/server_context.h", 45 "rate_estimate.cc", 46 "server_context.cc", 47 "transfer_thread.cc", 48 ], 49 hdrs = [ 50 "public/pw_transfer/handler.h", 51 "public/pw_transfer/rate_estimate.h", 52 "public/pw_transfer/transfer_thread.h", 53 ], 54 includes = ["public"], 55 deps = [ 56 ":config", 57 ":transfer_pwpb.pwpb", 58 ":transfer_pwpb.raw_rpc", 59 "//pw_bytes", 60 "//pw_chrono:system_clock", 61 "//pw_containers:intrusive_list", 62 "//pw_log", 63 "//pw_preprocessor", 64 "//pw_protobuf", 65 "//pw_result", 66 "//pw_rpc:client_server", 67 "//pw_rpc:internal_packet_cc.pwpb", 68 "//pw_rpc/raw:client_api", 69 "//pw_rpc/raw:server_api", 70 "//pw_status", 71 "//pw_stream", 72 "//pw_sync:binary_semaphore", 73 "//pw_sync:timed_thread_notification", 74 "//pw_thread:thread_core", 75 "//pw_varint", 76 ], 77) 78 79pw_cc_library( 80 name = "pw_transfer", 81 srcs = [ 82 "transfer.cc", 83 ], 84 hdrs = [ 85 "public/pw_transfer/transfer.h", 86 ], 87 includes = ["public"], 88 deps = [ 89 ":core", 90 "//pw_assert", 91 "//pw_bytes", 92 "//pw_log", 93 "//pw_result", 94 "//pw_rpc:internal_packet_cc.pwpb", 95 "//pw_rpc/raw:server_api", 96 "//pw_status", 97 "//pw_stream", 98 ], 99) 100 101pw_cc_library( 102 name = "client", 103 srcs = [ 104 "client.cc", 105 ], 106 hdrs = [ 107 "public/pw_transfer/client.h", 108 ], 109 includes = ["public"], 110 deps = [ 111 ":core", 112 "//pw_assert", 113 "//pw_function", 114 "//pw_log", 115 "//pw_stream", 116 ], 117) 118 119pw_cc_library( 120 name = "atomic_file_transfer_handler", 121 srcs = ["atomic_file_transfer_handler.cc"], 122 hdrs = [ 123 "public/pw_transfer/atomic_file_transfer_handler.h", 124 ], 125 includes = ["public"], 126 deps = [ 127 ":atomic_file_transfer_handler_internal", 128 ":core", 129 "//pw_log", 130 "//pw_stream:std_file_stream", 131 ], 132) 133 134pw_cc_library( 135 name = "atomic_file_transfer_handler_internal", 136 srcs = [ 137 "pw_transfer_private/filename_generator.h", 138 ], 139) 140 141pw_cc_library( 142 name = "test_helpers", 143 srcs = [ 144 "pw_transfer_private/chunk_testing.h", 145 ], 146 deps = [ 147 ":core", 148 "//pw_containers", 149 ], 150) 151 152pw_cc_test( 153 name = "chunk_test", 154 srcs = ["chunk_test.cc"], 155 deps = [ 156 ":core", 157 "//pw_unit_test", 158 ], 159) 160 161pw_cc_test( 162 name = "handler_test", 163 srcs = ["handler_test.cc"], 164 deps = [ 165 ":pw_transfer", 166 "//pw_unit_test", 167 ], 168) 169 170pw_cc_test( 171 name = "atomic_file_transfer_handler_test", 172 srcs = ["atomic_file_transfer_handler_test.cc"], 173 deps = [ 174 ":atomic_file_transfer_handler", 175 ":atomic_file_transfer_handler_internal", 176 ":pw_transfer", 177 "//pw_random", 178 "//pw_string", 179 "//pw_unit_test", 180 ], 181) 182 183pw_cc_test( 184 name = "transfer_thread_test", 185 srcs = ["transfer_thread_test.cc"], 186 deps = [ 187 ":pw_transfer", 188 ":test_helpers", 189 "//pw_rpc:test_helpers", 190 "//pw_rpc/raw:client_testing", 191 "//pw_rpc/raw:test_method_context", 192 "//pw_thread:thread", 193 "//pw_unit_test", 194 ], 195) 196 197pw_cc_test( 198 name = "transfer_test", 199 srcs = ["transfer_test.cc"], 200 deps = [ 201 ":pw_transfer", 202 ":test_helpers", 203 "//pw_assert", 204 "//pw_containers", 205 "//pw_rpc:test_helpers", 206 "//pw_rpc/raw:test_method_context", 207 "//pw_thread:thread", 208 "//pw_unit_test", 209 ], 210) 211 212pw_cc_test( 213 name = "client_test", 214 srcs = ["client_test.cc"], 215 deps = [ 216 ":client", 217 ":test_helpers", 218 "//pw_rpc:test_helpers", 219 "//pw_rpc/raw:client_testing", 220 "//pw_thread:sleep", 221 "//pw_thread:thread", 222 "//pw_unit_test", 223 ], 224) 225 226pw_cc_binary( 227 name = "test_rpc_server", 228 srcs = ["test_rpc_server.cc"], 229 deps = [ 230 ":atomic_file_transfer_handler", 231 ":pw_transfer", 232 ":test_server_pwpb.raw_rpc", 233 "//pw_log", 234 "//pw_rpc/system_server", 235 "//pw_stream:std_file_stream", 236 "//pw_thread:thread", 237 "//pw_work_queue", 238 ], 239) 240 241proto_library( 242 name = "transfer_proto", 243 srcs = [ 244 "transfer.proto", 245 ], 246) 247 248pw_proto_library( 249 name = "transfer_pwpb", 250 deps = [":transfer_proto"], 251) 252 253py_proto_library( 254 name = "transfer_proto_pb2", 255 srcs = ["transfer.proto"], 256) 257 258java_lite_proto_library( 259 name = "transfer_proto_java_lite", 260 deps = [":transfer_proto"], 261) 262 263proto_library( 264 name = "test_server", 265 srcs = [ 266 "test_server.proto", 267 ], 268 import_prefix = "pw_transfer_test", 269 strip_import_prefix = "/pw_transfer", 270 deps = [ 271 "//pw_protobuf:common_proto", 272 ], 273) 274 275pw_proto_library( 276 name = "test_server_pwpb", 277 deps = [":test_server"], 278) 279