xref: /aosp_15_r20/external/pigweed/pw_perf_test/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2022 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/target_types.gni")
19import("$dir_pw_chrono/backend.gni")
20import("$dir_pw_docgen/docs.gni")
21import("$dir_pw_perf_test/perf_test.gni")
22import("$dir_pw_unit_test/test.gni")
23
24config("public_include_path") {
25  include_dirs = [ "public" ]
26  visibility = [ ":*" ]
27}
28
29pw_source_set("pw_perf_test") {
30  public_configs = [ ":public_include_path" ]
31  public = [
32    "public/pw_perf_test/internal/framework.h",
33    "public/pw_perf_test/internal/test_info.h",
34    "public/pw_perf_test/perf_test.h",
35  ]
36  public_deps = [
37    ":event_handler",
38    ":state",
39    ":timer_interface",
40    dir_pw_preprocessor,
41  ]
42  sources = [
43    "framework.cc",
44    "perf_test.cc",
45    "test_info.cc",
46  ]
47}
48
49pw_source_set("state") {
50  public_configs = [ ":public_include_path" ]
51  public = [ "public/pw_perf_test/state.h" ]
52  public_deps = [
53    ":event_handler",
54    ":timer_interface",
55    dir_pw_assert,
56  ]
57  deps = [ dir_pw_log ]
58  sources = [ "state.cc" ]
59}
60
61pw_test("state_test") {
62  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
63  sources = [ "state_test.cc" ]
64  deps = [ ":state" ]
65}
66
67# Event handlers
68
69pw_source_set("event_handler") {
70  public_configs = [ ":public_include_path" ]
71  public = [ "public/pw_perf_test/event_handler.h" ]
72}
73
74pw_source_set("logging_event_handler") {
75  public_configs = [ ":public_include_path" ]
76  public = [
77    "public/pw_perf_test/googletest_style_event_handler.h",
78    "public/pw_perf_test/logging_event_handler.h",
79  ]
80  public_deps = [
81    ":event_handler",
82    ":pw_perf_test",
83  ]
84  deps = [ dir_pw_log ]
85  sources = [ "logging_event_handler.cc" ]
86}
87
88pw_source_set("logging_main") {
89  public_deps = [ ":logging_event_handler" ]
90  sources = [ "logging_main.cc" ]
91}
92
93# Timer facade
94
95pw_source_set("duration_unit") {
96  public = [ "public/pw_perf_test/internal/duration_unit.h" ]
97  public_configs = [ ":public_include_path" ]
98  visibility = [ ":*" ]
99}
100
101pw_facade("timer_interface") {
102  backend = pw_perf_test_TIMER_INTERFACE_BACKEND
103  public = [ "public/pw_perf_test/internal/timer.h" ]
104  public_deps = [ ":duration_unit" ]
105  visibility = [ ":*" ]
106}
107
108pw_test("timer_facade_test") {
109  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
110  sources = [ "timer_test.cc" ]
111  deps = [ ":timer_interface" ]
112}
113
114# Chrono timer facade implementation
115
116config("chrono_config") {
117  include_dirs = [ "chrono_public_overrides" ]
118  visibility = [ ":*" ]
119}
120
121pw_source_set("pw_perf_test_chrono") {
122  public_configs = [ ":chrono_config" ]
123  public = [ "chrono_public_overrides/pw_perf_test_timer_backend/timer.h" ]
124  public_deps = [ ":chrono_timer" ]
125}
126
127pw_source_set("chrono_timer") {
128  public_configs = [
129    ":public_include_path",
130    ":chrono_config",
131  ]
132  public = [ "public/pw_perf_test/internal/chrono_timer_interface.h" ]
133  public_deps = [
134    ":duration_unit",
135    "$dir_pw_chrono:system_clock",
136  ]
137  visibility = [ ":*" ]
138}
139
140pw_test("chrono_timer_test") {
141  enable_if = pw_chrono_SYSTEM_TIMER_BACKEND != ""
142  sources = [ "chrono_test.cc" ]
143  deps = [
144    ":chrono_timer",
145    "$dir_pw_chrono:system_timer",
146    "$dir_pw_thread:sleep",
147  ]
148}
149
150# ARM Cortex timer facade implementation
151
152config("arm_config") {
153  include_dirs = [ "arm_cortex_cyccnt_public_overrides" ]
154  visibility = [ ":*" ]
155}
156
157pw_source_set("arm_cortex_timer") {
158  public_configs = [
159    ":public_include_path",
160    ":arm_config",
161  ]
162  public = [ "public/pw_perf_test/internal/cyccnt_timer_interface.h" ]
163  public_deps = [ ":duration_unit" ]
164  visibility = [ ":*" ]
165}
166
167pw_source_set("pw_perf_test_arm_cortex") {
168  public_configs = [ ":arm_config" ]
169  public = [
170    "arm_cortex_cyccnt_public_overrides/pw_perf_test_timer_backend/timer.h",
171  ]
172  public_deps = [ ":arm_cortex_timer" ]
173}
174
175# Module-level targets
176
177pw_perf_test("example_perf_test") {
178  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
179  sources = [ "examples/example_perf_test.cc" ]
180}
181
182group("examples") {
183  deps = [ ":example_perf_test" ]
184}
185
186pw_test_group("tests") {
187  tests = [
188    ":chrono_timer_test",
189    ":state_test",
190    ":timer_facade_test",
191  ]
192}
193
194pw_doc_group("docs") {
195  sources = [ "docs.rst" ]
196  inputs = [ "examples/example_perf_test.cc" ]
197}
198