xref: /aosp_15_r20/external/pigweed/pw_transfer/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2022 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerload("@rules_proto//proto:defs.bzl", "proto_library")
16*61c4878aSAndroid Build Coastguard Workerload("@rules_python//python:proto.bzl", "py_proto_library")
17*61c4878aSAndroid Build Coastguard Workerload(
18*61c4878aSAndroid Build Coastguard Worker    "//pw_protobuf_compiler:pw_proto_library.bzl",
19*61c4878aSAndroid Build Coastguard Worker    "pwpb_proto_library",
20*61c4878aSAndroid Build Coastguard Worker    "raw_rpc_proto_library",
21*61c4878aSAndroid Build Coastguard Worker)
22*61c4878aSAndroid Build Coastguard Workerload("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Workerpackage(default_visibility = ["//visibility:public"])
25*61c4878aSAndroid Build Coastguard Worker
26*61c4878aSAndroid Build Coastguard Workerlicenses(["notice"])
27*61c4878aSAndroid Build Coastguard Worker
28*61c4878aSAndroid Build Coastguard Workerhosts_lin_mac = {
29*61c4878aSAndroid Build Coastguard Worker    "@platforms//os:linux": [],
30*61c4878aSAndroid Build Coastguard Worker    "@platforms//os:macos": [],
31*61c4878aSAndroid Build Coastguard Worker    "//conditions:default": ["@platforms//:incompatible"],
32*61c4878aSAndroid Build Coastguard Worker}
33*61c4878aSAndroid Build Coastguard Worker
34*61c4878aSAndroid Build Coastguard Workercc_library(
35*61c4878aSAndroid Build Coastguard Worker    name = "config",
36*61c4878aSAndroid Build Coastguard Worker    hdrs = ["public/pw_transfer/internal/config.h"],
37*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
38*61c4878aSAndroid Build Coastguard Worker    deps = [
39*61c4878aSAndroid Build Coastguard Worker        ":config_override",
40*61c4878aSAndroid Build Coastguard Worker        "//pw_chrono:system_clock",
41*61c4878aSAndroid Build Coastguard Worker    ],
42*61c4878aSAndroid Build Coastguard Worker)
43*61c4878aSAndroid Build Coastguard Worker
44*61c4878aSAndroid Build Coastguard Workerlabel_flag(
45*61c4878aSAndroid Build Coastguard Worker    name = "config_override",
46*61c4878aSAndroid Build Coastguard Worker    build_setting_default = "//pw_build:default_module_config",
47*61c4878aSAndroid Build Coastguard Worker)
48*61c4878aSAndroid Build Coastguard Worker
49*61c4878aSAndroid Build Coastguard Workercc_library(
50*61c4878aSAndroid Build Coastguard Worker    name = "core",
51*61c4878aSAndroid Build Coastguard Worker    srcs = [
52*61c4878aSAndroid Build Coastguard Worker        "chunk.cc",
53*61c4878aSAndroid Build Coastguard Worker        "client_context.cc",
54*61c4878aSAndroid Build Coastguard Worker        "context.cc",
55*61c4878aSAndroid Build Coastguard Worker        "rate_estimate.cc",
56*61c4878aSAndroid Build Coastguard Worker        "server_context.cc",
57*61c4878aSAndroid Build Coastguard Worker        "transfer_thread.cc",
58*61c4878aSAndroid Build Coastguard Worker    ],
59*61c4878aSAndroid Build Coastguard Worker    hdrs = [
60*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/handler.h",
61*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/chunk.h",
62*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/client_context.h",
63*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/context.h",
64*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/event.h",
65*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/protocol.h",
66*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/internal/server_context.h",
67*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/rate_estimate.h",
68*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/transfer_thread.h",
69*61c4878aSAndroid Build Coastguard Worker    ],
70*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
71*61c4878aSAndroid Build Coastguard Worker    deps = [
72*61c4878aSAndroid Build Coastguard Worker        ":config",
73*61c4878aSAndroid Build Coastguard Worker        ":transfer_pwpb",
74*61c4878aSAndroid Build Coastguard Worker        ":transfer_raw_rpc",
75*61c4878aSAndroid Build Coastguard Worker        "//pw_bytes",
76*61c4878aSAndroid Build Coastguard Worker        "//pw_chrono:system_clock",
77*61c4878aSAndroid Build Coastguard Worker        "//pw_containers:intrusive_list",
78*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
79*61c4878aSAndroid Build Coastguard Worker        "//pw_log:rate_limited",
80*61c4878aSAndroid Build Coastguard Worker        "//pw_preprocessor",
81*61c4878aSAndroid Build Coastguard Worker        "//pw_protobuf",
82*61c4878aSAndroid Build Coastguard Worker        "//pw_result",
83*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:client_server",
84*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:internal_packet_pwpb",
85*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:client_api",
86*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:server_api",
87*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
88*61c4878aSAndroid Build Coastguard Worker        "//pw_stream",
89*61c4878aSAndroid Build Coastguard Worker        "//pw_sync:binary_semaphore",
90*61c4878aSAndroid Build Coastguard Worker        "//pw_sync:timed_thread_notification",
91*61c4878aSAndroid Build Coastguard Worker        "//pw_thread:thread_core",
92*61c4878aSAndroid Build Coastguard Worker        "//pw_varint",
93*61c4878aSAndroid Build Coastguard Worker    ],
94*61c4878aSAndroid Build Coastguard Worker)
95*61c4878aSAndroid Build Coastguard Worker
96*61c4878aSAndroid Build Coastguard Workercc_library(
97*61c4878aSAndroid Build Coastguard Worker    name = "pw_transfer",
98*61c4878aSAndroid Build Coastguard Worker    srcs = [
99*61c4878aSAndroid Build Coastguard Worker        "transfer.cc",
100*61c4878aSAndroid Build Coastguard Worker    ],
101*61c4878aSAndroid Build Coastguard Worker    hdrs = [
102*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/transfer.h",
103*61c4878aSAndroid Build Coastguard Worker    ],
104*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
105*61c4878aSAndroid Build Coastguard Worker    deps = [
106*61c4878aSAndroid Build Coastguard Worker        ":core",
107*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
108*61c4878aSAndroid Build Coastguard Worker        "//pw_bytes",
109*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
110*61c4878aSAndroid Build Coastguard Worker        "//pw_result",
111*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:internal_packet_pwpb",
112*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:server_api",
113*61c4878aSAndroid Build Coastguard Worker        "//pw_status",
114*61c4878aSAndroid Build Coastguard Worker        "//pw_stream",
115*61c4878aSAndroid Build Coastguard Worker    ],
116*61c4878aSAndroid Build Coastguard Worker)
117*61c4878aSAndroid Build Coastguard Worker
118*61c4878aSAndroid Build Coastguard Workercc_library(
119*61c4878aSAndroid Build Coastguard Worker    name = "client",
120*61c4878aSAndroid Build Coastguard Worker    srcs = [
121*61c4878aSAndroid Build Coastguard Worker        "client.cc",
122*61c4878aSAndroid Build Coastguard Worker    ],
123*61c4878aSAndroid Build Coastguard Worker    hdrs = [
124*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/client.h",
125*61c4878aSAndroid Build Coastguard Worker    ],
126*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
127*61c4878aSAndroid Build Coastguard Worker    deps = [
128*61c4878aSAndroid Build Coastguard Worker        ":core",
129*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
130*61c4878aSAndroid Build Coastguard Worker        "//pw_function",
131*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
132*61c4878aSAndroid Build Coastguard Worker        "//pw_stream",
133*61c4878aSAndroid Build Coastguard Worker    ],
134*61c4878aSAndroid Build Coastguard Worker)
135*61c4878aSAndroid Build Coastguard Worker
136*61c4878aSAndroid Build Coastguard Workercc_library(
137*61c4878aSAndroid Build Coastguard Worker    name = "atomic_file_transfer_handler",
138*61c4878aSAndroid Build Coastguard Worker    srcs = ["atomic_file_transfer_handler.cc"],
139*61c4878aSAndroid Build Coastguard Worker    hdrs = [
140*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/atomic_file_transfer_handler.h",
141*61c4878aSAndroid Build Coastguard Worker    ],
142*61c4878aSAndroid Build Coastguard Worker    strip_include_prefix = "public",
143*61c4878aSAndroid Build Coastguard Worker    deps = [
144*61c4878aSAndroid Build Coastguard Worker        ":atomic_file_transfer_handler_internal",
145*61c4878aSAndroid Build Coastguard Worker        ":core",
146*61c4878aSAndroid Build Coastguard Worker        "//pw_log",
147*61c4878aSAndroid Build Coastguard Worker        "//pw_stream:std_file_stream",
148*61c4878aSAndroid Build Coastguard Worker    ],
149*61c4878aSAndroid Build Coastguard Worker)
150*61c4878aSAndroid Build Coastguard Worker
151*61c4878aSAndroid Build Coastguard Workercc_library(
152*61c4878aSAndroid Build Coastguard Worker    name = "atomic_file_transfer_handler_internal",
153*61c4878aSAndroid Build Coastguard Worker    srcs = [
154*61c4878aSAndroid Build Coastguard Worker        "pw_transfer_private/filename_generator.h",
155*61c4878aSAndroid Build Coastguard Worker    ],
156*61c4878aSAndroid Build Coastguard Worker)
157*61c4878aSAndroid Build Coastguard Worker
158*61c4878aSAndroid Build Coastguard Workercc_library(
159*61c4878aSAndroid Build Coastguard Worker    name = "test_helpers",
160*61c4878aSAndroid Build Coastguard Worker    srcs = [
161*61c4878aSAndroid Build Coastguard Worker        "pw_transfer_private/chunk_testing.h",
162*61c4878aSAndroid Build Coastguard Worker    ],
163*61c4878aSAndroid Build Coastguard Worker    deps = [
164*61c4878aSAndroid Build Coastguard Worker        ":core",
165*61c4878aSAndroid Build Coastguard Worker        "//pw_containers",
166*61c4878aSAndroid Build Coastguard Worker    ],
167*61c4878aSAndroid Build Coastguard Worker)
168*61c4878aSAndroid Build Coastguard Worker
169*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
170*61c4878aSAndroid Build Coastguard Worker    name = "chunk_test",
171*61c4878aSAndroid Build Coastguard Worker    srcs = ["chunk_test.cc"],
172*61c4878aSAndroid Build Coastguard Worker    deps = [
173*61c4878aSAndroid Build Coastguard Worker        ":core",
174*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
175*61c4878aSAndroid Build Coastguard Worker    ],
176*61c4878aSAndroid Build Coastguard Worker)
177*61c4878aSAndroid Build Coastguard Worker
178*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
179*61c4878aSAndroid Build Coastguard Worker    name = "handler_test",
180*61c4878aSAndroid Build Coastguard Worker    srcs = ["handler_test.cc"],
181*61c4878aSAndroid Build Coastguard Worker    # TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
182*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select(hosts_lin_mac),
183*61c4878aSAndroid Build Coastguard Worker    deps = [
184*61c4878aSAndroid Build Coastguard Worker        ":pw_transfer",
185*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
186*61c4878aSAndroid Build Coastguard Worker    ],
187*61c4878aSAndroid Build Coastguard Worker)
188*61c4878aSAndroid Build Coastguard Worker
189*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
190*61c4878aSAndroid Build Coastguard Worker    name = "atomic_file_transfer_handler_test",
191*61c4878aSAndroid Build Coastguard Worker    srcs = ["atomic_file_transfer_handler_test.cc"],
192*61c4878aSAndroid Build Coastguard Worker    # TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
193*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select(hosts_lin_mac),
194*61c4878aSAndroid Build Coastguard Worker    deps = [
195*61c4878aSAndroid Build Coastguard Worker        ":atomic_file_transfer_handler",
196*61c4878aSAndroid Build Coastguard Worker        ":atomic_file_transfer_handler_internal",
197*61c4878aSAndroid Build Coastguard Worker        ":pw_transfer",
198*61c4878aSAndroid Build Coastguard Worker        "//pw_random",
199*61c4878aSAndroid Build Coastguard Worker        "//pw_string",
200*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
201*61c4878aSAndroid Build Coastguard Worker    ],
202*61c4878aSAndroid Build Coastguard Worker)
203*61c4878aSAndroid Build Coastguard Worker
204*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
205*61c4878aSAndroid Build Coastguard Worker    name = "transfer_thread_test",
206*61c4878aSAndroid Build Coastguard Worker    srcs = ["transfer_thread_test.cc"],
207*61c4878aSAndroid Build Coastguard Worker    # TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
208*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select(hosts_lin_mac),
209*61c4878aSAndroid Build Coastguard Worker    deps = [
210*61c4878aSAndroid Build Coastguard Worker        ":pw_transfer",
211*61c4878aSAndroid Build Coastguard Worker        ":test_helpers",
212*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:test_helpers",
213*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:client_testing",
214*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:test_method_context",
215*61c4878aSAndroid Build Coastguard Worker        "//pw_thread:thread",
216*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
217*61c4878aSAndroid Build Coastguard Worker    ],
218*61c4878aSAndroid Build Coastguard Worker)
219*61c4878aSAndroid Build Coastguard Worker
220*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
221*61c4878aSAndroid Build Coastguard Worker    name = "transfer_test",
222*61c4878aSAndroid Build Coastguard Worker    srcs = ["transfer_test.cc"],
223*61c4878aSAndroid Build Coastguard Worker    # TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
224*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select(hosts_lin_mac),
225*61c4878aSAndroid Build Coastguard Worker    deps = [
226*61c4878aSAndroid Build Coastguard Worker        ":pw_transfer",
227*61c4878aSAndroid Build Coastguard Worker        ":test_helpers",
228*61c4878aSAndroid Build Coastguard Worker        "//pw_assert",
229*61c4878aSAndroid Build Coastguard Worker        "//pw_containers",
230*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:test_helpers",
231*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:test_method_context",
232*61c4878aSAndroid Build Coastguard Worker        "//pw_thread:thread",
233*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
234*61c4878aSAndroid Build Coastguard Worker    ],
235*61c4878aSAndroid Build Coastguard Worker)
236*61c4878aSAndroid Build Coastguard Worker
237*61c4878aSAndroid Build Coastguard Workerpw_cc_test(
238*61c4878aSAndroid Build Coastguard Worker    name = "client_test",
239*61c4878aSAndroid Build Coastguard Worker    srcs = ["client_test.cc"],
240*61c4878aSAndroid Build Coastguard Worker    # TODO: b/235345886 - Fix transfer tests on Windows and non-host builds.
241*61c4878aSAndroid Build Coastguard Worker    target_compatible_with = select(hosts_lin_mac),
242*61c4878aSAndroid Build Coastguard Worker    deps = [
243*61c4878aSAndroid Build Coastguard Worker        ":client",
244*61c4878aSAndroid Build Coastguard Worker        ":test_helpers",
245*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc:test_helpers",
246*61c4878aSAndroid Build Coastguard Worker        "//pw_rpc/raw:client_testing",
247*61c4878aSAndroid Build Coastguard Worker        "//pw_thread:sleep",
248*61c4878aSAndroid Build Coastguard Worker        "//pw_thread:thread",
249*61c4878aSAndroid Build Coastguard Worker        "//pw_unit_test",
250*61c4878aSAndroid Build Coastguard Worker    ],
251*61c4878aSAndroid Build Coastguard Worker)
252*61c4878aSAndroid Build Coastguard Worker
253*61c4878aSAndroid Build Coastguard Workerproto_library(
254*61c4878aSAndroid Build Coastguard Worker    name = "transfer_proto",
255*61c4878aSAndroid Build Coastguard Worker    srcs = [
256*61c4878aSAndroid Build Coastguard Worker        "transfer.proto",
257*61c4878aSAndroid Build Coastguard Worker    ],
258*61c4878aSAndroid Build Coastguard Worker)
259*61c4878aSAndroid Build Coastguard Worker
260*61c4878aSAndroid Build Coastguard Workerpwpb_proto_library(
261*61c4878aSAndroid Build Coastguard Worker    name = "transfer_pwpb",
262*61c4878aSAndroid Build Coastguard Worker    deps = [":transfer_proto"],
263*61c4878aSAndroid Build Coastguard Worker)
264*61c4878aSAndroid Build Coastguard Worker
265*61c4878aSAndroid Build Coastguard Workerraw_rpc_proto_library(
266*61c4878aSAndroid Build Coastguard Worker    name = "transfer_raw_rpc",
267*61c4878aSAndroid Build Coastguard Worker    deps = [":transfer_proto"],
268*61c4878aSAndroid Build Coastguard Worker)
269*61c4878aSAndroid Build Coastguard Worker
270*61c4878aSAndroid Build Coastguard Workerpy_proto_library(
271*61c4878aSAndroid Build Coastguard Worker    name = "transfer_proto_pb2",
272*61c4878aSAndroid Build Coastguard Worker    deps = [":transfer_proto"],
273*61c4878aSAndroid Build Coastguard Worker)
274*61c4878aSAndroid Build Coastguard Worker
275*61c4878aSAndroid Build Coastguard Workerjava_proto_library(
276*61c4878aSAndroid Build Coastguard Worker    name = "transfer_proto_java",
277*61c4878aSAndroid Build Coastguard Worker    deps = [":transfer_proto"],
278*61c4878aSAndroid Build Coastguard Worker)
279*61c4878aSAndroid Build Coastguard Worker
280*61c4878aSAndroid Build Coastguard Workerjava_lite_proto_library(
281*61c4878aSAndroid Build Coastguard Worker    name = "transfer_proto_java_lite",
282*61c4878aSAndroid Build Coastguard Worker    deps = [":transfer_proto"],
283*61c4878aSAndroid Build Coastguard Worker)
284*61c4878aSAndroid Build Coastguard Worker
285*61c4878aSAndroid Build Coastguard Workerfilegroup(
286*61c4878aSAndroid Build Coastguard Worker    name = "doxygen",
287*61c4878aSAndroid Build Coastguard Worker    srcs = [
288*61c4878aSAndroid Build Coastguard Worker        "public/pw_transfer/atomic_file_transfer_handler.h",
289*61c4878aSAndroid Build Coastguard Worker    ],
290*61c4878aSAndroid Build Coastguard Worker)
291