diff --git a/CMakeLists.txt b/CMakeLists.txt index 843b12ac94..2fe8936165 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,6 +79,7 @@ add_subdirectory(pw_async EXCLUDE_FROM_ALL) add_subdirectory(pw_async_basic EXCLUDE_FROM_ALL) add_subdirectory(pw_async2 EXCLUDE_FROM_ALL) add_subdirectory(pw_async2_basic EXCLUDE_FROM_ALL) +add_subdirectory(pw_async2_epoll EXCLUDE_FROM_ALL) add_subdirectory(pw_async_fuchsia EXCLUDE_FROM_ALL) add_subdirectory(pw_base64 EXCLUDE_FROM_ALL) add_subdirectory(pw_blob_store EXCLUDE_FROM_ALL) @@ -175,6 +176,13 @@ add_subdirectory(third_party/fuzztest EXCLUDE_FROM_ALL) add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL) add_subdirectory(third_party/boringssl EXCLUDE_FROM_ALL) +add_custom_target(pw_apps) + +# pw_system example apps +add_subdirectory(targets/host_device_simulator EXCLUDE_FROM_ALL) +add_dependencies(pw_apps pw_system.system_example) +add_dependencies(pw_apps pw_system.system_async_host_example) + if(CONFIG_ZEPHYR_PIGWEED_MODULE) add_subdirectory(zephyr) if(CONFIG_PIGWEED_MINIMAL_CPP_STDLIB) @@ -184,6 +192,5 @@ if(CONFIG_ZEPHYR_PIGWEED_MODULE) else() add_subdirectory(targets/host EXCLUDE_FROM_ALL) - add_custom_target(pw_apps) add_dependencies(pw_apps pw_hdlc.rpc_example) endif() diff --git a/pw_async2_epoll/CMakeLists.txt b/pw_async2_epoll/CMakeLists.txt index c8dc2845c7..63ae2dc621 100644 --- a/pw_async2_epoll/CMakeLists.txt +++ b/pw_async2_epoll/CMakeLists.txt @@ -14,7 +14,7 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) -pw_add_library(pw_async2_basic.dispatcher_backend STATIC +pw_add_library(pw_async2_epoll.dispatcher_backend STATIC HEADERS public_overrides/pw_async2/dispatcher_native.h SOURCES diff --git a/pw_channel/CMakeLists.txt b/pw_channel/CMakeLists.txt index 0dfe224fd0..1ed0005705 100644 --- a/pw_channel/CMakeLists.txt +++ b/pw_channel/CMakeLists.txt @@ -15,7 +15,7 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) include($ENV{PW_ROOT}/pw_async2/backend.cmake) -pw_add_library(pw_channel INTERFACE +pw_add_library(pw_channel STATIC HEADERS public/pw_channel/channel.h PUBLIC_DEPS @@ -31,6 +31,8 @@ pw_add_library(pw_channel INTERFACE pw_toolchain._sibling_cast PUBLIC_INCLUDES public + SOURCES + public/pw_channel/internal/channel_specializations.h ) pw_add_test(pw_channel.channel_test @@ -95,8 +97,11 @@ pw_add_library(pw_channel.epoll_channel STATIC PUBLIC_DEPS pw_channel pw_multibuf.allocator + pw_sync.mutex PUBLIC_INCLUDES public + PRIVATE_DEPS + pw_log ) pw_add_test(pw_channel.epoll_channel_test diff --git a/pw_file/CMakeLists.txt b/pw_file/CMakeLists.txt index 671f340560..b6f95bff57 100644 --- a/pw_file/CMakeLists.txt +++ b/pw_file/CMakeLists.txt @@ -15,19 +15,22 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) -pw_add_library(pw_file.flat_file_system INTERFACE +pw_add_library(pw_file.flat_file_system STATIC + HEADERS + public/pw_file/flat_file_system.h PUBLIC_INCLUDES public PUBLIC_DEPS - pw_file.proto.pwpb - pw_file.proto.raw_rpc pw_assert pw_bytes + pw_file.proto.pwpb + pw_file.proto.raw_rpc pw_log pw_result + pw_span pw_status - PRIVATE_DEPS - pw_rpc.test_utils + SOURCES + flat_file_system.cc ) pw_proto_library(pw_file.proto @@ -38,3 +41,18 @@ pw_proto_library(pw_file.proto PREFIX pw_file ) + +pw_add_test(pw_file.flat_file_system_test + SOURCES + flat_file_system_test.cc + PRIVATE_DEPS + pw_bytes + pw_file.flat_file_system + pw_file.proto.pwpb + pw_protobuf + pw_rpc.raw.test_method_context + pw_status + GROUPS + modules + pw_file +) diff --git a/pw_sensor/CMakeLists.txt b/pw_sensor/CMakeLists.txt index af31913b2b..8191bc1b54 100644 --- a/pw_sensor/CMakeLists.txt +++ b/pw_sensor/CMakeLists.txt @@ -51,6 +51,7 @@ pw_add_library(pw_sensor INTERFACE pw_tokenizer ) +# This test does not run on CMake due to missing pw_sensor_library function. pw_add_test(pw_sensor.constants_test SOURCES attributes_test.cc diff --git a/pw_system/CMakeLists.txt b/pw_system/CMakeLists.txt index b1544c56be..b1e7f71f14 100644 --- a/pw_system/CMakeLists.txt +++ b/pw_system/CMakeLists.txt @@ -14,17 +14,29 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) include($ENV{PW_ROOT}/pw_system/backend.cmake) +include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) # WARNING: Many of the dependencies in this file are missing and need to be # added/updated. This is provided as a starting point, but currently does not # work. -pw_add_library(pw_system.config INTERFACE - HEADERS - public/pw_system/config.h - PUBLIC_INCLUDES - public -) +if("${pw_cpu_exception.entry_BACKEND}" STREQUAL "") + pw_add_library(pw_system.config INTERFACE + HEADERS + public/pw_system/config.h + PUBLIC_INCLUDES + public + PUBLIC_DEFINES + PW_SYSTEM_ENABLE_CRASH_HANDLER=0 + ) +else() + pw_add_library(pw_system.config INTERFACE + HEADERS + public/pw_system/config.h + PUBLIC_INCLUDES + public + ) +endif() pw_add_library(pw_system.log STATIC PUBLIC_DEPS @@ -71,6 +83,7 @@ pw_add_facade(pw_system.rpc_server INTERFACE PUBLIC_INCLUDES public PUBLIC_DEPS + pw_rpc.server pw_system.config pw_thread.thread_core ) @@ -87,6 +100,7 @@ pw_add_library(pw_system.hdlc_rpc_server STATIC pw_system.sys_io_target_io pw_thread.thread_core pw_trace + pw_log SOURCES hdlc_rpc_server.cc ) @@ -169,7 +183,9 @@ pw_add_library(pw_system.trace_service STATIC trace_service.cc ) -pw_add_library(pw_system.io INTERFACE +pw_add_facade(pw_system.io INTERFACE + BACKEND + pw_system.io_BACKEND HEADERS public/pw_system/io.h PUBLIC_INCLUDES @@ -178,6 +194,55 @@ pw_add_library(pw_system.io INTERFACE pw_stream ) +pw_add_facade(pw_system.device_handler INTERFACE + BACKEND + pw_system.device_handler_BACKEND + HEADERS + public/pw_system/device_handler.h + PUBLIC_INCLUDES + public + PUBLIC_DEPS + pw_snapshot.snapshot_proto.pwpb +) + +pw_add_library(pw_system.unknown_device_handler STATIC + SOURCES + unknown_device_handler.cc + PRIVATE_DEPS + pw_system.device_handler.facade +) + +pw_proto_library(pw_system.device_service_proto + SOURCES + pw_system_protos/device_service.proto + INPUTS + pw_system_protos/device_service.options +) + +pw_add_library(pw_system.device_service_pwpb STATIC + HEADERS + public/pw_system/device_service_pwpb.h + PUBLIC_INCLUDES + public + SOURCES + device_service_pwpb.cc + PUBLIC_DEPS + pw_system.device_service_proto.pwpb_rpc + PRIVATE_DEPS + pw_system.device_handler +) + +pw_add_library(pw_system.device_service STATIC + HEADERS + public/pw_system/device_service.h + PUBLIC_INCLUDES + public + SOURCES + device_service.cc + PRIVATE_DEPS + pw_system.device_service_pwpb +) + pw_add_library(pw_system.init STATIC HEADERS public/pw_system/init.h @@ -186,17 +251,19 @@ pw_add_library(pw_system.init STATIC SOURCES init.cc PRIVATE_DEPS + pw_system.device_service + pw_system.file_manager pw_system.file_service pw_system.log pw_system.rpc_server - pw_system.target_hooks + pw_system.target_hooks.facade pw_system.thread_snapshot_service pw_system.trace_service pw_system.transfer_service - pw_system.file_manager pw_system.work_queue - pw_rpc.pwpb.echo_service + pw_metric.global pw_metric.metric_service_pwpb + pw_rpc.pwpb.echo_service pw_thread.thread pw_trace ) @@ -216,13 +283,24 @@ pw_add_library(pw_system.work_queue STATIC pw_add_library(pw_system.sys_io_target_io STATIC PRIVATE_DEPS - pw_system.io + pw_system.io.facade pw_stream pw_stream.sys_io_stream SOURCES sys_io_target_io.cc ) +pw_add_library(pw_system.socket_target_io STATIC + SOURCES + socket_target_io.cc + PRIVATE_DEPS + pw_assert + pw_stream + pw_stream.socket_stream + pw_system.config + pw_system.io.facade +) + pw_add_facade(pw_system.target_hooks INTERFACE BACKEND pw_system.target_hooks_BACKEND @@ -264,13 +342,125 @@ pw_add_library(pw_system.zephyr_target_hooks STATIC pw_thread_zephyr.thread ) -pw_add_library(pw_system.system_example STATIC - PRIVATE_DEPS +add_executable(pw_system.system_example EXCLUDE_FROM_ALL + example_user_app_init.cc +) +target_link_libraries(pw_system.system_example + PRIVATE pw_system.init pw_system.io + pw_system.log + pw_system.rpc_server + pw_system.work_queue + pw_log + pw_thread.sleep + pw_trace + pw_unit_test.rpc_service pw_system.target_hooks - pw_stream - pw_stream.sys_io_stream + targets.host_device_simulator.boot +) + +pw_add_library(pw_system.async STATIC + HEADERS + public/pw_system/system.h + PUBLIC_INCLUDES + public SOURCES - example_user_app_init.cc + pw_system_private/threads.h + system.cc + threads.cc + PUBLIC_DEPS + pw_allocator.allocator + pw_async2.dispatcher + pw_channel + pw_rpc.server + PRIVATE_DEPS + pw_system.async_packet_io + pw_system.file_manager + pw_system.file_service + pw_system.log + pw_system.thread_snapshot_service + pw_system.transfer_service + pw_system.work_queue + pw_allocator.best_fit_block_allocator + pw_allocator.synchronized_allocator + pw_async2.allocate_task + pw_async2.pend_func_task + pw_hdlc.router + pw_multibuf.simple_allocator + pw_rpc.pwpb.echo_service + pw_sync.interrupt_spin_lock + pw_thread.thread +) + +pw_add_library(pw_system.async_packet_io STATIC + HEADERS + public/pw_system/internal/async_packet_io.h + PUBLIC_INCLUDES + public + SOURCES + async_packet_io.cc + PUBLIC_DEPS + pw_async2.dispatcher + pw_channel.forwarding_channel + pw_containers.inline_var_len_entry_queue + pw_hdlc.router + pw_multibuf.simple_allocator + pw_rpc.server + pw_sync.lock_annotations + pw_sync.mutex + pw_sync.thread_notification + pw_thread.thread + pw_thread.thread_core + pw_allocator.allocator + pw_channel + pw_multibuf + PRIVATE_DEPS + pw_system.config + pw_assert + pw_log +) + +if((NOT "${pw_async2.dispatcher_BACKEND}" STREQUAL "") AND + (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")) + # TODO: b/317922402 - Run on Windows when thread detaching is supported. + pw_add_test(pw_system.async_packet_io_test + SOURCES + async_packet_io_test.cc + PRIVATE_DEPS + pw_system.async_packet_io + pw_allocator.testing + pw_channel.loopback_channel + pw_multibuf.testing + GROUPS + modules + pw_system + ) + + pw_add_test(pw_system.system_async_test + SOURCES + system_async_test.cc + PRIVATE_DEPS + pw_system.async + pw_allocator.testing + pw_channel.loopback_channel + pw_multibuf.testing + GROUPS + modules + pw_system + ) +endif() + + +add_executable(pw_system.system_async_host_example EXCLUDE_FROM_ALL + example_user_app_init.cc +) +target_link_libraries(pw_system.system_async_host_example + PRIVATE + pw_system.async + pw_channel.epoll_channel + pw_multibuf.testing + pw_trace + pw_unit_test.rpc_service + targets.host_device_simulator.boot ) diff --git a/pw_system/backend.cmake b/pw_system/backend.cmake index 297eaff6eb..a505bb648e 100644 --- a/pw_system/backend.cmake +++ b/pw_system/backend.cmake @@ -20,3 +20,9 @@ pw_add_backend_variable(pw_system.rpc_server_BACKEND) # The pw_system backend that provides the system target hooks. pw_add_backend_variable(pw_system.target_hooks_BACKEND) + +pw_add_backend_variable(pw_system.device_handler_BACKEND + DEFAULT_BACKEND + pw_system.unknown_device_handler +) +pw_add_backend_variable(pw_system.io_BACKEND) diff --git a/pw_thread/CMakeLists.txt b/pw_thread/CMakeLists.txt index 5b5f44cf58..50a67111ce 100644 --- a/pw_thread/CMakeLists.txt +++ b/pw_thread/CMakeLists.txt @@ -134,6 +134,7 @@ pw_add_library(pw_thread.thread_snapshot_service STATIC PUBLIC_INCLUDES public PUBLIC_DEPS + pw_log pw_protobuf pw_rpc.raw.server_api pw_span diff --git a/pw_thread_stl/CMakeLists.txt b/pw_thread_stl/CMakeLists.txt index e865a2ba1c..70d0650c86 100644 --- a/pw_thread_stl/CMakeLists.txt +++ b/pw_thread_stl/CMakeLists.txt @@ -92,6 +92,15 @@ pw_add_library(pw_thread_stl.test_threads STATIC pw_thread.thread ) +pw_add_library(pw_thread_stl.thread_iteration STATIC + PRIVATE_DEPS + pw_status + SOURCES + thread_iteration.cc + PUBLIC_DEPS + pw_thread.thread_iteration.facade +) + if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND (NOT "${pw_thread.sleep_BACKEND}" STREQUAL "")) pw_add_test(pw_thread_stl.thread_backend_test diff --git a/pw_toolchain/host_clang/toolchain.cmake b/pw_toolchain/host_clang/toolchain.cmake index 7e5a065ab3..f9ab9522e6 100644 --- a/pw_toolchain/host_clang/toolchain.cmake +++ b/pw_toolchain/host_clang/toolchain.cmake @@ -24,8 +24,10 @@ include($ENV{PW_ROOT}/pw_perf_test/backend.cmake) include($ENV{PW_ROOT}/pw_rpc/system_server/backend.cmake) include($ENV{PW_ROOT}/pw_sync/backend.cmake) include($ENV{PW_ROOT}/pw_sys_io/backend.cmake) +include($ENV{PW_ROOT}/pw_system/backend.cmake) include($ENV{PW_ROOT}/pw_thread/backend.cmake) include($ENV{PW_ROOT}/pw_trace/backend.cmake) +include($ENV{PW_ROOT}/pw_trace_tokenized/backend.cmake) set(CMAKE_C_COMPILER clang) set(CMAKE_CXX_COMPILER clang++) @@ -37,7 +39,7 @@ pw_set_backend(pw_assert.check pw_assert.print_and_abort_check_backend) pw_set_backend(pw_assert.assert pw_assert.print_and_abort_assert_backend) # Configure backend for async dispatcher facade -pw_set_backend(pw_async2.dispatcher pw_async2_basic.dispatcher_backend) +pw_set_backend(pw_async2.dispatcher pw_async2_epoll.dispatcher_backend) # Configure backend for logging facade. pw_set_backend(pw_log pw_log_basic) @@ -74,9 +76,17 @@ pw_set_backend(pw_thread.yield pw_thread_stl.yield) pw_set_backend(pw_thread.sleep pw_thread_stl.sleep) pw_set_backend(pw_thread.thread pw_thread_stl.thread) pw_set_backend(pw_thread.test_thread_context pw_thread_stl.test_thread_context) +pw_set_backend(pw_thread.thread_iteration pw_thread_stl.thread_iteration) -# TODO(ewout): Migrate this to match GN's tokenized trace setup. -pw_set_backend(pw_trace pw_trace.null) +# Configure backends for pw_system +pw_set_backend(pw_system.target_hooks pw_system.stl_target_hooks) +pw_set_backend(pw_system.rpc_server pw_system.hdlc_rpc_server) +pw_set_backend(pw_system.io pw_system.sys_io_target_io) + +# Configure backends for pw_trace +pw_set_backend(pw_trace pw_trace_tokenized) +# Maybe this should just be a facade? +set(pw_trace_tokenizer_time pw_trace_tokenized.host_trace_time CACHE STRING "Tokenizer trace time implementation" FORCE) if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # The CIPD provided Clang/LLVM toolchain must link against the matched diff --git a/pw_toolchain/host_gcc/toolchain.cmake b/pw_toolchain/host_gcc/toolchain.cmake index 019c3ae95f..0f39140b61 100644 --- a/pw_toolchain/host_gcc/toolchain.cmake +++ b/pw_toolchain/host_gcc/toolchain.cmake @@ -17,14 +17,17 @@ include(${CMAKE_CURRENT_LIST_DIR}/../../pw_build/pigweed.cmake) include($ENV{PW_ROOT}/pw_assert/backend.cmake) +include($ENV{PW_ROOT}/pw_async2/backend.cmake) include($ENV{PW_ROOT}/pw_chrono/backend.cmake) include($ENV{PW_ROOT}/pw_log/backend.cmake) include($ENV{PW_ROOT}/pw_perf_test/backend.cmake) include($ENV{PW_ROOT}/pw_rpc/system_server/backend.cmake) include($ENV{PW_ROOT}/pw_sync/backend.cmake) include($ENV{PW_ROOT}/pw_sys_io/backend.cmake) +include($ENV{PW_ROOT}/pw_system/backend.cmake) include($ENV{PW_ROOT}/pw_thread/backend.cmake) include($ENV{PW_ROOT}/pw_trace/backend.cmake) +include($ENV{PW_ROOT}/pw_trace_tokenized/backend.cmake) set(CMAKE_C_COMPILER gcc) set(CMAKE_CXX_COMPILER g++) @@ -35,6 +38,9 @@ pw_add_global_compile_options(-std=c++20 LANGUAGES CXX) pw_set_backend(pw_assert.check pw_assert.print_and_abort_check_backend) pw_set_backend(pw_assert.assert pw_assert.print_and_abort_assert_backend) +# Configure backend for async dispatcher facade +pw_set_backend(pw_async2.dispatcher pw_async2_epoll.dispatcher_backend) + # Configure backend for logging facade. pw_set_backend(pw_log pw_log_basic) @@ -62,16 +68,25 @@ pw_set_backend(pw_chrono.system_clock pw_chrono_stl.system_clock) pw_set_backend(pw_chrono.system_timer pw_chrono_stl.system_timer) # Configure backend for pw_perf_test's facade. -pw_perf_test(pw_perf_test.timer pw_perf_test.chrono_timer) +pw_set_backend(pw_perf_test.TIMER_INTERFACE_BACKEND pw_perf_test.chrono_timer) # Configure backends for pw_thread's facades. pw_set_backend(pw_thread.id pw_thread_stl.id) pw_set_backend(pw_thread.yield pw_thread_stl.yield) pw_set_backend(pw_thread.sleep pw_thread_stl.sleep) pw_set_backend(pw_thread.thread pw_thread_stl.thread) +pw_set_backend(pw_thread.test_thread_context pw_thread_stl.test_thread_context) +pw_set_backend(pw_thread.thread_iteration pw_thread_stl.thread_iteration) + +# Configure backends for pw_system +pw_set_backend(pw_system.target_hooks pw_system.stl_target_hooks) +pw_set_backend(pw_system.rpc_server pw_system.hdlc_rpc_server) +pw_set_backend(pw_system.io pw_system.sys_io_target_io) -# TODO(ewout): Migrate this to match GN's tokenized trace setup. -pw_set_backend(pw_trace pw_trace.null) +# Configure backends for pw_trace +pw_set_backend(pw_trace pw_trace_tokenized) +# Maybe this should just be a facade? +set(pw_trace_tokenizer_time pw_trace_tokenized.host_trace_time CACHE STRING "Tokenizer trace time implementation" FORCE) set(pw_build_WARNINGS pw_build.strict_warnings pw_build.extra_strict_warnings CACHE STRING "" FORCE) diff --git a/pw_trace_tokenized/CMakeLists.txt b/pw_trace_tokenized/CMakeLists.txt index bc6268f900..7749f9a2d8 100644 --- a/pw_trace_tokenized/CMakeLists.txt +++ b/pw_trace_tokenized/CMakeLists.txt @@ -14,6 +14,7 @@ include($ENV{PW_ROOT}/pw_build/pigweed.cmake) include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) +include($ENV{PW_ROOT}/pw_trace_tokenized/backend.cmake) pw_add_module_config(pw_trace_tokenized_CONFIG) @@ -26,7 +27,21 @@ pw_add_library(pw_trace_tokenized.config INTERFACE ${pw_trace_CONFIG} ) -pw_add_library(pw_trace_tokenized STATIC +pw_add_library(pw_trace_tokenized.fake_trace_time STATIC + PRIVATE_DEPS + pw_trace_tokenized.config + SOURCES + fake_trace_time.cc +) + +pw_add_library(pw_trace_tokenized.host_trace_time STATIC + PRIVATE_DEPS + pw_trace_tokenized.config + SOURCES + host_trace_time.cc +) + +pw_add_library(pw_trace_tokenized.core STATIC HEADERS public/pw_trace_tokenized/internal/trace_tokenized_internal.h public/pw_trace_tokenized/trace_callback.h @@ -36,34 +51,65 @@ pw_add_library(pw_trace_tokenized STATIC public public_overrides PUBLIC_DEPS + pw_log pw_span pw_status pw_tokenizer - pw_trace_tokenized.config SOURCES trace.cc PRIVATE_DEPS + pw_trace_tokenized.config pw_assert - pw_log pw_ring_buffer pw_trace.facade pw_varint + ${pw_trace_tokenizer_time} ) +pw_add_library(pw_trace_tokenized INTERFACE + PUBLIC_DEPS + pw_trace_tokenized.core + pw_trace_tokenized.config + PUBLIC_INCLUDES + public + public_overrides + PRIVATE_DEPS + ${pw_trace_tokenizer_time} +) + +if(("${pw_trace_BACKEND}" STREQUAL "pw_trace_tokenized") AND + (NOT "${pw_trace_tokenizer_time}" STREQUAL "")) +pw_add_test(pw_trace_tokenized.trace_tokenized_test + SOURCES + trace_test.cc + PRIVATE_DEPS + pw_trace_tokenized.core + pw_trace + ${pw_trace_tokenizer_time} + GROUPS + modules + pw_trace_tokenized +) +endif() + pw_add_library(pw_trace_tokenized.trace_buffer STATIC + HEADERS + public/pw_trace_tokenized/trace_buffer.h + PUBLIC_INCLUDES + public SOURCES trace_buffer.cc PRIVATE_DEPS - pw_assert - pw_bytes - pw_log + pw_trace_tokenized.core PUBLIC_DEPS + pw_bytes pw_ring_buffer - pw_status pw_tokenizer - pw_trace_tokenized pw_trace_tokenized.config pw_varint + pw_span + PUBLIC_DEFINES + PW_TRACE_BUFFER_SIZE_BYTES=${pw_trace_tokenized_BUFFER_SIZE} ) pw_proto_library(pw_trace_tokenized.protos diff --git a/pw_trace_tokenized/backend.cmake b/pw_trace_tokenized/backend.cmake new file mode 100644 index 0000000000..f69f4b5d6b --- /dev/null +++ b/pw_trace_tokenized/backend.cmake @@ -0,0 +1,24 @@ +# Copyright 2024 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +include_guard(GLOBAL) + +include($ENV{PW_ROOT}/pw_build/pigweed.cmake) + +set(pw_trace_tokenizer_time "" + CACHE STRING + "Tokenizer trace time, gets included if provided") + +set(pw_trace_tokenized_BUFFER_SIZE "256" + CACHE STRING + "Trace buffer size in bytes. Set to 0 to disable.") diff --git a/pw_transfer/CMakeLists.txt b/pw_transfer/CMakeLists.txt index 9e79c369ae..d626d3483c 100644 --- a/pw_transfer/CMakeLists.txt +++ b/pw_transfer/CMakeLists.txt @@ -20,18 +20,27 @@ pw_add_module_config(pw_transfer_CONFIG) pw_add_library(pw_transfer.config INTERFACE PUBLIC_DEPS ${pw_transfer_CONFIG} + pw_chrono.system_timer HEADERS public/pw_transfer/internal/config.h PUBLIC_INCLUDES public ) -pw_add_library(pw_transfer INTERFACE +pw_add_library(pw_transfer STATIC + HEADERS + public/pw_transfer/transfer.h + PUBLIC_INCLUDES + public + SOURCES + transfer.cc PUBLIC_DEPS pw_assert + pw_bytes pw_result pw_status pw_stream + pw_sync.mutex pw_transfer.core pw_transfer.proto.raw_rpc PRIVATE_DEPS @@ -40,34 +49,57 @@ pw_add_library(pw_transfer INTERFACE pw_transfer.proto.pwpb ) -pw_add_library(pw_transfer.client INTERFACE +pw_add_library(pw_transfer.client STATIC + HEADERS + public/pw_transfer/client.h + PUBLIC_INCLUDES + public + SOURCES + client.cc PUBLIC_DEPS pw_assert pw_function pw_stream - pw_sync.mutex pw_transfer.core pw_transfer.proto.raw_rpc PRIVATE_DEPS pw_log - pw_transfer.proto.pwpb ) -pw_add_library(pw_transfer.core INTERFACE +pw_add_library(pw_transfer.core STATIC PUBLIC_DEPS pw_bytes pw_chrono.system_clock pw_containers.intrusive_list pw_result pw_rpc.client + pw_rpc.raw.client_api + pw_rpc.raw.server_api pw_status pw_stream pw_sync.binary_semaphore + pw_sync.timed_thread_notification pw_thread.thread_core pw_transfer.config + pw_transfer.proto.pwpb + HEADERS + public/pw_transfer/internal/chunk.h + public/pw_transfer/internal/client_context.h + public/pw_transfer/internal/context.h + public/pw_transfer/internal/event.h + public/pw_transfer/internal/protocol.h + public/pw_transfer/internal/server_context.h + SOURCES + chunk.cc + client_context.cc + context.cc + rate_estimate.cc + server_context.cc + transfer_thread.cc PRIVATE_DEPS + pw_log + pw_log.rate_limited pw_protobuf - pw_transfer.proto.pwpb pw_varint ) @@ -77,3 +109,105 @@ pw_proto_library(pw_transfer.proto PREFIX pw_transfer ) + +pw_add_library(pw_transfer.test_helpers INTERFACE + HEADERS + pw_transfer_private/chunk_testing.h + PUBLIC_DEPS + pw_transfer.core + pw_containers +) + +pw_add_library(pw_transfer.atomic_file_transfer_handler STATIC + PUBLIC_INCLUDES + public + HEADERS + public/pw_transfer/atomic_file_transfer_handler.h + SOURCES + atomic_file_transfer_handler.cc + PUBLIC_DEPS + pw_transfer.core + pw_stream.std_file_stream + PRIVATE_DEPS + pw_transfer.atomic_file_transfer_handler_internal + pw_log +) + +pw_add_library(pw_transfer.atomic_file_transfer_handler_internal INTERFACE + HEADERS + pw_transfer_private/filename_generator.h +) + +if("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") + pw_add_test(pw_transfer.client_test + SOURCES + client_test.cc + PRIVATE_DEPS + pw_rpc.raw.client_testing + pw_rpc.test_helpers + pw_thread.sleep + pw_thread.thread + pw_transfer.client + pw_transfer.test_helpers + GROUPS + modules + pw_transfer + ) +endif() + +if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND + (${pw_unit_test_BACKEND} STREQUAL "pw_unit_test.light")) + pw_add_test(pw_transfer.transfer_thread_test + SOURCES + transfer_thread_test.cc + PRIVATE_DEPS + pw_transfer.proto.raw_rpc + pw_transfer.core + pw_transfer + pw_transfer.test_helpers + pw_rpc.test_helpers + pw_rpc.raw.client_testing + pw_rpc.raw.test_method_context + pw_thread.thread + GROUPS + modules + pw_transfer + ) +endif() + +if(("${pw_thread.thread_BACKEND}" STREQUAL "pw_thread_stl.thread") AND + (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")) + pw_add_test(pw_transfer.chunk_test + SOURCES + chunk_test.cc + PRIVATE_DEPS + pw_transfer.core + GROUPS + modules + pw_transfer + ) + + pw_add_test(pw_transfer.handler_test + SOURCES + handler_test.cc + PRIVATE_DEPS + pw_transfer + GROUPS + modules + pw_transfer + ) + + pw_add_test(pw_transfer.atomic_file_transfer_handler_test + SOURCES + atomic_file_transfer_handler_test.cc + PRIVATE_DEPS + pw_transfer.atomic_file_transfer_handler + pw_transfer.atomic_file_transfer_handler_internal + pw_transfer + pw_random + pw_string + GROUPS + modules + pw_transfer + ) +endif() diff --git a/pw_unit_test/CMakeLists.txt b/pw_unit_test/CMakeLists.txt index 57acd59693..abb3c0baa9 100644 --- a/pw_unit_test/CMakeLists.txt +++ b/pw_unit_test/CMakeLists.txt @@ -13,6 +13,9 @@ # the License. include($ENV{PW_ROOT}/pw_build/pigweed.cmake) +include($ENV{PW_ROOT}/pw_protobuf_compiler/proto.cmake) + +include($ENV{PW_ROOT}/pw_unit_test/backend.cmake) pw_add_module_config(pw_unit_test_CONFIG) @@ -58,8 +61,10 @@ pw_add_library(pw_unit_test.light STATIC pw_bytes.alignment pw_polyfill pw_preprocessor - pw_string + pw_string.builder pw_unit_test.config + PRIVATE_DEPS + pw_assert PUBLIC_INCLUDES light_public_overrides public @@ -227,3 +232,53 @@ pw_add_test(pw_unit_test.test_record_event_handler_test GROUPS pw_unit_test ) + +pw_proto_library(pw_unit_test.unit_test_proto + SOURCES + pw_unit_test_proto/unit_test.proto +) + +if("${pw_unit_test_BACKEND}" STREQUAL "pw_unit_test.light") + pw_add_library(pw_unit_test.rpc_service STATIC + PUBLIC_DEPS + pw_unit_test.config + pw_unit_test.event_handler + pw_unit_test + pw_unit_test.unit_test_proto.pwpb + pw_unit_test.unit_test_proto.raw_rpc + pw_containers.vector + PRIVATE_DEPS + pw_log + PUBLIC_INCLUDES + public + rpc_light_public + HEADERS + public/pw_unit_test/unit_test_service.h + rpc_light_public/pw_unit_test/internal/rpc_event_handler.h + SOURCES + unit_test_service.cc + rpc_light_event_handler.cc + ) +else() + pw_add_library(pw_unit_test.rpc_service STATIC + PUBLIC_DEPS + pw_unit_test.config + pw_unit_test.event_handler + pw_unit_test + pw_unit_test.unit_test_proto.pwpb + pw_unit_test.unit_test_proto.raw_rpc + pw_containers.vector + PRIVATE_DEPS + pw_log + PUBLIC_INCLUDES + public + rpc_gtest_public + HEADERS + public/pw_unit_test/unit_test_service.h + rpc_light_public/pw_unit_test/internal/rpc_event_handler.h + rpc_gtest_public/pw_unit_test/internal/rpc_event_handler.h + SOURCES + unit_test_service.cc + rpc_gtest_event_handler.cc + ) +endif() diff --git a/pw_unit_test/backend.cmake b/pw_unit_test/backend.cmake new file mode 100644 index 0000000000..9859ed18db --- /dev/null +++ b/pw_unit_test/backend.cmake @@ -0,0 +1,24 @@ +# Copyright 2024 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. +include_guard(GLOBAL) + +include($ENV{PW_ROOT}/pw_build/pigweed.cmake) + +set(pw_unit_test_BACKEND ="pw_unit_test.light" + CACHE STRING + "The unit test framework implementation. Defaults to pw_unit_test.light, which implements a subset of GoogleTest safe to run on device.") + +set(pw_unit_test_MAIN "pw_unit_test.simple_printing_main" + CACHE STRING + "Implementation of a main function for ``pw_test`` unit test binaries. Must be set to an appropriate target for the pw_unit_test backend.") diff --git a/targets/host_device_simulator/CMakeLists.txt b/targets/host_device_simulator/CMakeLists.txt new file mode 100644 index 0000000000..89ba006888 --- /dev/null +++ b/targets/host_device_simulator/CMakeLists.txt @@ -0,0 +1,24 @@ +# Copyright 2024 The Pigweed Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not +# use this file except in compliance with the License. You may obtain a copy of +# the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +include($ENV{PW_ROOT}/pw_build/pigweed.cmake) + +pw_add_library(targets.host_device_simulator.boot STATIC + PRIVATE_DEPS + pw_log + pw_system.init + pw_thread.sleep + SOURCES + boot.cc +)