xref: /aosp_15_r20/external/pigweed/pw_trace/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2020 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_docgen/docs.gni")
19import("$dir_pw_unit_test/facade_test.gni")
20import("$dir_pw_unit_test/test.gni")
21import("backend.gni")
22
23config("default_config") {
24  include_dirs = [ "public" ]
25}
26
27config("null_config") {
28  include_dirs = [ "public_overrides" ]
29  visibility = [ ":*" ]
30}
31
32pw_facade("pw_trace") {
33  backend = pw_trace_BACKEND
34  public_configs = [ ":default_config" ]
35  public = [
36    "public/pw_trace/internal/trace_internal.h",
37    "public/pw_trace/trace.h",
38  ]
39  public_deps = [ dir_pw_preprocessor ]
40}
41
42pw_source_set("null") {
43  public_configs = [
44    ":default_config",
45    ":null_config",
46  ]
47  public = [ "public_overrides/pw_trace_backend/trace_backend.h" ]
48  sources = [ "public/pw_trace/internal/null.h" ]
49  friend = [ ":*" ]
50  public_deps = [ dir_pw_preprocessor ]
51}
52
53pw_test_group("tests") {
54  tests = [
55    ":trace_facade_test",
56    ":trace_null_test",
57    ":trace_zero_backend_test",
58  ]
59  if (pw_trace_BACKEND != "") {
60    tests += [ ":trace_backend_compile_test" ]
61  }
62}
63
64pw_test("trace_facade_test") {
65  configs = [ ":default_config" ]
66  sources = [ "trace_facade_test.cc" ]
67  public = [
68    "pw_trace_test/fake_backend.h",
69    "pw_trace_test/public_overrides/pw_trace_backend/trace_backend.h",
70  ]
71  include_dirs = [
72    "pw_trace_test",
73    "pw_trace_test/public_overrides",
74  ]
75  deps = [ ":pw_trace" ]
76}
77
78pw_test("trace_backend_compile_test") {
79  enable_if = pw_trace_BACKEND != ""
80
81  deps = [
82    ":pw_trace",
83    pw_trace_BACKEND,
84  ]
85
86  sources = [
87    "trace_backend_compile_test.cc",
88    "trace_backend_compile_test_c.c",
89  ]
90}
91
92config("zero_config") {
93  include_dirs = [ "pw_trace_zero/public_overrides" ]
94  visibility = [ ":*" ]
95}
96
97pw_source_set("zero") {
98  public_configs = [
99    ":default_config",
100    ":zero_config",
101  ]
102  public = [ "pw_trace_zero/public_overrides/pw_trace_backend/trace_backend.h" ]
103}
104
105pw_facade_test("trace_zero_backend_test") {
106  build_args = {
107    pw_trace_BACKEND = ":zero"
108  }
109
110  deps = [ ":pw_trace" ]
111
112  sources = [
113    "trace_backend_compile_test.cc",
114    "trace_backend_compile_test_c.c",
115  ]
116}
117
118pw_test("trace_null_test") {
119  sources = [
120    "trace_null_test.cc",
121    "trace_null_test_c.c",
122  ]
123  deps = [ ":null" ]
124}
125
126pw_doc_group("docs") {
127  sources = [
128    "backends.rst",
129    "docs.rst",
130  ]
131}
132
133config("trace_sample_app_config") {
134  include_dirs = [ "example/public" ]
135}
136
137# The trace sample app produces a variety of different trace events to help
138# understand tracing.
139pw_source_set("trace_sample_app") {
140  deps = [ ":pw_trace" ]
141  public_deps = [ "$dir_pw_ring_buffer" ]
142  sources = [ "example/sample_app.cc" ]
143  public_configs = [ ":trace_sample_app_config" ]
144  public = [ "example/public/pw_trace/example/sample_app.h" ]
145}
146
147# Builds the trace sample app with whichever backend is connected
148pw_executable("trace_example_basic") {
149  deps = [
150    ":trace_sample_app",
151    "$dir_pw_log",
152  ]
153  sources = [ "example/basic.cc" ]
154}
155