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 15import("//build_overrides/pigweed.gni") 16 17import("$dir_pw_build/error.gni") 18import("$dir_pw_build/module_config.gni") 19import("$dir_pw_build/target_types.gni") 20import("$dir_pw_chrono/backend.gni") 21import("$dir_pw_docgen/docs.gni") 22 23declare_args() { 24 # The build target that overrides the default configuration options for this 25 # module. This should point to a source set that provides defines through a 26 # public config (which may -include a file or add defines directly). 27 pw_sync_freertos_CONFIG = pw_build_DEFAULT_MODULE_CONFIG 28} 29 30config("public_include_path") { 31 include_dirs = [ "public" ] 32 visibility = [ ":*" ] 33} 34 35config("backend_config") { 36 include_dirs = [ "public_overrides" ] 37 visibility = [ ":*" ] 38} 39 40pw_source_set("config") { 41 public = [ "public/pw_sync_freertos/config.h" ] 42 public_configs = [ ":public_include_path" ] 43 public_deps = [ 44 "$dir_pw_third_party/freertos", 45 pw_sync_freertos_CONFIG, 46 ] 47} 48 49pw_build_assert("check_system_clock_backend") { 50 condition = 51 pw_chrono_SYSTEM_CLOCK_BACKEND == "" || 52 pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_freertos:system_clock" 53 message = "The FreeRTOS pw_sync backends only work with the FreeRTOS " + 54 "pw::chrono::SystemClock backend." 55 visibility = [ ":*" ] 56} 57 58# This target provides the backend for pw::sync::BinarySemaphore. 59pw_source_set("binary_semaphore") { 60 public_configs = [ 61 ":public_include_path", 62 ":backend_config", 63 ] 64 public = [ 65 "public/pw_sync_freertos/binary_semaphore_inline.h", 66 "public/pw_sync_freertos/binary_semaphore_native.h", 67 "public_overrides/pw_sync_backend/binary_semaphore_inline.h", 68 "public_overrides/pw_sync_backend/binary_semaphore_native.h", 69 ] 70 public_deps = [ 71 "$dir_pw_assert", 72 "$dir_pw_chrono:system_clock", 73 "$dir_pw_chrono_freertos:system_clock", 74 "$dir_pw_interrupt:context", 75 "$dir_pw_third_party/freertos", 76 ] 77 sources = [ "binary_semaphore.cc" ] 78 deps = [ 79 ":check_system_clock_backend", 80 "$dir_pw_sync:binary_semaphore.facade", 81 ] 82} 83 84# This target provides the backend for pw::sync::CountingSemaphore. 85pw_source_set("counting_semaphore") { 86 public_configs = [ 87 ":public_include_path", 88 ":backend_config", 89 ] 90 public = [ 91 "public/pw_sync_freertos/counting_semaphore_inline.h", 92 "public/pw_sync_freertos/counting_semaphore_native.h", 93 "public_overrides/pw_sync_backend/counting_semaphore_inline.h", 94 "public_overrides/pw_sync_backend/counting_semaphore_native.h", 95 ] 96 public_deps = [ 97 "$dir_pw_assert", 98 "$dir_pw_chrono:system_clock", 99 "$dir_pw_chrono_freertos:system_clock", 100 "$dir_pw_interrupt:context", 101 "$dir_pw_third_party/freertos", 102 ] 103 sources = [ "counting_semaphore.cc" ] 104 deps = [ 105 ":check_system_clock_backend", 106 "$dir_pw_sync:counting_semaphore.facade", 107 ] 108} 109 110# This target provides the backend for pw::sync::Mutex. 111pw_source_set("mutex") { 112 public_configs = [ 113 ":public_include_path", 114 ":backend_config", 115 ] 116 public = [ 117 "public/pw_sync_freertos/mutex_inline.h", 118 "public/pw_sync_freertos/mutex_native.h", 119 "public_overrides/pw_sync_backend/mutex_inline.h", 120 "public_overrides/pw_sync_backend/mutex_native.h", 121 ] 122 public_deps = [ 123 "$dir_pw_assert", 124 "$dir_pw_interrupt:context", 125 "$dir_pw_sync:mutex.facade", 126 "$dir_pw_third_party/freertos", 127 ] 128} 129 130# This target provides the backend for pw::sync::TimedMutex. 131pw_source_set("timed_mutex") { 132 public_configs = [ 133 ":public_include_path", 134 ":backend_config", 135 ] 136 public = [ 137 "public/pw_sync_freertos/timed_mutex_inline.h", 138 "public_overrides/pw_sync_backend/timed_mutex_inline.h", 139 ] 140 public_deps = [ 141 "$dir_pw_chrono:system_clock", 142 "$dir_pw_sync:timed_mutex.facade", 143 ] 144 sources = [ "timed_mutex.cc" ] 145 deps = [ 146 ":check_system_clock_backend", 147 "$dir_pw_assert", 148 "$dir_pw_chrono_freertos:system_clock", 149 "$dir_pw_interrupt:context", 150 "$dir_pw_third_party/freertos", 151 ] 152} 153 154config("public_overrides_thread_notification_include_path") { 155 include_dirs = [ "public_overrides/thread_notification" ] 156 visibility = [ ":thread_notification" ] 157} 158 159# This target provides the backend for pw::sync::ThreadNotification based on 160# task notifications. 161pw_source_set("thread_notification") { 162 public_configs = [ 163 ":public_include_path", 164 ":public_overrides_thread_notification_include_path", 165 ] 166 public = [ 167 "public/pw_sync_freertos/thread_notification_inline.h", 168 "public/pw_sync_freertos/thread_notification_native.h", 169 "public_overrides/thread_notification/pw_sync_backend/thread_notification_inline.h", 170 "public_overrides/thread_notification/pw_sync_backend/thread_notification_native.h", 171 ] 172 public_deps = [ 173 "$dir_pw_interrupt:context", 174 "$dir_pw_sync:thread_notification.facade", 175 "$dir_pw_third_party/freertos", 176 ] 177 sources = [ "thread_notification.cc" ] 178 deps = [ 179 ":config", 180 dir_pw_assert, 181 ] 182} 183 184config("public_overrides_timed_thread_notification_include_path") { 185 include_dirs = [ "public_overrides/timed_thread_notification" ] 186 visibility = [ ":timed_thread_notification" ] 187} 188 189# This target provides the backend for pw::sync::TimedThreadNotification based 190# on task notifications. 191pw_source_set("timed_thread_notification") { 192 public_configs = [ 193 ":public_include_path", 194 ":public_overrides_timed_thread_notification_include_path", 195 ] 196 public = [ 197 "public/pw_sync_freertos/timed_thread_notification_inline.h", 198 "public_overrides/timed_thread_notification/pw_sync_backend/timed_thread_notification_inline.h", 199 ] 200 public_deps = [ 201 "$dir_pw_chrono:system_clock", 202 "$dir_pw_sync:timed_thread_notification.facade", 203 ] 204 sources = [ "timed_thread_notification.cc" ] 205 deps = [ 206 ":check_system_clock_backend", 207 ":config", 208 "$dir_pw_assert", 209 "$dir_pw_chrono_freertos:system_clock", 210 "$dir_pw_interrupt:context", 211 "$dir_pw_third_party/freertos", 212 ] 213} 214 215# This target provides the backend for pw::sync::InterruptSpinLock. 216pw_source_set("interrupt_spin_lock") { 217 public_configs = [ 218 ":public_include_path", 219 ":backend_config", 220 ] 221 public = [ 222 "public/pw_sync_freertos/interrupt_spin_lock_inline.h", 223 "public/pw_sync_freertos/interrupt_spin_lock_native.h", 224 "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h", 225 "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h", 226 ] 227 public_deps = [ "$dir_pw_third_party/freertos" ] 228 sources = [ "interrupt_spin_lock.cc" ] 229 deps = [ 230 "$dir_pw_assert", 231 "$dir_pw_interrupt:context", 232 "$dir_pw_sync:interrupt_spin_lock.facade", 233 ] 234} 235 236pw_doc_group("docs") { 237 sources = [ "docs.rst" ] 238} 239