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