1# Copyright 2020 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_test", 20) 21load("//pw_protobuf_compiler:proto.bzl", "pw_proto_library") 22load("@com_google_protobuf//:protobuf.bzl", "py_proto_library") 23 24package(default_visibility = ["//visibility:public"]) 25 26licenses(["notice"]) 27 28pw_cc_library( 29 name = "epoch", 30 hdrs = [ 31 "public/pw_chrono/epoch.h", 32 ], 33 includes = ["public"], 34) 35 36pw_cc_facade( 37 name = "system_clock_facade", 38 hdrs = [ 39 "public/pw_chrono/internal/system_clock_macros.h", 40 "public/pw_chrono/system_clock.h", 41 ], 42 includes = ["public"], 43 deps = [ 44 ":epoch", 45 "//pw_preprocessor", 46 ], 47) 48 49pw_cc_library( 50 name = "system_clock", 51 srcs = [ 52 "system_clock.cc", 53 ], 54 deps = [ 55 ":system_clock_facade", 56 "@pigweed_config//:pw_chrono_system_clock_backend", 57 ], 58) 59 60pw_cc_library( 61 name = "system_clock_backend_multiplexer", 62 visibility = ["@pigweed_config//:__pkg__"], 63 deps = select({ 64 "//pw_build/constraints/rtos:freertos": ["//pw_chrono_freertos:system_clock"], 65 "//pw_build/constraints/rtos:embos": ["//pw_chrono_embos:system_clock"], 66 "//pw_build/constraints/rtos:threadx": ["//pw_chrono_threadx:system_clock"], 67 "//conditions:default": ["//pw_chrono_stl:system_clock"], 68 }), 69) 70 71pw_cc_library( 72 name = "system_timer_facade", 73 hdrs = [ 74 "public/pw_chrono/system_timer.h", 75 ], 76 includes = ["public"], 77 deps = [ 78 ":system_clock", 79 "//pw_function", 80 ], 81) 82 83pw_cc_library( 84 name = "system_timer", 85 deps = [ 86 ":system_timer_facade", 87 "@pigweed_config//:pw_chrono_system_timer_backend", 88 ], 89) 90 91pw_cc_library( 92 name = "system_timer_backend_multiplexer", 93 visibility = ["@pigweed_config//:__pkg__"], 94 deps = select({ 95 "//pw_build/constraints/rtos:freertos": ["//pw_chrono_freertos:system_timer"], 96 "//pw_build/constraints/rtos:embos": ["//pw_chrono_embos:system_timer"], 97 "//conditions:default": ["//pw_chrono_stl:system_timer"], 98 }), 99) 100 101proto_library( 102 name = "chrono_proto", 103 srcs = [ 104 "chrono.proto", 105 ], 106 import_prefix = "pw_chrono_protos", 107 strip_import_prefix = "/pw_chrono", 108) 109 110py_proto_library( 111 name = "chrono_proto_pb2", 112 srcs = ["chrono.proto"], 113) 114 115pw_proto_library( 116 name = "chrono_proto_cc", 117 deps = [":chrono_proto"], 118) 119 120pw_cc_library( 121 name = "simulated_system_clock", 122 hdrs = [ 123 "public/pw_chrono/simulated_system_clock.h", 124 ], 125 deps = [ 126 ":system_clock", 127 "//pw_sync:interrupt_spin_lock", 128 ], 129) 130 131pw_cc_test( 132 name = "simulated_system_clock_test", 133 srcs = [ 134 "simulated_system_clock_test.cc", 135 ], 136 deps = [ 137 ":simulated_system_clock", 138 "//pw_unit_test", 139 ], 140) 141 142pw_cc_test( 143 name = "system_clock_facade_test", 144 srcs = [ 145 "system_clock_facade_test.cc", 146 "system_clock_facade_test_c.c", 147 ], 148 deps = [ 149 ":system_clock", 150 "//pw_preprocessor", 151 "//pw_unit_test", 152 ], 153) 154 155pw_cc_test( 156 name = "system_timer_facade_test", 157 srcs = [ 158 "system_timer_facade_test.cc", 159 ], 160 deps = [ 161 ":system_clock", 162 ":system_timer", 163 "//pw_sync:thread_notification", 164 "//pw_unit_test", 165 ], 166) 167