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_library", 18 "pw_cc_test", 19) 20load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") 21load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library") 22 23package(default_visibility = ["//visibility:public"]) 24 25licenses(["notice"]) 26 27pw_cc_library( 28 name = "config", 29 hdrs = ["pw_cpu_exception_cortex_m_private/config.h"], 30) 31 32pw_cc_library( 33 name = "cpu_state", 34 hdrs = ["public/pw_cpu_exception_cortex_m/cpu_state.h"], 35 includes = ["public"], 36 deps = [ 37 "//pw_preprocessor", 38 "//pw_preprocessor:cortex_m", 39 ], 40) 41 42pw_cc_library( 43 name = "util", 44 srcs = ["util.cc"], 45 hdrs = ["public/pw_cpu_exception_cortex_m/util.h"], 46 includes = ["public"], 47 target_compatible_with = select({ 48 "@platforms//cpu:armv7-m": [], 49 "@platforms//cpu:armv7e-m": [], 50 "@platforms//cpu:armv7e-mf": [], 51 "@platforms//cpu:armv8-m": [], 52 "//conditions:default": ["@platforms//:incompatible"], 53 }), 54 deps = [ 55 ":config", 56 ":cortex_m_constants", 57 ":cpu_state", 58 "//pw_log", 59 "//pw_preprocessor:cortex_m", 60 ], 61) 62 63pw_cc_library( 64 name = "support", 65 srcs = ["support.cc"], 66 deps = [ 67 ":config", 68 ":cortex_m_constants", 69 ":cpu_state", 70 ":util", 71 "//pw_log", 72 "//pw_preprocessor", 73 "//pw_preprocessor:cortex_m", 74 "//pw_string", 75 ], 76) 77 78pw_cc_library( 79 name = "proto_dump", 80 srcs = ["proto_dump.cc"], 81 hdrs = ["public/pw_cpu_exception_cortex_m/proto_dump.h"], 82 includes = ["public"], 83 deps = [ 84 ":config", 85 ":cpu_state", 86 ":cpu_state_protos_cc.pwpb", 87 ":support", 88 "//pw_protobuf", 89 "//pw_status", 90 "//pw_stream", 91 ], 92) 93 94proto_library( 95 name = "cpu_state_protos", 96 srcs = ["pw_cpu_exception_cortex_m_protos/cpu_state.proto"], 97 import_prefix = "pw_cpu_exception_cortex_m_protos", 98 strip_import_prefix = "/pw_cpu_exception_cortex_m/pw_cpu_exception_cortex_m_protos", 99) 100 101py_proto_library( 102 name = "cpu_state_protos_pb2", 103 srcs = ["pw_cpu_exception_cortex_m_protos/cpu_state.proto"], 104) 105 106pw_proto_library( 107 name = "cpu_state_protos_cc", 108 deps = [":cpu_state_protos"], 109) 110 111pw_cc_library( 112 name = "cpu_exception", 113 srcs = ["entry.cc"], 114 hdrs = [ 115 "public/pw_cpu_exception_cortex_m/cpu_state.h", 116 "public_overrides/pw_cpu_exception_backend/state.h", 117 ], 118 includes = ["public"], 119 deps = [ 120 ":config", 121 ":cpu_state", 122 ":cortex_m_constants", 123 ":proto_dump", 124 ":support", 125 ":util", 126 # TODO(b/242183021): Need to add support for facades/backends to Bazel. 127 # "//pw_cpu_exception", 128 "//pw_preprocessor", 129 "//pw_preprocessor:cortex_m", 130 ], 131) 132 133pw_cc_library( 134 name = "snapshot", 135 srcs = ["snapshot.cc"], 136 hdrs = ["public/pw_cpu_exception_cortex_m/snapshot.h"], 137 deps = [ 138 ":config", 139 ":cortex_m_constants", 140 ":cpu_state", 141 ":cpu_state_protos_cc.pwpb", 142 ":proto_dump", 143 ":util", 144 "//pw_log", 145 "//pw_protobuf", 146 "//pw_status", 147 "//pw_thread:snapshot", 148 "//pw_thread:thread_cc.pwpb", 149 ], 150) 151 152pw_cc_library( 153 name = "cortex_m_constants", 154 hdrs = ["pw_cpu_exception_cortex_m_private/cortex_m_constants.h"], 155 visibility = ["//visibility:private"], 156 deps = ["//pw_preprocessor:cortex_m"], 157) 158 159pw_cc_test( 160 name = "cpu_exception_entry_test", 161 srcs = [ 162 "exception_entry_test.cc", 163 ], 164 deps = [ 165 ":config", 166 ":cpu_exception", 167 ":cpu_state", 168 ], 169) 170 171pw_cc_test( 172 name = "util_test", 173 srcs = [ 174 "util_test.cc", 175 ], 176 deps = [ 177 ":cpu_state", 178 ":util", 179 ], 180) 181