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/handler.h 87 public/pw_transfer/internal/chunk.h 88 public/pw_transfer/internal/client_context.h 89 public/pw_transfer/internal/context.h 90 public/pw_transfer/internal/event.h 91 public/pw_transfer/internal/protocol.h 92 public/pw_transfer/internal/server_context.h 93 public/pw_transfer/rate_estimate.h 94 public/pw_transfer/transfer_thread.h 95 PUBLIC_INCLUDES 96 public 97 SOURCES 98 chunk.cc 99 client_context.cc 100 context.cc 101 rate_estimate.cc 102 server_context.cc 103 transfer_thread.cc 104 PRIVATE_DEPS 105 pw_log 106 pw_log.rate_limited 107 pw_protobuf 108 pw_varint 109) 110 111pw_proto_library(pw_transfer.proto 112 SOURCES 113 transfer.proto 114 PREFIX 115 pw_transfer 116) 117 118pw_add_library(pw_transfer.test_helpers INTERFACE 119 HEADERS 120 pw_transfer_private/chunk_testing.h 121 PUBLIC_DEPS 122 pw_transfer.core 123 pw_containers 124) 125 126pw_add_library(pw_transfer.atomic_file_transfer_handler STATIC 127 PUBLIC_INCLUDES 128 public 129 HEADERS 130 public/pw_transfer/atomic_file_transfer_handler.h 131 SOURCES 132 atomic_file_transfer_handler.cc 133 PUBLIC_DEPS 134 pw_transfer.core 135 pw_stream.std_file_stream 136 PRIVATE_DEPS 137 pw_transfer.atomic_file_transfer_handler_internal 138 pw_log 139) 140 141pw_add_library(pw_transfer.atomic_file_transfer_handler_internal INTERFACE 142 HEADERS 143 pw_transfer_private/filename_generator.h 144) 145 146if("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") 147 pw_add_test(pw_transfer.client_test 148 SOURCES 149 client_test.cc 150 PRIVATE_DEPS 151 pw_rpc.raw.client_testing 152 pw_rpc.test_helpers 153 pw_thread.sleep 154 pw_thread.thread 155 pw_transfer.client 156 pw_transfer.test_helpers 157 GROUPS 158 modules 159 pw_transfer 160 ) 161endif() 162 163if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND 164 (${pw_unit_test_BACKEND} STREQUAL "pw_unit_test.light")) 165 pw_add_test(pw_transfer.transfer_thread_test 166 SOURCES 167 transfer_thread_test.cc 168 PRIVATE_DEPS 169 pw_transfer.proto.raw_rpc 170 pw_transfer.core 171 pw_transfer 172 pw_transfer.test_helpers 173 pw_rpc.test_helpers 174 pw_rpc.raw.client_testing 175 pw_rpc.raw.test_method_context 176 pw_thread.thread 177 GROUPS 178 modules 179 pw_transfer 180 ) 181endif() 182 183if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND 184 (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")) 185 pw_add_test(pw_transfer.chunk_test 186 SOURCES 187 chunk_test.cc 188 PRIVATE_DEPS 189 pw_transfer.core 190 GROUPS 191 modules 192 pw_transfer 193 ) 194 195 pw_add_test(pw_transfer.handler_test 196 SOURCES 197 handler_test.cc 198 PRIVATE_DEPS 199 pw_transfer 200 GROUPS 201 modules 202 pw_transfer 203 ) 204 205 pw_add_test(pw_transfer.atomic_file_transfer_handler_test 206 SOURCES 207 atomic_file_transfer_handler_test.cc 208 PRIVATE_DEPS 209 pw_transfer.atomic_file_transfer_handler 210 pw_transfer.atomic_file_transfer_handler_internal 211 pw_transfer 212 pw_random 213 pw_string 214 GROUPS 215 modules 216 pw_transfer 217 ) 218endif() 219