xref: /aosp_15_r20/external/pigweed/pw_cpu_exception/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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
15load("//pw_build:compatibility.bzl", "boolean_constraint_value")
16load("//pw_build:pw_facade.bzl", "pw_facade")
17
18package(default_visibility = ["//visibility:public"])
19
20licenses(["notice"])
21
22# This module has three facades, each of whose backends are set with a
23# different constraint_setting.
24#
25# - entry: This is the library that handles early exception entry and prepares
26#   any CPU state that must be available to the exception handler via the
27#   pw_cpu_exception_State object. The backend for this facade is
28#   architecture-specific.
29constraint_setting(
30    name = "entry_constraint_setting",
31)
32
33# - handler: This facade is backed by an application-specific handler that
34#   determines what to do when an exception is encountered. This may be
35#   capturing a crash report before resetting the device, or in some cases
36#   handling the exception to allow execution to continue.
37constraint_setting(
38    name = "handler_constraint_setting",
39)
40
41# - support: This facade provides architecture-independent functions that may be
42#   helpful for dumping CPU state in various forms. This allows an application
43#   to create an application-specific handler that is portable across multiple
44#   architectures.
45constraint_setting(
46    name = "support_constraint_setting",
47)
48
49pw_facade(
50    name = "entry",
51    hdrs = [
52        "public/pw_cpu_exception/entry.h",
53        "public/pw_cpu_exception/state.h",
54    ],
55    backend = ":entry_backend",
56    strip_include_prefix = "public",
57    deps = [
58        "//pw_preprocessor",
59    ],
60)
61
62pw_facade(
63    name = "handler",
64    srcs = ["start_exception_handler.cc"],
65    hdrs = ["public/pw_cpu_exception/handler.h"],
66    backend = ":handler_backend",
67    implementation_deps = [
68        "//pw_preprocessor",
69    ],
70    strip_include_prefix = "public",
71    deps = [":entry"],
72)
73
74pw_facade(
75    name = "support",
76    hdrs = ["public/pw_cpu_exception/support.h"],
77    backend = ":support_backend",
78    strip_include_prefix = "public",
79    deps = [
80        ":entry",
81    ],
82)
83
84constraint_value(
85    name = "basic_handler_backend",
86    constraint_setting = "//pw_cpu_exception:handler_constraint_setting",
87)
88
89# TODO: https://github.com/bazelbuild/bazel/issues/23003 - this shouldn't be
90# needed, as it should be possible to have a config_setting as to whether
91# the entry_backend is "//pw_build:unspecified_backend" or not, but that doesn't
92# work currently due to the referenced bug.
93boolean_constraint_value(
94    name = "enabled",
95)
96
97cc_library(
98    name = "basic_handler",
99    srcs = ["basic_handler.cc"],
100    deps = [
101        ":entry",
102        ":handler.facade",
103        "//pw_log",
104    ],
105)
106
107# Override-able flags for each facade backend.
108label_flag(
109    name = "entry_backend",
110    build_setting_default = "//pw_build:unspecified_backend",
111)
112
113label_flag(
114    name = "entry_backend_impl",
115    build_setting_default = "//pw_build:unspecified_backend",
116)
117
118label_flag(
119    name = "handler_backend",
120    build_setting_default = "//pw_build:unspecified_backend",
121)
122
123label_flag(
124    name = "support_backend",
125    build_setting_default = "//pw_build:unspecified_backend",
126)
127