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