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