• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_armv7m") {
159  public_deps = [ ":cpu_exception" ]
160}
161group("cpu_exception_armv8m") {
162  public_deps = [ ":cpu_exception" ]
163}
164
165pw_source_set("cpu_exception.impl") {
166  sources = [ "entry.cc" ]
167  deps = [
168    ":config",
169    ":cortex_m_constants",
170    ":cpu_state",
171    ":util",
172    "$dir_pw_cpu_exception:entry.facade",
173    "$dir_pw_cpu_exception:handler",
174    "$dir_pw_preprocessor:arch",
175  ]
176}
177
178# The following targets are deprecated, use ":cpu_exception.impl" instead.
179group("cpu_exception_armv7m.impl") {
180  public_deps = [ ":cpu_exception.impl" ]
181}
182group("cpu_exception_armv8m.impl") {
183  public_deps = [ ":cpu_exception.impl" ]
184}
185
186pw_source_set("snapshot") {
187  public_configs = [ ":public_include_path" ]
188  public_deps = [
189    ":cpu_state",
190    ":cpu_state_protos.pwpb",
191    "$dir_pw_thread:protos.pwpb",
192    "$dir_pw_thread:snapshot",
193    dir_pw_protobuf,
194    dir_pw_status,
195  ]
196  public = [ "public/pw_cpu_exception_cortex_m/snapshot.h" ]
197  sources = [ "snapshot.cc" ]
198  deps = [
199    ":config",
200    ":cortex_m_constants",
201    ":proto_dump",
202    ":util",
203    dir_pw_log,
204  ]
205}
206
207# The following targets are deprecated, use ":snapshot" instead.
208group("snapshot_armv7m") {
209  public_deps = [ ":snapshot" ]
210}
211group("snapshot_armv8m") {
212  public_deps = [ ":snapshot" ]
213}
214
215pw_source_set("cortex_m_constants") {
216  public = [ "pw_cpu_exception_cortex_m_private/cortex_m_constants.h" ]
217  public_deps = [ "$dir_pw_preprocessor:arch" ]
218  visibility = [ ":*" ]
219}
220
221# The following targets are deprecated, use ":cortex_m_constants" instead.
222group("cortex_m_constants_armv7m") {
223  public_deps = [ ":cortex_m_constants" ]
224  visibility = [ ":*" ]
225}
226group("cortex_m_constants_armv8m") {
227  public_deps = [ ":cortex_m_constants" ]
228  visibility = [ ":*" ]
229}
230
231pw_test_group("tests") {
232  tests = [
233    ":cpu_exception_entry_test",
234    ":crash_test",
235    ":util_test",
236  ]
237}
238
239# TODO: b/234888156 - Add ARMv8-M mainline coverage.
240pw_test("cpu_exception_entry_test") {
241  enable_if = pw_cpu_exception_ENTRY_BACKEND ==
242              "$dir_pw_cpu_exception_cortex_m:cpu_exception" &&
243              pw_cpu_exception_SUPPORT_BACKEND != ""
244  deps = [
245    ":config",
246    ":cortex_m_constants",
247    ":cpu_exception",
248    ":cpu_state",
249    "$dir_pw_cpu_exception:entry",
250    "$dir_pw_cpu_exception:handler",
251    "$dir_pw_cpu_exception:support",
252    dir_pw_span,
253  ]
254  sources = [ "exception_entry_test.cc" ]
255}
256
257pw_test("util_test") {
258  enable_if = pw_cpu_exception_ENTRY_BACKEND ==
259              "$dir_pw_cpu_exception_cortex_m:cpu_exception"
260  deps = [
261    ":cpu_state",
262    ":util",
263  ]
264  sources = [ "util_test.cc" ]
265}
266
267# This test defines a crash backend so pw_cpu_exception_cortex_m_CRASH_BACKEND
268# cannot be defined.
269pw_test("crash_test") {
270  enable_if = pw_cpu_exception_ENTRY_BACKEND ==
271              "$dir_pw_cpu_exception_cortex_m:cpu_exception" &&
272              pw_cpu_exception_cortex_m_CRASH_BACKEND == ""
273  public_configs = [
274    ":backend_config",
275    ":public_include_path",
276    ":private_include_path",
277  ]
278  public = [
279    "private/pw_cpu_exception_cortex_m_backend/crash.h",
280    "public/pw_cpu_exception_cortex_m/crash.h",
281  ]
282  deps = [
283    ":config",
284    ":cortex_m_constants",
285    ":cpu_state",
286    ":util",
287    "$dir_pw_cpu_exception:entry",
288    "$dir_pw_preprocessor:arch",
289    "$dir_pw_string:builder",
290    "$dir_pw_sync:lock_annotations",
291    "$dir_pw_sync:mutex",
292    dir_pw_status,
293  ]
294  sources = [
295    "crash.cc",
296    "crash_test.cc",
297  ]
298}
299
300pw_doc_group("docs") {
301  sources = [ "docs.rst" ]
302}
303