# 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_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_docgen/docs.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", ] } # 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" ] public_deps = [ pw_system_CONFIG ] visibility = [ "./*" ] friend = [ "./*" ] } 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", ":rpc_server", "$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_source_set("init") { public_configs = [ ":public_include_path" ] public = [ "public/pw_system/init.h" ] sources = [ "init.cc" ] deps = [ ":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", ] } 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 = [ "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 = [ "$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" ] } 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("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_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", ] } 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", ] } pw_test_group("tests") { }