xref: /aosp_15_r20/external/pigweed/pw_perf_test/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1*61c4878aSAndroid Build Coastguard Worker# Copyright 2022 The Pigweed Authors
2*61c4878aSAndroid Build Coastguard Worker#
3*61c4878aSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4*61c4878aSAndroid Build Coastguard Worker# use this file except in compliance with the License. You may obtain a copy of
5*61c4878aSAndroid Build Coastguard Worker# the License at
6*61c4878aSAndroid Build Coastguard Worker#
7*61c4878aSAndroid Build Coastguard Worker#     https://www.apache.org/licenses/LICENSE-2.0
8*61c4878aSAndroid Build Coastguard Worker#
9*61c4878aSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*61c4878aSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11*61c4878aSAndroid Build Coastguard Worker# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12*61c4878aSAndroid Build Coastguard Worker# License for the specific language governing permissions and limitations under
13*61c4878aSAndroid Build Coastguard Worker# the License.
14*61c4878aSAndroid Build Coastguard Worker
15*61c4878aSAndroid Build Coastguard Workerimport("//build_overrides/pigweed.gni")
16*61c4878aSAndroid Build Coastguard Worker
17*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/facade.gni")
18*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_build/target_types.gni")
19*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_chrono/backend.gni")
20*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_docgen/docs.gni")
21*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_perf_test/perf_test.gni")
22*61c4878aSAndroid Build Coastguard Workerimport("$dir_pw_unit_test/test.gni")
23*61c4878aSAndroid Build Coastguard Worker
24*61c4878aSAndroid Build Coastguard Workerconfig("public_include_path") {
25*61c4878aSAndroid Build Coastguard Worker  include_dirs = [ "public" ]
26*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
27*61c4878aSAndroid Build Coastguard Worker}
28*61c4878aSAndroid Build Coastguard Worker
29*61c4878aSAndroid Build Coastguard Workerpw_source_set("pw_perf_test") {
30*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
31*61c4878aSAndroid Build Coastguard Worker  public = [
32*61c4878aSAndroid Build Coastguard Worker    "public/pw_perf_test/internal/framework.h",
33*61c4878aSAndroid Build Coastguard Worker    "public/pw_perf_test/internal/test_info.h",
34*61c4878aSAndroid Build Coastguard Worker    "public/pw_perf_test/perf_test.h",
35*61c4878aSAndroid Build Coastguard Worker  ]
36*61c4878aSAndroid Build Coastguard Worker  public_deps = [
37*61c4878aSAndroid Build Coastguard Worker    ":event_handler",
38*61c4878aSAndroid Build Coastguard Worker    ":state",
39*61c4878aSAndroid Build Coastguard Worker    ":timer_interface",
40*61c4878aSAndroid Build Coastguard Worker    dir_pw_preprocessor,
41*61c4878aSAndroid Build Coastguard Worker  ]
42*61c4878aSAndroid Build Coastguard Worker  sources = [
43*61c4878aSAndroid Build Coastguard Worker    "framework.cc",
44*61c4878aSAndroid Build Coastguard Worker    "perf_test.cc",
45*61c4878aSAndroid Build Coastguard Worker    "test_info.cc",
46*61c4878aSAndroid Build Coastguard Worker  ]
47*61c4878aSAndroid Build Coastguard Worker}
48*61c4878aSAndroid Build Coastguard Worker
49*61c4878aSAndroid Build Coastguard Workerpw_source_set("state") {
50*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
51*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/state.h" ]
52*61c4878aSAndroid Build Coastguard Worker  public_deps = [
53*61c4878aSAndroid Build Coastguard Worker    ":event_handler",
54*61c4878aSAndroid Build Coastguard Worker    ":timer_interface",
55*61c4878aSAndroid Build Coastguard Worker    dir_pw_assert,
56*61c4878aSAndroid Build Coastguard Worker  ]
57*61c4878aSAndroid Build Coastguard Worker  deps = [ dir_pw_log ]
58*61c4878aSAndroid Build Coastguard Worker  sources = [ "state.cc" ]
59*61c4878aSAndroid Build Coastguard Worker}
60*61c4878aSAndroid Build Coastguard Worker
61*61c4878aSAndroid Build Coastguard Workerpw_test("state_test") {
62*61c4878aSAndroid Build Coastguard Worker  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
63*61c4878aSAndroid Build Coastguard Worker  sources = [ "state_test.cc" ]
64*61c4878aSAndroid Build Coastguard Worker  deps = [ ":state" ]
65*61c4878aSAndroid Build Coastguard Worker}
66*61c4878aSAndroid Build Coastguard Worker
67*61c4878aSAndroid Build Coastguard Worker# Event handlers
68*61c4878aSAndroid Build Coastguard Worker
69*61c4878aSAndroid Build Coastguard Workerpw_source_set("event_handler") {
70*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
71*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/event_handler.h" ]
72*61c4878aSAndroid Build Coastguard Worker}
73*61c4878aSAndroid Build Coastguard Worker
74*61c4878aSAndroid Build Coastguard Workerpw_source_set("logging_event_handler") {
75*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
76*61c4878aSAndroid Build Coastguard Worker  public = [
77*61c4878aSAndroid Build Coastguard Worker    "public/pw_perf_test/googletest_style_event_handler.h",
78*61c4878aSAndroid Build Coastguard Worker    "public/pw_perf_test/logging_event_handler.h",
79*61c4878aSAndroid Build Coastguard Worker  ]
80*61c4878aSAndroid Build Coastguard Worker  public_deps = [
81*61c4878aSAndroid Build Coastguard Worker    ":event_handler",
82*61c4878aSAndroid Build Coastguard Worker    ":pw_perf_test",
83*61c4878aSAndroid Build Coastguard Worker  ]
84*61c4878aSAndroid Build Coastguard Worker  deps = [ dir_pw_log ]
85*61c4878aSAndroid Build Coastguard Worker  sources = [ "logging_event_handler.cc" ]
86*61c4878aSAndroid Build Coastguard Worker}
87*61c4878aSAndroid Build Coastguard Worker
88*61c4878aSAndroid Build Coastguard Workerpw_source_set("logging_main") {
89*61c4878aSAndroid Build Coastguard Worker  public_deps = [ ":logging_event_handler" ]
90*61c4878aSAndroid Build Coastguard Worker  sources = [ "logging_main.cc" ]
91*61c4878aSAndroid Build Coastguard Worker}
92*61c4878aSAndroid Build Coastguard Worker
93*61c4878aSAndroid Build Coastguard Worker# Timer facade
94*61c4878aSAndroid Build Coastguard Worker
95*61c4878aSAndroid Build Coastguard Workerpw_source_set("duration_unit") {
96*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/internal/duration_unit.h" ]
97*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":public_include_path" ]
98*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
99*61c4878aSAndroid Build Coastguard Worker}
100*61c4878aSAndroid Build Coastguard Worker
101*61c4878aSAndroid Build Coastguard Workerpw_facade("timer_interface") {
102*61c4878aSAndroid Build Coastguard Worker  backend = pw_perf_test_TIMER_INTERFACE_BACKEND
103*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/internal/timer.h" ]
104*61c4878aSAndroid Build Coastguard Worker  public_deps = [ ":duration_unit" ]
105*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
106*61c4878aSAndroid Build Coastguard Worker}
107*61c4878aSAndroid Build Coastguard Worker
108*61c4878aSAndroid Build Coastguard Workerpw_test("timer_facade_test") {
109*61c4878aSAndroid Build Coastguard Worker  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
110*61c4878aSAndroid Build Coastguard Worker  sources = [ "timer_test.cc" ]
111*61c4878aSAndroid Build Coastguard Worker  deps = [ ":timer_interface" ]
112*61c4878aSAndroid Build Coastguard Worker}
113*61c4878aSAndroid Build Coastguard Worker
114*61c4878aSAndroid Build Coastguard Worker# Chrono timer facade implementation
115*61c4878aSAndroid Build Coastguard Worker
116*61c4878aSAndroid Build Coastguard Workerconfig("chrono_config") {
117*61c4878aSAndroid Build Coastguard Worker  include_dirs = [ "chrono_public_overrides" ]
118*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
119*61c4878aSAndroid Build Coastguard Worker}
120*61c4878aSAndroid Build Coastguard Worker
121*61c4878aSAndroid Build Coastguard Workerpw_source_set("pw_perf_test_chrono") {
122*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":chrono_config" ]
123*61c4878aSAndroid Build Coastguard Worker  public = [ "chrono_public_overrides/pw_perf_test_timer_backend/timer.h" ]
124*61c4878aSAndroid Build Coastguard Worker  public_deps = [ ":chrono_timer" ]
125*61c4878aSAndroid Build Coastguard Worker}
126*61c4878aSAndroid Build Coastguard Worker
127*61c4878aSAndroid Build Coastguard Workerpw_source_set("chrono_timer") {
128*61c4878aSAndroid Build Coastguard Worker  public_configs = [
129*61c4878aSAndroid Build Coastguard Worker    ":public_include_path",
130*61c4878aSAndroid Build Coastguard Worker    ":chrono_config",
131*61c4878aSAndroid Build Coastguard Worker  ]
132*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/internal/chrono_timer_interface.h" ]
133*61c4878aSAndroid Build Coastguard Worker  public_deps = [
134*61c4878aSAndroid Build Coastguard Worker    ":duration_unit",
135*61c4878aSAndroid Build Coastguard Worker    "$dir_pw_chrono:system_clock",
136*61c4878aSAndroid Build Coastguard Worker  ]
137*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
138*61c4878aSAndroid Build Coastguard Worker}
139*61c4878aSAndroid Build Coastguard Worker
140*61c4878aSAndroid Build Coastguard Workerpw_test("chrono_timer_test") {
141*61c4878aSAndroid Build Coastguard Worker  enable_if = pw_chrono_SYSTEM_TIMER_BACKEND != ""
142*61c4878aSAndroid Build Coastguard Worker  sources = [ "chrono_test.cc" ]
143*61c4878aSAndroid Build Coastguard Worker  deps = [
144*61c4878aSAndroid Build Coastguard Worker    ":chrono_timer",
145*61c4878aSAndroid Build Coastguard Worker    "$dir_pw_chrono:system_timer",
146*61c4878aSAndroid Build Coastguard Worker    "$dir_pw_thread:sleep",
147*61c4878aSAndroid Build Coastguard Worker  ]
148*61c4878aSAndroid Build Coastguard Worker}
149*61c4878aSAndroid Build Coastguard Worker
150*61c4878aSAndroid Build Coastguard Worker# ARM Cortex timer facade implementation
151*61c4878aSAndroid Build Coastguard Worker
152*61c4878aSAndroid Build Coastguard Workerconfig("arm_config") {
153*61c4878aSAndroid Build Coastguard Worker  include_dirs = [ "arm_cortex_cyccnt_public_overrides" ]
154*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
155*61c4878aSAndroid Build Coastguard Worker}
156*61c4878aSAndroid Build Coastguard Worker
157*61c4878aSAndroid Build Coastguard Workerpw_source_set("arm_cortex_timer") {
158*61c4878aSAndroid Build Coastguard Worker  public_configs = [
159*61c4878aSAndroid Build Coastguard Worker    ":public_include_path",
160*61c4878aSAndroid Build Coastguard Worker    ":arm_config",
161*61c4878aSAndroid Build Coastguard Worker  ]
162*61c4878aSAndroid Build Coastguard Worker  public = [ "public/pw_perf_test/internal/cyccnt_timer_interface.h" ]
163*61c4878aSAndroid Build Coastguard Worker  public_deps = [ ":duration_unit" ]
164*61c4878aSAndroid Build Coastguard Worker  visibility = [ ":*" ]
165*61c4878aSAndroid Build Coastguard Worker}
166*61c4878aSAndroid Build Coastguard Worker
167*61c4878aSAndroid Build Coastguard Workerpw_source_set("pw_perf_test_arm_cortex") {
168*61c4878aSAndroid Build Coastguard Worker  public_configs = [ ":arm_config" ]
169*61c4878aSAndroid Build Coastguard Worker  public = [
170*61c4878aSAndroid Build Coastguard Worker    "arm_cortex_cyccnt_public_overrides/pw_perf_test_timer_backend/timer.h",
171*61c4878aSAndroid Build Coastguard Worker  ]
172*61c4878aSAndroid Build Coastguard Worker  public_deps = [ ":arm_cortex_timer" ]
173*61c4878aSAndroid Build Coastguard Worker}
174*61c4878aSAndroid Build Coastguard Worker
175*61c4878aSAndroid Build Coastguard Worker# Module-level targets
176*61c4878aSAndroid Build Coastguard Worker
177*61c4878aSAndroid Build Coastguard Workerpw_perf_test("example_perf_test") {
178*61c4878aSAndroid Build Coastguard Worker  enable_if = pw_perf_test_TIMER_INTERFACE_BACKEND != ""
179*61c4878aSAndroid Build Coastguard Worker  sources = [ "examples/example_perf_test.cc" ]
180*61c4878aSAndroid Build Coastguard Worker}
181*61c4878aSAndroid Build Coastguard Worker
182*61c4878aSAndroid Build Coastguard Workergroup("examples") {
183*61c4878aSAndroid Build Coastguard Worker  deps = [ ":example_perf_test" ]
184*61c4878aSAndroid Build Coastguard Worker}
185*61c4878aSAndroid Build Coastguard Worker
186*61c4878aSAndroid Build Coastguard Workerpw_test_group("tests") {
187*61c4878aSAndroid Build Coastguard Worker  tests = [
188*61c4878aSAndroid Build Coastguard Worker    ":chrono_timer_test",
189*61c4878aSAndroid Build Coastguard Worker    ":state_test",
190*61c4878aSAndroid Build Coastguard Worker    ":timer_facade_test",
191*61c4878aSAndroid Build Coastguard Worker  ]
192*61c4878aSAndroid Build Coastguard Worker}
193*61c4878aSAndroid Build Coastguard Worker
194*61c4878aSAndroid Build Coastguard Workerpw_doc_group("docs") {
195*61c4878aSAndroid Build Coastguard Worker  sources = [ "docs.rst" ]
196*61c4878aSAndroid Build Coastguard Worker  inputs = [ "examples/example_perf_test.cc" ]
197*61c4878aSAndroid Build Coastguard Worker}
198