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 15load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 16load("//pw_build:pw_facade.bzl", "pw_facade") 17load("//pw_perf_test:pw_cc_perf_test.bzl", "pw_cc_perf_test") 18load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 19 20package(default_visibility = ["//visibility:public"]) 21 22licenses(["notice"]) 23 24cc_library( 25 name = "pw_perf_test", 26 srcs = [ 27 "framework.cc", 28 "perf_test.cc", 29 "test_info.cc", 30 ], 31 hdrs = [ 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 strip_include_prefix = "public", 37 deps = [ 38 ":event_handler", 39 ":state", 40 ":timer", 41 "//pw_preprocessor", 42 ], 43) 44 45cc_library( 46 name = "state", 47 srcs = [ 48 "state.cc", 49 ], 50 hdrs = [ 51 "public/pw_perf_test/state.h", 52 ], 53 strip_include_prefix = "public", 54 deps = [ 55 ":event_handler", 56 ":timer", 57 "//pw_assert", 58 "//pw_log", 59 ], 60) 61 62pw_cc_test( 63 name = "state_test", 64 srcs = ["state_test.cc"], 65 deps = [":pw_perf_test"], 66) 67 68# Event handlers 69 70cc_library( 71 name = "event_handler", 72 hdrs = ["public/pw_perf_test/event_handler.h"], 73 strip_include_prefix = "public", 74 deps = [":timer"], 75) 76 77cc_library( 78 name = "logging_event_handler", 79 srcs = ["logging_event_handler.cc"], 80 hdrs = [ 81 "public/pw_perf_test/googletest_style_event_handler.h", 82 "public/pw_perf_test/logging_event_handler.h", 83 ], 84 strip_include_prefix = "public", 85 deps = [ 86 ":event_handler", 87 "//pw_log", 88 ], 89) 90 91cc_library( 92 name = "logging_main", 93 srcs = ["logging_main.cc"], 94 deps = [ 95 ":logging_event_handler", 96 ":pw_perf_test", 97 ], 98) 99 100# Timer facade 101 102cc_library( 103 name = "duration_unit", 104 hdrs = [ 105 "public/pw_perf_test/internal/duration_unit.h", 106 ], 107 strip_include_prefix = "public", 108 visibility = ["//visibility:private"], 109) 110 111pw_facade( 112 name = "timer", 113 hdrs = [ 114 "public/pw_perf_test/internal/timer.h", 115 ], 116 backend = ":test_timer_backend", 117 strip_include_prefix = "public", 118 deps = [ 119 ":duration_unit", 120 ], 121) 122 123label_flag( 124 name = "test_timer_backend", 125 build_setting_default = ":timer_multiplexer", 126) 127 128cc_library( 129 name = "timer_multiplexer", 130 visibility = ["//targets:__pkg__"], 131 deps = select({ 132 "//conditions:default": [":chrono_timer"], 133 }), 134) 135 136pw_cc_test( 137 name = "timer_test", 138 srcs = ["timer_test.cc"], 139 deps = [ 140 ":timer", 141 "//pw_chrono:system_clock", 142 "//pw_thread:sleep", 143 ], 144) 145 146# Chrono timer facade implementation 147 148cc_library( 149 name = "chrono_timer", 150 hdrs = [ 151 "chrono_public_overrides/pw_perf_test_timer_backend/timer.h", 152 "public/pw_perf_test/internal/chrono_timer_interface.h", 153 ], 154 includes = [ 155 "chrono_public_overrides", 156 "public", 157 ], 158 target_compatible_with = incompatible_with_mcu(), 159 deps = [ 160 ":duration_unit", 161 ":timer.facade", 162 "//pw_chrono:system_clock", 163 ], 164) 165 166pw_cc_test( 167 name = "chrono_timer_test", 168 srcs = ["chrono_test.cc"], 169 deps = [ 170 ":chrono_timer", 171 "//pw_chrono:system_clock", 172 "//pw_thread:sleep", 173 ], 174) 175 176# ARM Cortex timer facade implementation 177 178cc_library( 179 name = "arm_cortex_timer", 180 hdrs = [ 181 "arm_cortex_cyccnt_public_overrides/pw_perf_test_timer_backend/timer.h", 182 "public/pw_perf_test/internal/cyccnt_timer_interface.h", 183 ], 184 includes = [ 185 "arm_cortex_cyccnt_public_overrides", 186 "public", 187 ], 188 target_compatible_with = incompatible_with_mcu(), 189 deps = [ 190 ":duration_unit", 191 ":timer.facade", 192 ], 193) 194 195# Module-level targets 196 197pw_cc_perf_test( 198 name = "example_perf_test", 199 srcs = ["examples/example_perf_test.cc"], 200) 201 202# Bazel does not yet support building docs. 203filegroup( 204 name = "docs", 205 srcs = ["docs.rst"], 206) 207 208filegroup( 209 name = "doxygen", 210 srcs = [ 211 "public/pw_perf_test/event_handler.h", 212 "public/pw_perf_test/perf_test.h", 213 ], 214) 215