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_facade", 18 "pw_cc_library", 19 "pw_cc_perf_test", 20 "pw_cc_test", 21) 22load( 23 "//pw_build:selects.bzl", 24 "TARGET_COMPATIBLE_WITH_HOST_SELECT", 25) 26 27package(default_visibility = ["//visibility:public"]) 28 29licenses(["notice"]) 30 31pw_cc_library( 32 name = "duration_unit", 33 hdrs = [ 34 "public/pw_perf_test/internal/duration_unit.h", 35 ], 36 includes = ["public"], 37 visibility = ["//visibility:private"], 38) 39 40pw_cc_facade( 41 name = "timer_interface_facade", 42 hdrs = [ 43 "public/pw_perf_test/internal/timer.h", 44 ], 45 includes = ["public"], 46 visibility = ["//visibility:private"], 47 deps = [ 48 ":duration_unit", 49 ], 50) 51 52pw_cc_library( 53 name = "timer", 54 deps = [ 55 ":timer_interface_facade", 56 "@pigweed_config//:pw_perf_test_timer_backend", 57 ], 58) 59 60pw_cc_library( 61 name = "timer_multiplexer", 62 visibility = ["@pigweed_config//:__pkg__"], 63 deps = select({ 64 "//conditions:default": [":chrono_timer"], 65 }), 66) 67 68# EventHandler Configuraitions 69 70pw_cc_library( 71 name = "event_handler", 72 hdrs = ["public/pw_perf_test/event_handler.h"], 73 includes = ["public"], 74 deps = [":timer"], 75) 76 77pw_cc_library( 78 name = "pw_perf_test", 79 srcs = ["perf_test.cc"], 80 hdrs = ["public/pw_perf_test/perf_test.h"], 81 includes = ["public"], 82 deps = [ 83 ":event_handler", 84 ":timer", 85 "//pw_assert", 86 "//pw_log", 87 ], 88) 89 90pw_cc_library( 91 name = "google_test_style_event_strings", 92 hdrs = ["public/pw_perf_test/googletest_style_event_handler.h"], 93) 94 95pw_cc_library( 96 name = "log_main_handler", 97 srcs = ["log_perf_handler.cc"], 98 hdrs = ["public/pw_perf_test/log_perf_handler.h"], 99 includes = [ 100 "public", 101 ], 102 deps = [ 103 ":event_handler", 104 ":google_test_style_event_strings", 105 "//pw_log", 106 ], 107) 108 109pw_cc_library( 110 name = "logging_main", 111 srcs = ["log_perf_handler_main.cc"], 112 deps = [ 113 ":log_main_handler", 114 ":pw_perf_test", 115 ], 116) 117 118pw_cc_perf_test( 119 name = "generic_test", 120 srcs = ["performance_test_generic.cc"], 121) 122 123# Test Declarations 124 125pw_cc_test( 126 name = "perf_test_test", 127 srcs = ["perf_test_test.cc"], 128 deps = [":pw_perf_test"], 129) 130 131pw_cc_test( 132 name = "timer_test", 133 srcs = ["timer_test.cc"], 134 deps = [ 135 ":timer", 136 "//pw_chrono:system_clock", 137 "//pw_thread:sleep", 138 ], 139) 140 141pw_cc_test( 142 name = "chrono_timer_test", 143 srcs = ["chrono_test.cc"], 144 deps = [ 145 ":chrono_timer", 146 "//pw_chrono:system_clock", 147 "//pw_thread:sleep", 148 ], 149) 150 151pw_cc_test( 152 name = "state_test", 153 srcs = ["state_test.cc"], 154 deps = [":pw_perf_test"], 155) 156 157# Bazel does not yet support building docs. 158filegroup( 159 name = "docs", 160 srcs = ["docs.rst"], 161) 162 163# Chrono Implementation 164 165pw_cc_library( 166 name = "chrono_timer_headers", 167 hdrs = [ 168 "chrono_public_overrides/pw_perf_test_timer_backend/timer.h", 169 "public/pw_perf_test/internal/chrono_timer_interface.h", 170 ], 171 includes = [ 172 "chrono_public_overrides", 173 "public", 174 ], 175 deps = [ 176 ":duration_unit", 177 "//pw_chrono:system_clock", 178 ], 179) 180 181pw_cc_library( 182 name = "chrono_timer", 183 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 184 deps = [ 185 ":chrono_timer_headers", 186 ":timer_interface_facade", 187 ], 188) 189 190# ARM Cortex Implementation 191 192pw_cc_library( 193 name = "arm_cortex_timer_headers", 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 deps = [":duration_unit"], 203) 204 205pw_cc_library( 206 name = "arm_cortex_timer", 207 target_compatible_with = select(TARGET_COMPATIBLE_WITH_HOST_SELECT), 208 deps = [ 209 ":arm_cortex_timer_headers", 210 ":timer_interface_facade", 211 ], 212) 213