Ewout van Bekkum | f010606 | 2021-05-06 14:08:33 -0700 | [diff] [blame] | 1 | # Copyright 2021 The Pigweed Authors |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 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 | import("//build_overrides/pigweed.gni") |
| 16 | |
| 17 | import("$dir_pw_build/facade.gni") |
| 18 | import("$dir_pw_build/target_types.gni") |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 19 | import("$dir_pw_chrono/backend.gni") |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 20 | import("$dir_pw_docgen/docs.gni") |
| 21 | import("$dir_pw_unit_test/test.gni") |
Wyatt Hepler | ae93f42 | 2020-12-14 11:46:19 -0800 | [diff] [blame] | 22 | import("backend.gni") |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 23 | |
| 24 | config("public_include_path") { |
| 25 | include_dirs = [ "public" ] |
| 26 | visibility = [ ":*" ] |
| 27 | } |
| 28 | |
Ewout van Bekkum | f010606 | 2021-05-06 14:08:33 -0700 | [diff] [blame] | 29 | config("backend_config") { |
| 30 | include_dirs = [ "public_overrides" ] |
| 31 | visibility = [ ":*" ] |
| 32 | } |
| 33 | |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 34 | pw_facade("binary_semaphore") { |
| 35 | backend = pw_sync_BINARY_SEMAPHORE_BACKEND |
| 36 | public_configs = [ ":public_include_path" ] |
| 37 | public = [ "public/pw_sync/binary_semaphore.h" ] |
| 38 | public_deps = [ |
| 39 | "$dir_pw_chrono:system_clock", |
| 40 | "$dir_pw_preprocessor", |
| 41 | ] |
| 42 | sources = [ "binary_semaphore.cc" ] |
| 43 | } |
| 44 | |
| 45 | pw_facade("counting_semaphore") { |
| 46 | backend = pw_sync_COUNTING_SEMAPHORE_BACKEND |
| 47 | public_configs = [ ":public_include_path" ] |
| 48 | public = [ "public/pw_sync/counting_semaphore.h" ] |
| 49 | public_deps = [ |
| 50 | "$dir_pw_chrono:system_clock", |
| 51 | "$dir_pw_preprocessor", |
| 52 | ] |
| 53 | sources = [ "counting_semaphore.cc" ] |
| 54 | } |
| 55 | |
Ewout van Bekkum | cc9ef83 | 2021-04-08 08:51:16 -0700 | [diff] [blame] | 56 | pw_source_set("lock_annotations") { |
| 57 | public_configs = [ ":public_include_path" ] |
| 58 | public = [ "public/pw_sync/lock_annotations.h" ] |
| 59 | public_deps = [ "$dir_pw_preprocessor" ] |
| 60 | } |
| 61 | |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 62 | pw_source_set("borrow") { |
| 63 | public_configs = [ ":public_include_path" ] |
| 64 | public = [ "public/pw_sync/borrow.h" ] |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 65 | public_deps = [ |
Ewout van Bekkum | afadef9 | 2021-10-20 11:56:06 -0700 | [diff] [blame] | 66 | ":lock_annotations", |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 67 | ":virtual_basic_lockable", |
| 68 | dir_pw_assert, |
| 69 | ] |
| 70 | } |
| 71 | |
| 72 | pw_source_set("virtual_basic_lockable") { |
| 73 | public_configs = [ ":public_include_path" ] |
| 74 | public = [ "public/pw_sync/virtual_basic_lockable.h" ] |
| 75 | public_deps = [ |
| 76 | ":lock_annotations", |
| 77 | dir_pw_polyfill, |
| 78 | ] |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 79 | } |
| 80 | |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 81 | pw_facade("mutex") { |
| 82 | backend = pw_sync_MUTEX_BACKEND |
| 83 | public_configs = [ ":public_include_path" ] |
| 84 | public = [ "public/pw_sync/mutex.h" ] |
Ewout van Bekkum | cc9ef83 | 2021-04-08 08:51:16 -0700 | [diff] [blame] | 85 | public_deps = [ |
| 86 | ":lock_annotations", |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 87 | ":virtual_basic_lockable", |
Ewout van Bekkum | cc9ef83 | 2021-04-08 08:51:16 -0700 | [diff] [blame] | 88 | "$dir_pw_preprocessor", |
| 89 | ] |
Ewout van Bekkum | 6f5b8fb | 2021-04-06 16:15:22 -0700 | [diff] [blame] | 90 | sources = [ "mutex.cc" ] |
| 91 | } |
| 92 | |
| 93 | pw_facade("timed_mutex") { |
| 94 | backend = pw_sync_TIMED_MUTEX_BACKEND |
| 95 | public_configs = [ ":public_include_path" ] |
| 96 | public = [ "public/pw_sync/timed_mutex.h" ] |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 97 | public_deps = [ |
Ewout van Bekkum | 6f5b8fb | 2021-04-06 16:15:22 -0700 | [diff] [blame] | 98 | ":mutex", |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 99 | ":virtual_basic_lockable", |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 100 | "$dir_pw_chrono:system_clock", |
| 101 | "$dir_pw_preprocessor", |
| 102 | ] |
Ewout van Bekkum | 6f5b8fb | 2021-04-06 16:15:22 -0700 | [diff] [blame] | 103 | sources = [ "timed_mutex.cc" ] |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 104 | } |
| 105 | |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 106 | pw_facade("interrupt_spin_lock") { |
| 107 | backend = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND |
| 108 | public_configs = [ ":public_include_path" ] |
| 109 | public = [ "public/pw_sync/interrupt_spin_lock.h" ] |
Ewout van Bekkum | cc9ef83 | 2021-04-08 08:51:16 -0700 | [diff] [blame] | 110 | public_deps = [ |
| 111 | ":lock_annotations", |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 112 | ":virtual_basic_lockable", |
Ewout van Bekkum | cc9ef83 | 2021-04-08 08:51:16 -0700 | [diff] [blame] | 113 | "$dir_pw_preprocessor", |
| 114 | ] |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 115 | sources = [ "interrupt_spin_lock.cc" ] |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 116 | } |
| 117 | |
Ewout van Bekkum | f010606 | 2021-05-06 14:08:33 -0700 | [diff] [blame] | 118 | pw_facade("thread_notification") { |
| 119 | backend = pw_sync_THREAD_NOTIFICATION_BACKEND |
| 120 | public_configs = [ ":public_include_path" ] |
| 121 | public = [ "public/pw_sync/thread_notification.h" ] |
| 122 | } |
| 123 | |
| 124 | pw_facade("timed_thread_notification") { |
| 125 | backend = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND |
| 126 | public_configs = [ ":public_include_path" ] |
| 127 | public = [ "public/pw_sync/timed_thread_notification.h" ] |
| 128 | public_deps = [ |
| 129 | ":thread_notification", |
| 130 | "$dir_pw_chrono:system_clock", |
| 131 | ] |
| 132 | } |
| 133 | |
| 134 | # This target provides the backend for pw::sync::ThreadNotification based on |
| 135 | # pw::sync::BinarySemaphore. |
| 136 | pw_source_set("binary_semaphore_thread_notification_backend") { |
| 137 | public_configs = [ |
| 138 | ":public_include_path", |
| 139 | ":backend_config", |
| 140 | ] |
| 141 | public = [ |
| 142 | "public/pw_sync/backends/binary_semaphore_thread_notification_inline.h", |
| 143 | "public/pw_sync/backends/binary_semaphore_thread_notification_native.h", |
| 144 | "public_overrides/pw_sync_backend/thread_notification_inline.h", |
| 145 | "public_overrides/pw_sync_backend/thread_notification_native.h", |
| 146 | ] |
| 147 | public_deps = [ |
| 148 | ":binary_semaphore", |
| 149 | ":thread_notification.facade", |
| 150 | ] |
| 151 | } |
| 152 | |
| 153 | # This target provides the backend for pw::sync::TimedThreadNotification based |
| 154 | # on pw::sync::BinarySemaphore. |
| 155 | pw_source_set("binary_semaphore_timed_thread_notification_backend") { |
| 156 | public_configs = [ |
| 157 | ":public_include_path", |
| 158 | ":backend_config", |
| 159 | ] |
| 160 | public = [ |
| 161 | "public/pw_sync/backends/binary_semaphore_timed_thread_notification_inline.h", |
| 162 | "public_overrides/pw_sync_backend/timed_thread_notification_inline.h", |
| 163 | ] |
| 164 | public_deps = [ |
| 165 | ":binary_semaphore_thread_notification_backend", |
| 166 | ":timed_thread_notification.facade", |
| 167 | "$dir_pw_chrono:system_clock", |
| 168 | ] |
| 169 | } |
| 170 | |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 171 | pw_source_set("yield_core") { |
| 172 | public = [ "public/pw_sync/yield_core.h" ] |
| 173 | public_configs = [ ":public_include_path" ] |
| 174 | } |
| 175 | |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 176 | pw_test_group("tests") { |
| 177 | tests = [ |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 178 | ":borrow_test", |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 179 | ":binary_semaphore_facade_test", |
| 180 | ":counting_semaphore_facade_test", |
| 181 | ":mutex_facade_test", |
Ewout van Bekkum | 6f5b8fb | 2021-04-06 16:15:22 -0700 | [diff] [blame] | 182 | ":timed_mutex_facade_test", |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 183 | ":interrupt_spin_lock_facade_test", |
Ewout van Bekkum | f010606 | 2021-05-06 14:08:33 -0700 | [diff] [blame] | 184 | ":thread_notification_facade_test", |
| 185 | ":timed_thread_notification_facade_test", |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 186 | ] |
| 187 | } |
| 188 | |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 189 | pw_test("borrow_test") { |
| 190 | sources = [ "borrow_test.cc" ] |
| 191 | deps = [ |
| 192 | ":borrow", |
Ewout van Bekkum | baf2fdc | 2021-09-09 14:11:51 -0700 | [diff] [blame] | 193 | ":virtual_basic_lockable", |
Ewout van Bekkum | f6c3a78 | 2021-08-31 11:23:35 -0700 | [diff] [blame] | 194 | dir_pw_assert, |
| 195 | ] |
| 196 | } |
| 197 | |
Ewout van Bekkum | 9618d8a | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 198 | pw_test("binary_semaphore_facade_test") { |
| 199 | enable_if = pw_sync_BINARY_SEMAPHORE_BACKEND != "" |
| 200 | sources = [ |
| 201 | "binary_semaphore_facade_test.cc", |
| 202 | "binary_semaphore_facade_test_c.c", |
| 203 | ] |
| 204 | deps = [ |
| 205 | ":binary_semaphore", |
| 206 | "$dir_pw_preprocessor", |
| 207 | pw_sync_BINARY_SEMAPHORE_BACKEND, |
| 208 | ] |
| 209 | } |
| 210 | |
| 211 | pw_test("counting_semaphore_facade_test") { |
| 212 | enable_if = pw_sync_COUNTING_SEMAPHORE_BACKEND != "" |
| 213 | sources = [ |
| 214 | "counting_semaphore_facade_test.cc", |
| 215 | "counting_semaphore_facade_test_c.c", |
| 216 | ] |
| 217 | deps = [ |
| 218 | ":counting_semaphore", |
| 219 | "$dir_pw_preprocessor", |
| 220 | pw_sync_COUNTING_SEMAPHORE_BACKEND, |
| 221 | ] |
| 222 | } |
| 223 | |
| 224 | pw_test("mutex_facade_test") { |
| 225 | enable_if = pw_sync_MUTEX_BACKEND != "" |
| 226 | sources = [ |
| 227 | "mutex_facade_test.cc", |
| 228 | "mutex_facade_test_c.c", |
| 229 | ] |
| 230 | deps = [ |
| 231 | ":mutex", |
| 232 | "$dir_pw_preprocessor", |
| 233 | pw_sync_MUTEX_BACKEND, |
| 234 | ] |
| 235 | } |
| 236 | |
Ewout van Bekkum | 6f5b8fb | 2021-04-06 16:15:22 -0700 | [diff] [blame] | 237 | pw_test("timed_mutex_facade_test") { |
| 238 | enable_if = pw_sync_TIMED_MUTEX_BACKEND != "" |
| 239 | sources = [ |
| 240 | "timed_mutex_facade_test.cc", |
| 241 | "timed_mutex_facade_test_c.c", |
| 242 | ] |
| 243 | deps = [ |
| 244 | ":timed_mutex", |
| 245 | "$dir_pw_preprocessor", |
| 246 | pw_sync_TIMED_MUTEX_BACKEND, |
| 247 | ] |
| 248 | } |
| 249 | |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 250 | pw_test("interrupt_spin_lock_facade_test") { |
| 251 | enable_if = pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 252 | sources = [ |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 253 | "interrupt_spin_lock_facade_test.cc", |
| 254 | "interrupt_spin_lock_facade_test_c.c", |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 255 | ] |
| 256 | deps = [ |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 257 | ":interrupt_spin_lock", |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 258 | "$dir_pw_preprocessor", |
Ewout van Bekkum | 126e011 | 2021-03-12 10:59:49 -0800 | [diff] [blame] | 259 | pw_sync_INTERRUPT_SPIN_LOCK_BACKEND, |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 260 | ] |
| 261 | } |
| 262 | |
Ewout van Bekkum | f010606 | 2021-05-06 14:08:33 -0700 | [diff] [blame] | 263 | pw_test("thread_notification_facade_test") { |
| 264 | enable_if = pw_sync_THREAD_NOTIFICATION_BACKEND != "" |
| 265 | sources = [ "thread_notification_facade_test.cc" ] |
| 266 | deps = [ |
| 267 | ":thread_notification", |
| 268 | pw_sync_THREAD_NOTIFICATION_BACKEND, |
| 269 | ] |
| 270 | } |
| 271 | |
| 272 | pw_test("timed_thread_notification_facade_test") { |
| 273 | enable_if = pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != "" |
| 274 | sources = [ "timed_thread_notification_facade_test.cc" ] |
| 275 | deps = [ |
| 276 | ":timed_thread_notification", |
| 277 | pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND, |
| 278 | ] |
| 279 | } |
| 280 | |
Ewout van Bekkum | 5890193 | 2020-11-09 12:46:52 -0800 | [diff] [blame] | 281 | pw_doc_group("docs") { |
| 282 | sources = [ "docs.rst" ] |
| 283 | } |