xref: /aosp_15_r20/external/pigweed/pw_snapshot/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/target_types.gni")
18import("$dir_pw_docgen/docs.gni")
19import("$dir_pw_protobuf_compiler/proto.gni")
20import("$dir_pw_unit_test/test.gni")
21
22config("public_include_path") {
23  include_dirs = [ "public" ]
24  visibility = [ ":*" ]
25}
26
27pw_source_set("uuid") {
28  public_configs = [ ":public_include_path" ]
29  public = [ "public/pw_snapshot/uuid.h" ]
30  public_deps = [
31    dir_pw_bytes,
32    dir_pw_result,
33    dir_pw_span,
34    dir_pw_status,
35  ]
36  deps = [
37    ":metadata_proto.pwpb",
38    dir_pw_protobuf,
39  ]
40  sources = [ "uuid.cc" ]
41}
42
43group("pw_snapshot") {
44  deps = [
45    ":metadata_proto",
46    ":snapshot_proto",
47  ]
48}
49
50# This proto library only contains the snapshot_metadata.proto. Typically this
51# should be a dependency of snapshot-like protos.
52pw_proto_library("metadata_proto") {
53  sources = [ "pw_snapshot_protos/snapshot_metadata.proto" ]
54  strip_prefix = "pw_snapshot_protos"
55  prefix = "pw_snapshot_metadata_proto"
56  deps = [ "$dir_pw_tokenizer:proto" ]
57}
58
59# This proto provides the complete "Snapshot" proto, which depends on various
60# proto libraries throughout Pigweed. This is the proto library to use when
61# building/reading snapshots.
62pw_proto_library("snapshot_proto") {
63  sources = [ "pw_snapshot_protos/snapshot.proto" ]
64  deps = [
65    ":metadata_proto",
66    "$dir_pw_chrono:protos",
67    "$dir_pw_cpu_exception_cortex_m:cpu_state_protos",
68    "$dir_pw_cpu_exception_risc_v:cpu_state_protos",
69    "$dir_pw_log:protos",
70    "$dir_pw_thread:protos",
71  ]
72}
73
74pw_doc_group("docs") {
75  inputs = [ "images/generic_crash_flow.svg" ]
76  sources = [
77    "design_discussion.rst",
78    "docs.rst",
79    "module_usage.rst",
80    "proto_format.rst",
81    "setup.rst",
82  ]
83}
84
85pw_test_group("tests") {
86  tests = [
87    ":cpp_compile_test",
88    ":uuid_test",
89  ]
90}
91
92# An empty test to ensure the proto libraries compile correctly.
93pw_test("cpp_compile_test") {
94  sources = [ "cpp_compile_test.cc" ]
95  deps = [
96    ":snapshot_proto.pwpb",
97    dir_pw_protobuf,
98  ]
99}
100
101pw_test("uuid_test") {
102  sources = [ "uuid_test.cc" ]
103  deps = [
104    ":metadata_proto.pwpb",
105    ":uuid",
106    dir_pw_bytes,
107    dir_pw_protobuf,
108    dir_pw_result,
109    dir_pw_status,
110  ]
111}
112