| # Copyright 2021 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. |
| |
| import("//build_overrides/pigweed.gni") |
| |
| import("$dir_pigweed/third_party/ambiq/ambiq.gni") |
| import("$dir_pigweed/third_party/freertos/freertos.gni") |
| import("$dir_pigweed/third_party/nanopb/nanopb.gni") |
| import("$dir_pigweed/third_party/pico_sdk/pi_pico.gni") |
| import("$dir_pigweed/third_party/smartfusion_mss/mss.gni") |
| import("$dir_pigweed/third_party/stm32cube/stm32cube.gni") |
| import("$dir_pw_async2/backend.gni") |
| import("$dir_pw_build/error.gni") |
| import("$dir_pw_build/facade.gni") |
| import("$dir_pw_build/module_config.gni") |
| import("$dir_pw_build/target_types.gni") |
| import("$dir_pw_cpu_exception/backend.gni") |
| import("$dir_pw_docgen/docs.gni") |
| import("$dir_pw_protobuf_compiler/proto.gni") |
| import("$dir_pw_unit_test/test.gni") |
| import("backend.gni") |
| |
| declare_args() { |
| # The build target that overrides the default configuration options for this |
| # module. This should point to a source set that provides defines through a |
| # public config (which may -include a file or add defines directly). |
| pw_system_CONFIG = pw_build_DEFAULT_MODULE_CONFIG |
| } |
| |
| config("public_include_path") { |
| include_dirs = [ "public" ] |
| } |
| |
| # This config moves RPC logging to a separate RPC channel and HDLC |
| # address. This does two things: |
| # * The separate RPC channel allows logging traffic to be treated as |
| # if it is being sent to a different client via a separate RPC |
| # channel. This illustrates the ability for an RPC server to |
| # communicate to multiple clients over multiple physical links. |
| # * The separate HDLC address completely isolates typical RPC traffic |
| # from logging traffic by communicating to a different HDLC endpoint |
| # address. This effectively creates two virtual data pipes over the |
| # same physical link. |
| # |
| # This is mostly to illustrate pw_rpc's capability to route and multiplex |
| # traffic. |
| config("multi_endpoint_rpc_overrides") { |
| defines = [ |
| "PW_SYSTEM_LOGGING_CHANNEL_ID=10000", |
| "PW_SYSTEM_LOGGING_RPC_HDLC_ADDRESS=10000", |
| ] |
| } |
| |
| config("pw_cpu_exception_config") { |
| # disable the crash handler entirely if the cpu exception backend has |
| # not been set. |
| if (pw_cpu_exception_ENTRY_BACKEND == "") { |
| defines = [ "PW_SYSTEM_ENABLE_CRASH_HANDLER=0" ] |
| } |
| } |
| |
| # The Pigweed config pattern requires a pw_source_set to provide the |
| # configuration defines. This provides the flags in |
| # multi_endpoint_rpc_overrides. |
| pw_source_set("multi_endpoint_rpc_config") { |
| public_configs = [ ":multi_endpoint_rpc_overrides" ] |
| } |
| |
| pw_source_set("config") { |
| sources = [ "public/pw_system/config.h" ] |
| public_configs = [ |
| ":public_include_path", |
| ":pw_cpu_exception_config", |
| ] |
| public_deps = [ pw_system_CONFIG ] |
| visibility = [ "./*" ] |
| } |
| |
| pw_source_set("log") { |
| public_configs = [ ":public_include_path" ] |
| sources = [ |
| "log.cc", |
| "pw_system_private/log.h", |
| ] |
| public_deps = [ |
| "$dir_pw_log_rpc:log_service", |
| "$dir_pw_log_rpc:rpc_log_drain_thread", |
| "$dir_pw_multisink", |
| ] |
| deps = [ |
| ":config", |
| "$dir_pw_log_rpc:rpc_log_drain", |
| "$dir_pw_sync:lock_annotations", |
| "$dir_pw_sync:mutex", |
| ] |
| } |
| |
| # There is no public part to this backend which does not cause circular |
| # dependencies, there is only the pw_build_LINK_DEPS "log_backend.impl". |
| pw_source_set("log_backend") { |
| } |
| |
| pw_source_set("log_backend.impl") { |
| sources = [ "log_backend.cc" ] |
| deps = [ |
| ":config", |
| ":log", |
| "$dir_pw_bytes", |
| "$dir_pw_chrono:system_clock", |
| "$dir_pw_log:proto_utils", |
| "$dir_pw_log:pw_log.facade", |
| "$dir_pw_log_string:handler.facade", |
| "$dir_pw_metric:global", |
| "$dir_pw_multisink", |
| "$dir_pw_result", |
| "$dir_pw_string", |
| "$dir_pw_sync:interrupt_spin_lock", |
| "$dir_pw_sync:lock_annotations", |
| "$dir_pw_tokenizer", |
| ] |
| } |
| |
| pw_facade("rpc_server") { |
| backend = pw_system_RPC_SERVER_BACKEND |
| public = [ "public/pw_system/rpc_server.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":config", |
| "$dir_pw_rpc:server", |
| "$dir_pw_thread:thread_core", |
| ] |
| } |
| |
| pw_facade("io") { |
| backend = pw_system_IO_BACKEND |
| public_configs = [ ":public_include_path" ] |
| public = [ "public/pw_system/io.h" ] |
| public_deps = [ "$dir_pw_stream" ] |
| } |
| |
| pw_facade("device_handler") { |
| backend = pw_system_DEVICE_HANDLER |
| public_configs = [ ":public_include_path" ] |
| public = [ "public/pw_system/device_handler.h" ] |
| public_deps = [ "$dir_pw_snapshot:snapshot_proto.pwpb" ] |
| } |
| |
| pw_source_set("unknown_device_handler") { |
| sources = [ "unknown_device_handler.cc" ] |
| deps = [ ":device_handler.facade" ] |
| } |
| |
| pw_source_set("init") { |
| public_configs = [ ":public_include_path" ] |
| public = [ "public/pw_system/init.h" ] |
| sources = [ "init.cc" ] |
| deps = [ |
| ":device_service", |
| ":file_manager", |
| ":file_service", |
| ":log", |
| ":rpc_server", |
| ":target_hooks.facade", |
| ":thread_snapshot_service", |
| ":trace_service", |
| ":transfer_service", |
| ":work_queue", |
| "$dir_pw_metric:global", |
| "$dir_pw_metric:metric_service_pwpb", |
| "$dir_pw_rpc/pwpb:echo_service", |
| "$dir_pw_thread:thread", |
| "$dir_pw_trace", |
| ] |
| if (pw_cpu_exception_ENTRY_BACKEND != "") { |
| deps += [ |
| ":crash_handler", |
| ":crash_snapshot", |
| ] |
| } |
| |
| # disable include checking, as there are conditional includes dependent on |
| # whether the pw_cpu_exception_ENTRY_BACKEND is set. |
| check_includes = false |
| } |
| |
| pw_source_set("hdlc_rpc_server") { |
| sources = [ "hdlc_rpc_server.cc" ] |
| deps = [ |
| ":config", |
| ":io", |
| ":rpc_server.facade", |
| "$dir_pw_assert", |
| "$dir_pw_hdlc:decoder", |
| "$dir_pw_hdlc:default_addresses", |
| "$dir_pw_hdlc:rpc_channel_output", |
| "$dir_pw_log", |
| "$dir_pw_sync:mutex", |
| "$dir_pw_trace", |
| ] |
| } |
| |
| pw_source_set("work_queue") { |
| public_configs = [ ":public_include_path" ] |
| public = [ "public/pw_system/work_queue.h" ] |
| sources = [ "work_queue.cc" ] |
| public_deps = [ "$dir_pw_work_queue" ] |
| deps = [ ":config" ] |
| } |
| |
| pw_source_set("sys_io_target_io") { |
| sources = [ "sys_io_target_io.cc" ] |
| deps = [ |
| ":io.facade", |
| "$dir_pw_stream", |
| "$dir_pw_stream:sys_io_stream", |
| ] |
| } |
| |
| pw_source_set("socket_target_io") { |
| sources = [ "socket_target_io.cc" ] |
| deps = [ |
| ":config", |
| ":io.facade", |
| "$dir_pw_assert", |
| "$dir_pw_stream", |
| "$dir_pw_stream:socket_stream", |
| ] |
| } |
| |
| pw_source_set("transfer_handlers") { |
| public = [ "public/pw_system/transfer_handlers.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":config", |
| "$dir_pw_persistent_ram", |
| "$dir_pw_trace_tokenized:config", |
| "$dir_pw_transfer", |
| ] |
| sources = [ "transfer_handlers.cc" ] |
| deps = [] |
| } |
| |
| pw_source_set("file_manager") { |
| public = [ "public/pw_system/file_manager.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":config", |
| ":transfer_handlers", |
| "$dir_pw_file:flat_file_system", |
| "$dir_pw_persistent_ram:flat_file_system_entry", |
| ] |
| sources = [ "file_manager.cc" ] |
| deps = [ ":trace_service" ] |
| if (pw_cpu_exception_ENTRY_BACKEND != "") { |
| deps += [ ":crash_snapshot" ] |
| } |
| |
| # disable include checking, as there are conditional includes dependent on |
| # whether the pw_cpu_exception_ENTRY_BACKEND is set. |
| check_includes = false |
| } |
| |
| pw_source_set("transfer_service") { |
| public = [ "public/pw_system/transfer_service.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ "$dir_pw_transfer" ] |
| sources = [ "transfer_service.cc" ] |
| deps = [ ":file_manager" ] |
| } |
| |
| pw_source_set("file_service") { |
| public = [ "public/pw_system/file_service.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [] |
| sources = [ "file_service.cc" ] |
| deps = [ ":file_manager" ] |
| } |
| |
| pw_source_set("trace_service") { |
| public = [ "public/pw_system/trace_service.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ ":transfer_handlers" ] |
| sources = [ "trace_service.cc" ] |
| deps = [ |
| "$dir_pw_persistent_ram", |
| "$dir_pw_trace_tokenized:trace_service_pwpb", |
| ] |
| } |
| |
| pw_source_set("crash_handler") { |
| public = [ "public/pw_system/crash_handler.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [] |
| sources = [ "crash_handler.cc" ] |
| deps = [ |
| ":crash_snapshot", |
| ":device_handler", |
| ":log", |
| "$dir_pw_assert_trap:message", |
| "$dir_pw_cpu_exception:handler", |
| ] |
| } |
| |
| pw_source_set("crash_snapshot") { |
| public = [ "public/pw_system/crash_snapshot.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ |
| ":transfer_handlers", |
| "$dir_pw_cpu_exception:entry", |
| "$dir_pw_persistent_ram", |
| "$dir_pw_snapshot:snapshot_proto.pwpb", |
| ] |
| sources = [ "crash_snapshot.cc" ] |
| deps = [ |
| ":device_handler", |
| ":log", |
| "$dir_pw_multisink:util", |
| "$dir_pw_snapshot:uuid", |
| ] |
| } |
| |
| pw_proto_library("device_service_proto") { |
| sources = [ "pw_system_protos/device_service.proto" ] |
| inputs = [ "pw_system_protos/device_service.options" ] |
| deps = [] |
| } |
| |
| pw_source_set("device_service_pwpb") { |
| public = [ "public/pw_system/device_service_pwpb.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [] |
| sources = [ "device_service_pwpb.cc" ] |
| public_deps = [ ":device_service_proto.pwpb_rpc" ] |
| deps = [ ":device_handler" ] |
| } |
| |
| pw_source_set("device_service") { |
| public = [ "public/pw_system/device_service.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [] |
| sources = [ "device_service.cc" ] |
| deps = [ ":device_service_pwpb" ] |
| } |
| |
| pw_source_set("thread_snapshot_service") { |
| public = [ "public/pw_system/thread_snapshot_service.h" ] |
| public_configs = [ ":public_include_path" ] |
| public_deps = [ "$dir_pw_rpc:server" ] |
| sources = [ "thread_snapshot_service.cc" ] |
| deps = [ "$dir_pw_thread:thread_snapshot_service" ] |
| } |
| |
| pw_facade("target_hooks") { |
| backend = pw_system_TARGET_HOOKS_BACKEND |
| public = [ "public/pw_system/target_hooks.h" ] |
| public_deps = [ "$dir_pw_thread:thread" ] |
| public_configs = [ ":public_include_path" ] |
| } |
| |
| if (pw_system_TARGET_HOOKS_BACKEND == "") { |
| # Do nothing, prevents errors from trying to parse pw_system_TARGET_HOOKS_BACKEND as a |
| # build target when it's unset. |
| } else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND, |
| "label_no_toolchain") == |
| get_label_info(":stl_target_hooks", "label_no_toolchain")) { |
| pw_source_set("stl_target_hooks") { |
| deps = [ |
| ":config", |
| "$dir_pw_thread:thread", |
| "$dir_pw_thread_stl:thread", |
| ] |
| sources = [ "stl_target_hooks.cc" ] |
| } |
| } else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND, |
| "label_no_toolchain") == |
| get_label_info(":freertos_target_hooks", "label_no_toolchain")) { |
| pw_source_set("freertos_target_hooks") { |
| deps = [ |
| ":config", |
| ":init", |
| "$dir_pw_third_party/freertos", |
| "$dir_pw_thread:thread", |
| "$dir_pw_thread_freertos:thread", |
| ] |
| sources = [ "freertos_target_hooks.cc" ] |
| } |
| } |
| |
| group("pw_system") { |
| public_deps = [ |
| ":init", |
| ":io", |
| ":log", |
| ":rpc_server", |
| ":work_queue", |
| ] |
| deps = [ ":target_hooks" ] |
| } |
| |
| pw_source_set("async") { |
| public = [ "public/pw_system/system.h" ] |
| public_configs = [ ":public_include_path" ] |
| sources = [ |
| "pw_system_private/threads.h", |
| "system.cc", |
| "threads.cc", |
| ] |
| public_deps = [ |
| "$dir_pw_allocator:allocator", |
| "$dir_pw_async2:dispatcher", |
| "$dir_pw_channel", |
| "$dir_pw_rpc:server", |
| ] |
| deps = [ |
| ":async_packet_io", |
| ":file_manager", |
| ":file_service", |
| ":log", |
| ":thread_snapshot_service", |
| ":transfer_service", |
| ":work_queue", |
| "$dir_pw_allocator:best_fit_block_allocator", |
| "$dir_pw_allocator:synchronized_allocator", |
| "$dir_pw_async2:allocate_task", |
| "$dir_pw_async2:pend_func_task", |
| "$dir_pw_hdlc:router", |
| "$dir_pw_multibuf:simple_allocator", |
| "$dir_pw_rpc/pwpb:echo_service", |
| "$dir_pw_sync:interrupt_spin_lock", |
| "$dir_pw_thread:thread", |
| ] |
| if (pw_cpu_exception_ENTRY_BACKEND != "") { |
| deps += [ |
| ":crash_handler", |
| ":crash_snapshot", |
| ] |
| } |
| } |
| |
| pw_executable("system_example") { |
| # TODO: b/303282642 - Remove this testonly |
| testonly = pw_unit_test_TESTONLY |
| |
| sources = [ "example_user_app_init.cc" ] |
| deps = [ |
| ":pw_system", |
| "$dir_pw_log", |
| "$dir_pw_thread:sleep", |
| "$dir_pw_trace", |
| "$dir_pw_unit_test:rpc_service", |
| |
| # Adds a test that the test server can run. |
| "$dir_pw_status:status_test.lib", |
| "$dir_pw_string:string_builder_test.lib", |
| ] |
| } |
| |
| pw_executable("system_async_host_example") { |
| sources = [ "system_async_host_example.cc" ] |
| deps = [ |
| ":async", |
| "$dir_pw_channel:epoll_channel", |
| "$dir_pw_multibuf:testing", |
| ] |
| } |
| |
| pw_source_set("async_packet_io") { |
| public_configs = [ ":public_include_path" ] |
| public = [ "public/pw_system/internal/async_packet_io.h" ] |
| sources = [ "async_packet_io.cc" ] |
| public_deps = [ |
| "$dir_pw_async2:dispatcher", |
| "$dir_pw_channel:forwarding_channel", |
| "$dir_pw_containers:inline_var_len_entry_queue", |
| "$dir_pw_hdlc:router", |
| "$dir_pw_multibuf:simple_allocator", |
| "$dir_pw_rpc:server", |
| "$dir_pw_sync:lock_annotations", |
| "$dir_pw_sync:mutex", |
| "$dir_pw_sync:thread_notification", |
| "$dir_pw_thread:thread", |
| "$dir_pw_thread:thread_core", |
| dir_pw_allocator, |
| dir_pw_channel, |
| dir_pw_multibuf, |
| ] |
| deps = [ |
| ":config", |
| dir_pw_assert, |
| dir_pw_log, |
| ] |
| visibility = [ "./*" ] |
| } |
| |
| pw_test("async_packet_io_test") { |
| sources = [ "async_packet_io_test.cc" ] |
| deps = [ |
| ":async_packet_io", |
| "$dir_pw_allocator:testing", |
| "$dir_pw_channel:loopback_channel", |
| "$dir_pw_multibuf:testing", |
| ] |
| |
| # TODO: b/317922402 - Run on Windows when thread detaching is supported. |
| enable_if = host_os != "win" && pw_async2_DISPATCHER_BACKEND != "" |
| } |
| |
| pw_test("system_async_test") { |
| sources = [ "system_async_test.cc" ] |
| deps = [ |
| ":async", |
| "$dir_pw_allocator:testing", |
| "$dir_pw_channel:loopback_channel", |
| "$dir_pw_multibuf:testing", |
| ] |
| |
| # TODO: b/317922402 - Run on Windows when thread detaching is supported. |
| enable_if = host_os != "win" && pw_async2_DISPATCHER_BACKEND != "" |
| } |
| |
| group("system_examples") { |
| # TODO: b/303282642 - Remove this testonly |
| testonly = pw_unit_test_TESTONLY |
| |
| deps = [ ":system_example($dir_pigweed/targets/host_device_simulator:host_device_simulator.speed_optimized)" ] |
| if (dir_pw_third_party_stm32cube_f4 != "" && |
| dir_pw_third_party_freertos != "") { |
| deps += [ ":system_example($dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube.size_optimized)" ] |
| deps += [ ":system_example($dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube_clang.size_optimized)" ] |
| } |
| if (dir_pw_third_party_smartfusion_mss != "" && |
| dir_pw_third_party_freertos != "") { |
| deps += [ |
| ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som.size_optimized)", |
| ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som.speed_optimized)", |
| ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som_debug.debug)", |
| ] |
| } |
| if (PICO_SRC_DIR != "" && dir_pw_third_party_freertos != "") { |
| deps += [ |
| ":system_example($dir_pigweed/targets/rp2040:rp2040.debug)", |
| ":system_example($dir_pigweed/targets/rp2040:rp2040.size_optimized)", |
| ] |
| } |
| if (dir_pw_third_party_ambiq_SDK != "" && dir_pw_third_party_freertos != "") { |
| deps += [ |
| ":system_example($dir_pigweed/targets/apollo4_pw_system:apollo4_pw_system.debug)", |
| ":system_example($dir_pigweed/targets/apollo4_pw_system:apollo4_pw_system.size_optimized)", |
| ] |
| } |
| } |
| |
| pw_doc_group("docs") { |
| sources = [ |
| "cli.rst", |
| "docs.rst", |
| ] |
| inputs = [ "system_async_test.cc" ] |
| } |
| |
| pw_test_group("tests") { |
| tests = [ |
| ":async_packet_io_test", |
| ":system_async_test", |
| ] |
| } |