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