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 15load( 16 "//pw_build:pigweed.bzl", 17 "pw_cc_binary", 18 "pw_cc_library", 19) 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) 24 25pw_cc_library( 26 name = "config", 27 hdrs = [ 28 "public/pw_system/config.h", 29 ], 30) 31 32pw_cc_library( 33 name = "log", 34 srcs = [ 35 "log.cc", 36 ], 37 hdrs = [ 38 "pw_system_private/log.h", 39 ], 40 deps = [ 41 ":config", 42 ":rpc_server", 43 "//pw_log_rpc:log_service", 44 "//pw_log_rpc:rpc_log_drain", 45 "//pw_log_rpc:rpc_log_drain_thread", 46 "//pw_multisink", 47 "//pw_sync:lock_annotations", 48 "//pw_sync:mutex", 49 ], 50) 51 52pw_cc_library( 53 name = "log_backend", 54 srcs = [ 55 "log_backend.cc", 56 ], 57 deps = [ 58 ":config", 59 ":log", 60 "//pw_bytes", 61 "//pw_chrono:system_clock", 62 "//pw_log:facade", 63 "//pw_log:proto_utils", 64 "//pw_log_string:handler_facade", 65 "//pw_log_tokenized:handler_facade", 66 "//pw_log_tokenized:headers", 67 "//pw_metric:global", 68 "//pw_multisink", 69 "//pw_result", 70 "//pw_string", 71 "//pw_sync:interrupt_spin_lock", 72 "//pw_sync:lock_annotations", 73 "//pw_tokenizer", 74 ], 75) 76 77pw_cc_library( 78 name = "rpc_server_headers", 79 hdrs = [ 80 "public/pw_system/rpc_server.h", 81 ], 82 includes = ["public"], 83 deps = [ 84 ":config", 85 ], 86) 87 88pw_cc_library( 89 name = "rpc_server", 90 deps = [ 91 ":config", 92 ":hdlc_rpc_server", 93 ":rpc_server_headers", 94 ], 95) 96 97pw_cc_library( 98 name = "hdlc_rpc_server", 99 srcs = [ 100 "hdlc_rpc_server.cc", 101 ], 102 includes = ["public"], 103 deps = [ 104 ":io", 105 ":rpc_server_headers", 106 ":target_io", 107 "//pw_assert", 108 "//pw_hdlc:pw_rpc", 109 "//pw_hdlc:rpc_channel_output", 110 "//pw_sync:mutex", 111 "//pw_thread:thread_core", 112 ], 113) 114 115pw_cc_library( 116 name = "thread_snapshot_service", 117 srcs = [ 118 "thread_snapshot_service.cc", 119 ], 120 hdrs = [ 121 "public/pw_system/thread_snapshot_service.h", 122 ], 123 includes = ["public"], 124 deps = [ 125 "//pw_rpc", 126 "//pw_thread:thread_snapshot_service", 127 ], 128) 129 130pw_cc_library( 131 name = "io", 132 hdrs = [ 133 "public/pw_system/io.h", 134 ], 135 deps = [ 136 "//pw_stream", 137 ], 138) 139 140pw_cc_library( 141 name = "init", 142 srcs = [ 143 "init.cc", 144 ], 145 hdrs = [ 146 "public/pw_system/init.h", 147 ], 148 includes = ["public"], 149 deps = [ 150 ":log", 151 ":rpc_server", 152 ":target_hooks", 153 ":thread_snapshot_service", 154 ":work_queue", 155 "//pw_metric:global", 156 "//pw_metric:metric_service_pwpb", 157 "//pw_rpc/pwpb:echo_service", 158 "//pw_thread:thread", 159 ], 160) 161 162pw_cc_library( 163 name = "work_queue", 164 srcs = [ 165 "work_queue.cc", 166 ], 167 hdrs = [ 168 "public/pw_system/work_queue.h", 169 ], 170 includes = ["public"], 171 deps = [ 172 ":config", 173 "//pw_work_queue", 174 ], 175) 176 177pw_cc_library( 178 name = "target_io", 179 srcs = [ 180 "target_io.cc", 181 ], 182 includes = ["public"], 183 deps = [ 184 ":io", 185 "//pw_stream", 186 "//pw_stream:sys_io_stream", 187 ], 188) 189 190pw_cc_library( 191 name = "socket_target_io", 192 srcs = [ 193 "socket_target_io.cc", 194 ], 195 includes = ["public"], 196 deps = [ 197 ":config", 198 ":io", 199 "//pw_assert", 200 "//pw_stream", 201 "//pw_stream:socket_stream", 202 ], 203) 204 205pw_cc_library( 206 name = "target_hooks_headers", 207 hdrs = [ 208 "public/pw_system/target_hooks.h", 209 ], 210 includes = ["public"], 211 deps = [ 212 "//pw_thread:thread", 213 ], 214) 215 216pw_cc_library( 217 name = "target_hooks", 218 hdrs = [ 219 "public/pw_system/target_hooks.h", 220 ], 221 includes = ["public"], 222 deps = [ 223 "//pw_thread:thread", 224 "@pigweed_config//:pw_system_target_hooks_backend", 225 ], 226) 227 228# This isn't the best solution, but it's close enough for now. Target hooks are 229# not generically related to an OS, and should be inject-able by downstream 230# projects. For now, assume the pre-baked OS-specific hooks are good enough. 231pw_cc_library( 232 name = "target_hooks_multiplexer", 233 visibility = ["@pigweed_config//:__pkg__"], 234 deps = select({ 235 "//pw_build/constraints/rtos:freertos": [":freertos_target_hooks"], 236 "//conditions:default": [":stl_target_hooks"], 237 }), 238) 239 240pw_cc_library( 241 name = "stl_target_hooks", 242 srcs = [ 243 "stl_target_hooks.cc", 244 ], 245 deps = [ 246 "//pw_thread:thread", 247 "//pw_thread_stl:thread", 248 ], 249) 250 251pw_cc_library( 252 name = "freertos_target_hooks", 253 srcs = [ 254 "freertos_target_hooks.cc", 255 ], 256 target_compatible_with = [ 257 "//pw_build/constraints/rtos:freertos", 258 ], 259 deps = [ 260 ":target_hooks_headers", 261 "//pw_thread:thread", 262 "//pw_thread_freertos:thread", 263 ], 264) 265 266pw_cc_binary( 267 name = "system_example", 268 srcs = ["example_user_app_init.cc"], 269 deps = [ 270 ":init", 271 ":io", 272 ":target_hooks", 273 "//pw_stream", 274 "//pw_stream:sys_io_stream", 275 "//pw_unit_test:rpc_service", 276 ] + select({ 277 "//pw_build/constraints/rtos:freertos": [], 278 "//conditions:default": ["//targets/host_device_simulator:boot"], 279 }), 280) 281