blob: d4d786096abe012e2c712c8bab7d524716924391 [file] [log] [blame]
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -07001# 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",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080017 "pw_cc_facade",
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070018 "pw_cc_library",
19 "pw_cc_test",
20)
21
22package(default_visibility = ["//visibility:public"])
23
24licenses(["notice"]) # Apache License 2.0
25
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070026pw_cc_library(
27 name = "epoch",
28 hdrs = [
29 "public/pw_chrono/epoch.h",
30 ],
31 includes = ["public"],
32)
33
Nathaniel Broughc2d57812021-04-18 22:52:00 +080034pw_cc_facade(
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070035 name = "system_clock_facade",
36 hdrs = [
Ewout van Bekkum830d5d12021-01-28 18:58:03 -080037 "public/pw_chrono/internal/system_clock_macros.h",
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070038 "public/pw_chrono/system_clock.h",
39 ],
40 includes = ["public"],
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070041 deps = [
42 ":epoch",
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070043 "//pw_preprocessor",
44 ],
45)
46
47pw_cc_library(
48 name = "system_clock",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080049 srcs = [
50 "system_clock.cc",
51 ],
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070052 deps = [
53 ":system_clock_facade",
Nathaniel Broughc2d57812021-04-18 22:52:00 +080054 "@pigweed_config//:pw_chrono_backend",
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070055 ],
56)
57
58pw_cc_library(
Nathaniel Broughc2d57812021-04-18 22:52:00 +080059 name = "backend_multiplexer",
60 visibility = ["@pigweed_config//:__pkg__"],
61 deps = select({
62 "//pw_build/constraints/rtos:freertos": ["//pw_chrono_freertos:system_clock"],
63 "//pw_build/constraints/rtos:embos": ["//pw_chrono_embos:system_clock"],
64 "//pw_build/constraints/rtos:threadx": ["//pw_chrono_threadx:system_clock"],
65 "//conditions:default": ["//pw_chrono_stl:system_clock"],
66 }),
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070067)
68
69pw_cc_library(
70 name = "simulated_system_clock",
71 hdrs = [
72 "public/pw_chrono/simulated_system_clock.h",
73 ],
74 deps = [
75 ":system_clock",
Ewout van Bekkumda2a62d2021-03-12 11:34:47 -080076 "//pw_sync:interrupt_spin_lock",
Ewout van Bekkum3c61ae92020-10-30 15:52:25 -070077 ],
78)
79
80pw_cc_test(
81 name = "simulated_system_clock_test",
82 srcs = [
83 "simulated_system_clock_test.cc",
84 ],
85 deps = [
86 ":simulated_system_clock",
87 "//pw_unit_test",
88 ],
89)
90
91pw_cc_test(
92 name = "system_clock_facade_test",
93 srcs = [
94 "system_clock_facade_test.cc",
95 "system_clock_facade_test_c.c",
96 ],
97 deps = [
98 ":system_clock",
99 "//pw_preprocessor",
100 "//pw_unit_test",
101 ],
102)