Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 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 | |
| 15 | load( |
| 16 | "//pw_build:pigweed.bzl", |
| 17 | "pw_cc_library", |
| 18 | "pw_cc_test", |
| 19 | ) |
| 20 | |
| 21 | package(default_visibility = ["//visibility:public"]) |
| 22 | |
| 23 | licenses(["notice"]) # Apache License 2.0 |
| 24 | |
| 25 | # TODO(pwbug/101): Need to add support for facades/backends to Bazel. |
| 26 | PW_THREAD_ID_BACKEND = "//pw_thread_stl:id" |
| 27 | PW_THREAD_SLEEP_BACKEND = "//pw_thread_stl:sleep" |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame^] | 28 | PW_THREAD_THREAD_BACKEND = "//pw_thread_stl:thread" |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 29 | PW_THREAD_YIELD_BACKEND = "//pw_thread_stl:yield" |
| 30 | |
| 31 | pw_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 | |
| 42 | pw_cc_library( |
| 43 | name = "id", |
| 44 | deps = [ |
| 45 | ":id_facade", |
| 46 | PW_THREAD_ID_BACKEND + "_headers", |
| 47 | ], |
| 48 | ) |
| 49 | |
| 50 | pw_cc_library( |
| 51 | name = "id_backend", |
| 52 | deps = [ |
| 53 | PW_THREAD_ID_BACKEND, |
| 54 | ], |
| 55 | ) |
| 56 | |
| 57 | pw_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 | |
| 73 | pw_cc_library( |
| 74 | name = "sleep", |
| 75 | deps = [ |
| 76 | ":sleep_facade", |
| 77 | PW_THREAD_SLEEP_BACKEND + "_headers", |
| 78 | ], |
| 79 | ) |
| 80 | |
| 81 | pw_cc_library( |
| 82 | name = "sleep_backend", |
| 83 | deps = [ |
| 84 | PW_THREAD_SLEEP_BACKEND, |
| 85 | ], |
| 86 | ) |
| 87 | |
| 88 | pw_cc_library( |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame^] | 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 | |
| 100 | pw_cc_library( |
| 101 | name = "thread", |
| 102 | deps = [ |
| 103 | ":thread_facade", |
| 104 | PW_THREAD_THREAD_BACKEND + "_headers", |
| 105 | ], |
| 106 | ) |
| 107 | |
| 108 | pw_cc_library( |
| 109 | name = "thread_backend", |
| 110 | deps = [ |
| 111 | PW_THREAD_THREAD_BACKEND, |
| 112 | ], |
| 113 | ) |
| 114 | |
| 115 | pw_cc_library( |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 116 | name = "yield_facade", |
| 117 | hdrs = [ |
| 118 | "public/pw_thread/yield.h", |
| 119 | ], |
| 120 | includes = ["public"], |
| 121 | srcs = [ |
| 122 | "yield.cc" |
| 123 | ], |
| 124 | deps = [ |
| 125 | PW_THREAD_YIELD_BACKEND + "_headers", |
| 126 | "//pw_preprocessor", |
| 127 | ], |
| 128 | ) |
| 129 | |
| 130 | pw_cc_library( |
| 131 | name = "yield", |
| 132 | deps = [ |
| 133 | ":yield_facade", |
| 134 | PW_THREAD_YIELD_BACKEND + "_headers", |
| 135 | ], |
| 136 | ) |
| 137 | |
| 138 | pw_cc_library( |
| 139 | name = "yield_backend", |
| 140 | deps = [ |
| 141 | PW_THREAD_YIELD_BACKEND, |
| 142 | ], |
| 143 | ) |
| 144 | |
Ewout van Bekkum | 0f3901e | 2020-12-22 12:00:18 -0800 | [diff] [blame^] | 145 | pw_cc_library( |
| 146 | name = "test_threads_header", |
| 147 | hdrs = [ |
| 148 | "public/pw_thread/test_threads.h", |
| 149 | ], |
| 150 | deps = [ |
| 151 | ":thread", |
| 152 | ], |
| 153 | ) |
| 154 | |
| 155 | # To instantiate this as a pw_cc_test, depend on this pw_cc_library and the |
| 156 | # pw_cc_library which implements the backend for test_threads_header. See |
| 157 | # //pw_thread:thread_backend_test as an example. |
| 158 | pw_cc_library( |
| 159 | name = "thread_facade_test", |
| 160 | srcs = [ |
| 161 | "thread_facade_test.cc", |
| 162 | ], |
| 163 | deps = [ |
| 164 | ":thread", |
| 165 | ":id", |
| 166 | ":test_threads_header", |
| 167 | "//pw_unit_test", |
| 168 | ], |
| 169 | ) |
| 170 | |
Ewout van Bekkum | e3b5603 | 2020-12-22 12:00:18 -0800 | [diff] [blame] | 171 | pw_cc_test( |
| 172 | name = "id_facade_test", |
| 173 | srcs = [ |
| 174 | "id_facade_test.cc", |
| 175 | ], |
| 176 | deps = [ |
| 177 | ":id", |
| 178 | "//pw_unit_test", |
| 179 | ], |
| 180 | ) |
| 181 | |
| 182 | pw_cc_test( |
| 183 | name = "sleep_facade_test", |
| 184 | srcs = [ |
| 185 | "sleep_facade_test.cc", |
| 186 | "sleep_facade_test_c.c", |
| 187 | ], |
| 188 | deps = [ |
| 189 | ":sleep", |
| 190 | "//pw_chrono:system_clock", |
| 191 | "//pw_preprocessor", |
| 192 | "//pw_unit_test", |
| 193 | ], |
| 194 | ) |
| 195 | |
| 196 | pw_cc_test( |
| 197 | name = "yield_facade_test", |
| 198 | srcs = [ |
| 199 | "yield_facade_test.cc", |
| 200 | "yield_facade_test_c.c", |
| 201 | ], |
| 202 | deps = [ |
| 203 | ":yield", |
| 204 | "//pw_preprocessor", |
| 205 | "//pw_unit_test", |
| 206 | ], |
| 207 | ) |