xref: /aosp_15_r20/external/pigweed/pw_transfer/CMakeLists.txt (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2020 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
15include($ENV{PW_ROOT}/pw_build/pigweed.cmake)
16include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake)
17
18pw_add_module_config(pw_transfer_CONFIG)
19
20pw_add_library(pw_transfer.config INTERFACE
21  PUBLIC_DEPS
22    ${pw_transfer_CONFIG}
23    pw_chrono.system_timer
24  HEADERS
25    public/pw_transfer/internal/config.h
26  PUBLIC_INCLUDES
27    public
28)
29
30pw_add_library(pw_transfer STATIC
31  HEADERS
32    public/pw_transfer/transfer.h
33  PUBLIC_INCLUDES
34    public
35  SOURCES
36    transfer.cc
37  PUBLIC_DEPS
38    pw_assert
39    pw_bytes
40    pw_result
41    pw_status
42    pw_stream
43    pw_sync.mutex
44    pw_transfer.core
45    pw_transfer.proto.raw_rpc
46  PRIVATE_DEPS
47    pw_log
48    pw_log.rate_limited
49    pw_transfer.proto.pwpb
50)
51
52pw_add_library(pw_transfer.client STATIC
53  HEADERS
54    public/pw_transfer/client.h
55  PUBLIC_INCLUDES
56    public
57  SOURCES
58    client.cc
59  PUBLIC_DEPS
60    pw_assert
61    pw_function
62    pw_stream
63    pw_transfer.core
64    pw_transfer.proto.raw_rpc
65  PRIVATE_DEPS
66    pw_log
67)
68
69pw_add_library(pw_transfer.core STATIC
70  PUBLIC_DEPS
71    pw_bytes
72    pw_chrono.system_clock
73    pw_containers.intrusive_list
74    pw_result
75    pw_rpc.client
76    pw_rpc.raw.client_api
77    pw_rpc.raw.server_api
78    pw_status
79    pw_stream
80    pw_sync.binary_semaphore
81    pw_sync.timed_thread_notification
82    pw_thread.thread_core
83    pw_transfer.config
84    pw_transfer.proto.pwpb
85  HEADERS
86    public/pw_transfer/internal/chunk.h
87    public/pw_transfer/internal/client_context.h
88    public/pw_transfer/internal/context.h
89    public/pw_transfer/internal/event.h
90    public/pw_transfer/internal/protocol.h
91    public/pw_transfer/internal/server_context.h
92  SOURCES
93    chunk.cc
94    client_context.cc
95    context.cc
96    rate_estimate.cc
97    server_context.cc
98    transfer_thread.cc
99  PRIVATE_DEPS
100    pw_log
101    pw_log.rate_limited
102    pw_protobuf
103    pw_varint
104)
105
106pw_proto_library(pw_transfer.proto
107  SOURCES
108    transfer.proto
109  PREFIX
110    pw_transfer
111)
112
113pw_add_library(pw_transfer.test_helpers INTERFACE
114  HEADERS
115    pw_transfer_private/chunk_testing.h
116  PUBLIC_DEPS
117    pw_transfer.core
118    pw_containers
119)
120
121pw_add_library(pw_transfer.atomic_file_transfer_handler STATIC
122  PUBLIC_INCLUDES
123    public
124  HEADERS
125    public/pw_transfer/atomic_file_transfer_handler.h
126  SOURCES
127    atomic_file_transfer_handler.cc
128  PUBLIC_DEPS
129    pw_transfer.core
130    pw_stream.std_file_stream
131  PRIVATE_DEPS
132    pw_transfer.atomic_file_transfer_handler_internal
133    pw_log
134)
135
136pw_add_library(pw_transfer.atomic_file_transfer_handler_internal INTERFACE
137  HEADERS
138    pw_transfer_private/filename_generator.h
139)
140
141if("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread")
142  pw_add_test(pw_transfer.client_test
143    SOURCES
144      client_test.cc
145    PRIVATE_DEPS
146      pw_rpc.raw.client_testing
147      pw_rpc.test_helpers
148      pw_thread.sleep
149      pw_thread.thread
150      pw_transfer.client
151      pw_transfer.test_helpers
152    GROUPS
153      modules
154      pw_transfer
155  )
156endif()
157
158if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND
159   (${pw_unit_test_BACKEND} STREQUAL "pw_unit_test.light"))
160  pw_add_test(pw_transfer.transfer_thread_test
161    SOURCES
162      transfer_thread_test.cc
163    PRIVATE_DEPS
164      pw_transfer.proto.raw_rpc
165      pw_transfer.core
166      pw_transfer
167      pw_transfer.test_helpers
168      pw_rpc.test_helpers
169      pw_rpc.raw.client_testing
170      pw_rpc.raw.test_method_context
171      pw_thread.thread
172    GROUPS
173      modules
174      pw_transfer
175  )
176endif()
177
178if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND
179   (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows"))
180  pw_add_test(pw_transfer.chunk_test
181    SOURCES
182      chunk_test.cc
183    PRIVATE_DEPS
184      pw_transfer.core
185    GROUPS
186      modules
187      pw_transfer
188  )
189
190  pw_add_test(pw_transfer.handler_test
191    SOURCES
192      handler_test.cc
193    PRIVATE_DEPS
194      pw_transfer
195    GROUPS
196      modules
197      pw_transfer
198  )
199
200  pw_add_test(pw_transfer.atomic_file_transfer_handler_test
201    SOURCES
202      atomic_file_transfer_handler_test.cc
203    PRIVATE_DEPS
204      pw_transfer.atomic_file_transfer_handler
205      pw_transfer.atomic_file_transfer_handler_internal
206      pw_transfer
207      pw_random
208      pw_string
209    GROUPS
210      modules
211      pw_transfer
212  )
213endif()
214