1# Copyright 2019 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_pw_build/facade.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_cpu_exception/backend.gni") 21import("$dir_pw_cpu_exception_cortex_m/backend.gni") 22import("$dir_pw_docgen/docs.gni") 23import("$dir_pw_protobuf_compiler/proto.gni") 24import("$dir_pw_unit_test/test.gni") 25 26declare_args() { 27 # The build target that overrides the default configuration options for this 28 # module. This should point to a source set that provides defines through a 29 # public config (which may -include a file or add defines directly). 30 pw_cpu_exception_cortex_m_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 31} 32 33pw_source_set("config") { 34 public_deps = [ 35 "$dir_pw_preprocessor:arch", 36 pw_cpu_exception_cortex_m_CONFIG, 37 ] 38 public = [ "pw_cpu_exception_cortex_m_private/config.h" ] 39 visibility = [ ":*" ] 40} 41 42config("public_include_path") { 43 include_dirs = [ "public" ] 44 visibility = [ ":*" ] 45} 46 47config("private_include_path") { 48 include_dirs = [ "private" ] 49 visibility = [ ":*" ] 50} 51 52config("backend_config") { 53 include_dirs = [ "public_overrides" ] 54 visibility = [ ":*" ] 55} 56 57pw_source_set("support") { 58 deps = [ 59 ":config", 60 ":cortex_m_constants", 61 ":util", 62 "$dir_pw_cpu_exception:support.facade", 63 "$dir_pw_preprocessor:arch", 64 dir_pw_log, 65 dir_pw_span, 66 dir_pw_string, 67 ] 68 sources = [ "support.cc" ] 69} 70 71# The following targets are deprecated, use ":support" instead. 72group("support_armv7m") { 73 public_deps = [ ":support" ] 74} 75group("support_armv8m") { 76 public_deps = [ ":support" ] 77} 78 79pw_source_set("util") { 80 public_configs = [ ":public_include_path" ] 81 public = [ "public/pw_cpu_exception_cortex_m/util.h" ] 82 public_deps = [ ":cpu_state" ] 83 deps = [ 84 ":config", 85 ":cortex_m_constants", 86 "$dir_pw_preprocessor:arch", 87 dir_pw_log, 88 ] 89 sources = [ "util.cc" ] 90} 91 92pw_facade("crash") { 93 backend = pw_cpu_exception_cortex_m_CRASH_BACKEND 94 public_configs = [ ":public_include_path" ] 95 public_deps = [ "$dir_pw_cpu_exception:entry" ] 96 public = [ "public/pw_cpu_exception_cortex_m/crash.h" ] 97 deps = [ 98 ":config", 99 ":cortex_m_constants", 100 ":cpu_state", 101 ":util", 102 "$dir_pw_preprocessor:arch", 103 ] 104 sources = [ "crash.cc" ] 105} 106 107pw_source_set("proto_dump") { 108 public_configs = [ ":public_include_path" ] 109 public_deps = [ 110 ":cpu_exception_armv7m", 111 dir_pw_protobuf, 112 dir_pw_status, 113 dir_pw_stream, 114 ] 115 public = [ "public/pw_cpu_exception_cortex_m/proto_dump.h" ] 116 deps = [ 117 ":config", 118 ":cpu_state_protos.pwpb", 119 ] 120 sources = [ "proto_dump.cc" ] 121} 122 123# The following targets are deprecated, use ":proto_dump" instead. 124group("proto_dump_armv7m") { 125 public_deps = [ ":proto_dump" ] 126} 127group("proto_dump_armv8m") { 128 public_deps = [ ":proto_dump" ] 129} 130 131pw_proto_library("cpu_state_protos") { 132 sources = [ "pw_cpu_exception_cortex_m_protos/cpu_state.proto" ] 133} 134 135pw_source_set("cpu_state") { 136 public_configs = [ ":public_include_path" ] 137 public = [ "public/pw_cpu_exception_cortex_m/cpu_state.h" ] 138 public_deps = [ 139 "$dir_pw_preprocessor", 140 "$dir_pw_preprocessor:arch", 141 ] 142} 143 144pw_source_set("cpu_exception") { 145 public_configs = [ 146 ":backend_config", 147 ":public_include_path", 148 ] 149 public = [ "public_overrides/pw_cpu_exception_backend/state.h" ] 150 public_deps = [ 151 ":cpu_state", 152 "$dir_pw_preprocessor", 153 "$dir_pw_preprocessor:arch", 154 ] 155} 156 157# The following targets are deprecated, use ":cpu_exception" instead. 158group("cpu_exception_armv6m") { 159 public_deps = [ ":cpu_exception" ] 160} 161group("cpu_exception_armv7m") { 162 public_deps = [ ":cpu_exception" ] 163} 164group("cpu_exception_armv8m") { 165 public_deps = [ ":cpu_exception" ] 166} 167 168pw_source_set("cpu_exception_armv6m.impl") { 169 sources = [ "entry_armv6m.cc" ] 170 deps = [ 171 ":config", 172 ":cortex_m_constants", 173 ":cpu_state", 174 ":util", 175 "$dir_pw_cpu_exception:entry.facade", 176 "$dir_pw_cpu_exception:handler", 177 "$dir_pw_preprocessor:arch", 178 ] 179} 180 181pw_source_set("cpu_exception.impl") { 182 sources = [ "entry.cc" ] 183 deps = [ 184 ":config", 185 ":cortex_m_constants", 186 ":cpu_state", 187 ":util", 188 "$dir_pw_cpu_exception:entry.facade", 189 "$dir_pw_cpu_exception:handler", 190 "$dir_pw_preprocessor:arch", 191 ] 192} 193 194# The following targets are deprecated, use ":cpu_exception.impl" instead. 195group("cpu_exception_armv7m.impl") { 196 public_deps = [ ":cpu_exception.impl" ] 197} 198group("cpu_exception_armv8m.impl") { 199 public_deps = [ ":cpu_exception.impl" ] 200} 201 202pw_source_set("snapshot") { 203 public_configs = [ ":public_include_path" ] 204 public_deps = [ 205 ":cpu_state", 206 ":cpu_state_protos.pwpb", 207 "$dir_pw_thread:protos.pwpb", 208 "$dir_pw_thread:snapshot", 209 dir_pw_protobuf, 210 dir_pw_status, 211 ] 212 public = [ "public/pw_cpu_exception_cortex_m/snapshot.h" ] 213 sources = [ "snapshot.cc" ] 214 deps = [ 215 ":config", 216 ":cortex_m_constants", 217 ":proto_dump", 218 ":util", 219 dir_pw_log, 220 ] 221} 222 223# The following targets are deprecated, use ":snapshot" instead. 224group("snapshot_armv7m") { 225 public_deps = [ ":snapshot" ] 226} 227group("snapshot_armv8m") { 228 public_deps = [ ":snapshot" ] 229} 230 231pw_source_set("cortex_m_constants") { 232 public = [ "pw_cpu_exception_cortex_m_private/cortex_m_constants.h" ] 233 public_deps = [ "$dir_pw_preprocessor:arch" ] 234 visibility = [ ":*" ] 235} 236 237# The following targets are deprecated, use ":cortex_m_constants" instead. 238group("cortex_m_constants_armv7m") { 239 public_deps = [ ":cortex_m_constants" ] 240 visibility = [ ":*" ] 241} 242group("cortex_m_constants_armv8m") { 243 public_deps = [ ":cortex_m_constants" ] 244 visibility = [ ":*" ] 245} 246 247pw_test_group("tests") { 248 tests = [ 249 ":cpu_exception_entry_test", 250 ":cpu_exception_entry_test_armv6m", 251 ":crash_test", 252 ":util_test", 253 ] 254} 255 256pw_source_set("cpu_exception_entry_test_util") { 257 sources = [ "exception_entry_test_util.cc" ] 258 public = [ "public/pw_cpu_exception_cortex_m/exception_entry_test_util.h" ] 259 deps = [ 260 ":cortex_m_constants", 261 ":cpu_state", 262 ] 263} 264 265pw_test("cpu_exception_entry_test_armv6m") { 266 enable_if = pw_cpu_exception_ENTRY_BACKEND == 267 "$dir_pw_cpu_exception_cortex_m:cpu_exception_armv6m" && 268 pw_cpu_exception_SUPPORT_BACKEND != "" 269 deps = [ 270 ":config", 271 ":cortex_m_constants", 272 ":cpu_exception_armv6m", 273 ":cpu_exception_entry_test_util", 274 ":cpu_state", 275 "$dir_pw_cpu_exception:entry", 276 "$dir_pw_cpu_exception:handler", 277 "$dir_pw_cpu_exception:support", 278 dir_pw_span, 279 ] 280 sources = [ "exception_entry_test_armv6m.cc" ] 281} 282 283# TODO: b/234888156 - Add ARMv8-M mainline coverage. 284pw_test("cpu_exception_entry_test") { 285 enable_if = pw_cpu_exception_ENTRY_BACKEND == 286 "$dir_pw_cpu_exception_cortex_m:cpu_exception" && 287 pw_cpu_exception_SUPPORT_BACKEND != "" 288 deps = [ 289 ":config", 290 ":cortex_m_constants", 291 ":cpu_exception", 292 ":cpu_exception_entry_test_util", 293 ":cpu_state", 294 "$dir_pw_cpu_exception:entry", 295 "$dir_pw_cpu_exception:handler", 296 "$dir_pw_cpu_exception:support", 297 "$dir_pw_toolchain:infinite_loop", 298 dir_pw_span, 299 ] 300 sources = [ "exception_entry_test.cc" ] 301} 302 303pw_test("util_test") { 304 enable_if = pw_cpu_exception_ENTRY_BACKEND == 305 "$dir_pw_cpu_exception_cortex_m:cpu_exception" || 306 pw_cpu_exception_ENTRY_BACKEND == 307 "$dir_pw_cpu_exception_cortex_m:cpu_exception_armv6m" 308 deps = [ 309 ":cpu_state", 310 ":util", 311 ] 312 sources = [ "util_test.cc" ] 313} 314 315# This test defines a crash backend so pw_cpu_exception_cortex_m_CRASH_BACKEND 316# cannot be defined. 317pw_test("crash_test") { 318 enable_if = pw_cpu_exception_ENTRY_BACKEND == 319 "$dir_pw_cpu_exception_cortex_m:cpu_exception" && 320 pw_cpu_exception_cortex_m_CRASH_BACKEND == "" 321 public_configs = [ 322 ":backend_config", 323 ":public_include_path", 324 ":private_include_path", 325 ] 326 public = [ 327 "private/pw_cpu_exception_cortex_m_backend/crash.h", 328 "public/pw_cpu_exception_cortex_m/crash.h", 329 ] 330 deps = [ 331 ":config", 332 ":cortex_m_constants", 333 ":cpu_state", 334 ":util", 335 "$dir_pw_cpu_exception:entry", 336 "$dir_pw_preprocessor:arch", 337 "$dir_pw_string:builder", 338 "$dir_pw_sync:lock_annotations", 339 "$dir_pw_sync:mutex", 340 dir_pw_status, 341 ] 342 sources = [ 343 "crash.cc", 344 "crash_test.cc", 345 ] 346} 347 348pw_doc_group("docs") { 349 sources = [ "docs.rst" ] 350} 351