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_library", 18 "pw_cc_test", 19) 20 21package(default_visibility = ["//visibility:public"]) 22 23licenses(["notice"]) # Apache License 2.0 24 25# TODO(pwbug/101): Need to add support for facades/backends to Bazel. 26PW_THREAD_ID_BACKEND = "//pw_thread_stl:id" 27PW_THREAD_SLEEP_BACKEND = "//pw_thread_stl:sleep" 28PW_THREAD_THREAD_BACKEND = "//pw_thread_stl:thread" 29PW_THREAD_YIELD_BACKEND = "//pw_thread_stl:yield" 30 31pw_cc_library( 32 name = "id_facade", 33 hdrs = [ 34 "public/pw_thread/id.h", 35 ], 36 includes = ["public"], 37 deps = [ 38 PW_THREAD_ID_BACKEND + "_headers", 39 ], 40) 41 42pw_cc_library( 43 name = "id", 44 deps = [ 45 ":id_facade", 46 PW_THREAD_ID_BACKEND + "_headers", 47 ], 48) 49 50pw_cc_library( 51 name = "id_backend", 52 deps = [ 53 PW_THREAD_ID_BACKEND, 54 ], 55) 56 57pw_cc_library( 58 name = "sleep_facade", 59 hdrs = [ 60 "public/pw_thread/sleep.h", 61 ], 62 includes = ["public"], 63 srcs = [ 64 "sleep.cc" 65 ], 66 deps = [ 67 PW_THREAD_SLEEP_BACKEND + "_headers", 68 "//pw_chrono:system_clock", 69 "//pw_preprocessor", 70 ], 71) 72 73pw_cc_library( 74 name = "sleep", 75 deps = [ 76 ":sleep_facade", 77 PW_THREAD_SLEEP_BACKEND + "_headers", 78 ], 79) 80 81pw_cc_library( 82 name = "sleep_backend", 83 deps = [ 84 PW_THREAD_SLEEP_BACKEND, 85 ], 86) 87 88pw_cc_library( 89 name = "thread_facade", 90 hdrs = [ 91 "public/pw_thread/thread.h", 92 ], 93 includes = ["public"], 94 deps = [ 95 ":id_facade", 96 PW_THREAD_THREAD_BACKEND + "_headers", 97 ], 98) 99 100pw_cc_library( 101 name = "thread", 102 deps = [ 103 ":thread_facade", 104 ":thread_core", 105 PW_THREAD_THREAD_BACKEND + "_headers", 106 ], 107 srcs = [ 108 "thread.cc" 109 ], 110) 111 112pw_cc_library( 113 name = "thread_backend", 114 deps = [ 115 PW_THREAD_THREAD_BACKEND, 116 ], 117) 118 119pw_cc_library( 120 name = "thread_core", 121 hdrs = [ 122 "public/pw_thread/thread_core.h", 123 ], 124 includes = ["public"], 125) 126 127pw_cc_library( 128 name = "yield_facade", 129 hdrs = [ 130 "public/pw_thread/yield.h", 131 ], 132 includes = ["public"], 133 srcs = [ 134 "yield.cc" 135 ], 136 deps = [ 137 PW_THREAD_YIELD_BACKEND + "_headers", 138 "//pw_preprocessor", 139 ], 140) 141 142pw_cc_library( 143 name = "yield", 144 deps = [ 145 ":yield_facade", 146 PW_THREAD_YIELD_BACKEND + "_headers", 147 ], 148) 149 150pw_cc_library( 151 name = "yield_backend", 152 deps = [ 153 PW_THREAD_YIELD_BACKEND, 154 ], 155) 156 157pw_cc_library( 158 name = "test_threads_header", 159 hdrs = [ 160 "public/pw_thread/test_threads.h", 161 ], 162 deps = [ 163 ":thread", 164 ], 165) 166 167# To instantiate this as a pw_cc_test, depend on this pw_cc_library and the 168# pw_cc_library which implements the backend for test_threads_header. See 169# //pw_thread:thread_backend_test as an example. 170pw_cc_library( 171 name = "thread_facade_test", 172 srcs = [ 173 "thread_facade_test.cc", 174 ], 175 deps = [ 176 ":thread", 177 ":id", 178 ":test_threads_header", 179 "//pw_chrono:system_clock", 180 "//pw_sync:binary_semaphore", 181 "//pw_unit_test", 182 ], 183) 184 185pw_cc_test( 186 name = "id_facade_test", 187 srcs = [ 188 "id_facade_test.cc", 189 ], 190 deps = [ 191 ":id", 192 "//pw_unit_test", 193 ], 194) 195 196pw_cc_test( 197 name = "sleep_facade_test", 198 srcs = [ 199 "sleep_facade_test.cc", 200 "sleep_facade_test_c.c", 201 ], 202 deps = [ 203 ":sleep", 204 "//pw_chrono:system_clock", 205 "//pw_preprocessor", 206 "//pw_unit_test", 207 ], 208) 209 210pw_cc_test( 211 name = "yield_facade_test", 212 srcs = [ 213 "yield_facade_test.cc", 214 "yield_facade_test_c.c", 215 ], 216 deps = [ 217 ":yield", 218 "//pw_preprocessor", 219 "//pw_unit_test", 220 ], 221) 222