1# Copyright 2021 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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pigweed/third_party/freertos/freertos.gni") 18import("$dir_pigweed/third_party/nanopb/nanopb.gni") 19import("$dir_pigweed/third_party/smartfusion_mss/mss.gni") 20import("$dir_pigweed/third_party/stm32cube/stm32cube.gni") 21import("$dir_pw_build/error.gni") 22import("$dir_pw_build/facade.gni") 23import("$dir_pw_build/module_config.gni") 24import("$dir_pw_build/target_types.gni") 25import("$dir_pw_docgen/docs.gni") 26import("backend.gni") 27 28declare_args() { 29 # The build target that overrides the default configuration options for this 30 # module. This should point to a source set that provides defines through a 31 # public config (which may -include a file or add defines directly). 32 pw_system_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 33} 34 35config("public_include_path") { 36 include_dirs = [ "public" ] 37} 38 39pw_source_set("config") { 40 sources = [ "public/pw_system/config.h" ] 41 public_configs = [ ":public_include_path" ] 42 public_deps = [ pw_system_CONFIG ] 43 visibility = [ "./*" ] 44 friend = [ "./*" ] 45} 46 47group("pw_system") { 48 public_deps = [ 49 ":init", 50 ":io", 51 ":log", 52 ":rpc_server", 53 ":work_queue", 54 ] 55 deps = [ ":target_hooks" ] 56} 57 58pw_source_set("log") { 59 public_configs = [ ":public_include_path" ] 60 sources = [ 61 "log.cc", 62 "pw_system_private/log.h", 63 ] 64 public_deps = [ 65 "$dir_pw_log_rpc:log_service", 66 "$dir_pw_log_rpc:rpc_log_drain_thread", 67 "$dir_pw_multisink", 68 ] 69 deps = [ 70 ":config", 71 ":rpc_server", 72 "$dir_pw_log_rpc:rpc_log_drain", 73 "$dir_pw_sync:lock_annotations", 74 "$dir_pw_sync:mutex", 75 ] 76} 77 78# There is no public part to this backend which does not cause circular 79# dependencies, there is only the pw_build_LINK_DEPS "log_backend.impl". 80pw_source_set("log_backend") { 81} 82 83pw_source_set("log_backend.impl") { 84 sources = [ "log_backend.cc" ] 85 deps = [ 86 ":config", 87 ":log", 88 "$dir_pw_bytes", 89 "$dir_pw_chrono:system_clock", 90 "$dir_pw_log:proto_utils", 91 "$dir_pw_log:pw_log.facade", 92 "$dir_pw_log_string:handler.facade", 93 "$dir_pw_log_tokenized:metadata", 94 "$dir_pw_multisink", 95 "$dir_pw_result", 96 "$dir_pw_string", 97 "$dir_pw_sync:interrupt_spin_lock", 98 "$dir_pw_sync:lock_annotations", 99 "$dir_pw_tokenizer", 100 "$dir_pw_tokenizer:global_handler_with_payload.facade", 101 ] 102} 103 104pw_facade("rpc_server") { 105 backend = pw_system_RPC_SERVER_BACKEND 106 public = [ "public/pw_system/rpc_server.h" ] 107 public_configs = [ ":public_include_path" ] 108 public_deps = [ 109 ":config", 110 "$dir_pw_thread:thread_core", 111 ] 112} 113 114pw_facade("io") { 115 backend = pw_system_IO_BACKEND 116 public_configs = [ ":public_include_path" ] 117 public = [ "public/pw_system/io.h" ] 118 public_deps = [ "$dir_pw_stream" ] 119} 120 121pw_source_set("init") { 122 public_configs = [ ":public_include_path" ] 123 public = [ "public/pw_system/init.h" ] 124 sources = [ "init.cc" ] 125 deps = [ 126 ":log", 127 ":rpc_server", 128 ":target_hooks.facade", 129 ":work_queue", 130 "$dir_pw_rpc/nanopb:echo_service", 131 "$dir_pw_thread:thread", 132 ] 133} 134 135pw_source_set("hdlc_rpc_server") { 136 sources = [ "hdlc_rpc_server.cc" ] 137 deps = [ 138 ":config", 139 ":io", 140 ":rpc_server.facade", 141 "$dir_pw_assert", 142 "$dir_pw_hdlc:pw_rpc", 143 "$dir_pw_hdlc:rpc_channel_output", 144 "$dir_pw_log", 145 "$dir_pw_sync:mutex", 146 ] 147} 148 149pw_source_set("work_queue") { 150 public_configs = [ ":public_include_path" ] 151 public = [ "public/pw_system/work_queue.h" ] 152 sources = [ "work_queue.cc" ] 153 public_deps = [ "$dir_pw_work_queue" ] 154 deps = [ ":config" ] 155} 156 157pw_source_set("sys_io_target_io") { 158 sources = [ "target_io.cc" ] 159 deps = [ 160 ":io.facade", 161 "$dir_pw_stream", 162 "$dir_pw_stream:sys_io_stream", 163 ] 164} 165 166pw_source_set("socket_target_io") { 167 sources = [ "socket_target_io.cc" ] 168 deps = [ 169 ":config", 170 ":io.facade", 171 "$dir_pw_assert", 172 "$dir_pw_stream", 173 "$dir_pw_stream:socket_stream", 174 ] 175} 176 177pw_facade("target_hooks") { 178 backend = pw_system_TARGET_HOOKS_BACKEND 179 public = [ "public/pw_system/target_hooks.h" ] 180 public_deps = [ "$dir_pw_thread:thread" ] 181 public_configs = [ ":public_include_path" ] 182} 183 184if (pw_system_TARGET_HOOKS_BACKEND == "") { 185 # Do nothing, prevents errors from trying to parse pw_system_TARGET_HOOKS_BACKEND as a 186 # build target when it's unset. 187} else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND, 188 "label_no_toolchain") == 189 get_label_info(":stl_target_hooks", "label_no_toolchain")) { 190 pw_source_set("stl_target_hooks") { 191 deps = [ 192 ":init", 193 "$dir_pw_log", 194 "$dir_pw_thread:sleep", 195 "$dir_pw_thread:thread", 196 "$dir_pw_thread_stl:thread", 197 ] 198 sources = [ "stl_target_hooks.cc" ] 199 } 200} else if (get_label_info(pw_system_TARGET_HOOKS_BACKEND, 201 "label_no_toolchain") == 202 get_label_info(":freertos_target_hooks", "label_no_toolchain")) { 203 pw_source_set("freertos_target_hooks") { 204 deps = [ 205 ":init", 206 "$dir_pw_third_party/freertos", 207 "$dir_pw_thread:thread", 208 "$dir_pw_thread_freertos:thread", 209 ] 210 sources = [ "freertos_target_hooks.cc" ] 211 } 212} 213 214pw_executable("system_example") { 215 sources = [ "example_user_app_init.cc" ] 216 deps = [ 217 ":pw_system", 218 "$dir_pw_log", 219 "$dir_pw_thread:sleep", 220 ] 221} 222 223if (dir_pw_third_party_nanopb != "") { 224 group("system_examples") { 225 deps = [ ":system_example($dir_pigweed/targets/host_device_simulator:host_device_simulator.speed_optimized)" ] 226 if (dir_pw_third_party_stm32cube_f4 != "" && 227 dir_pw_third_party_freertos != "") { 228 deps += [ ":system_example($dir_pigweed/targets/stm32f429i_disc1_stm32cube:stm32f429i_disc1_stm32cube.size_optimized)" ] 229 } 230 if (dir_pw_third_party_smartfusion_mss != "" && 231 dir_pw_third_party_freertos != "") { 232 deps += [ 233 ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som.size_optimized)", 234 ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som.speed_optimized)", 235 ":system_example($dir_pigweed/targets/emcraft_sf2_som:emcraft_sf2_som_debug.debug)", 236 ] 237 } 238 } 239} else { 240 pw_error("system_examples") { 241 message_lines = [ 242 "Building the pw_system examples requires Nanopb.", 243 "Nanopb can be installed by running the command below and then following the prompted setup steps:", 244 " pw package install nanopb", 245 ] 246 } 247} 248 249pw_doc_group("docs") { 250 sources = [ "docs.rst" ] 251} 252