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/target_types.gni") 19import("$dir_pw_chrono/backend.gni") 20import("$dir_pw_docgen/docs.gni") 21import("$dir_pw_sync/backend.gni") 22import("$dir_pw_thread/backend.gni") 23import("$dir_pw_unit_test/test.gni") 24 25config("public_include_path") { 26 include_dirs = [ "public" ] 27 visibility = [ ":*" ] 28} 29 30config("backend_config") { 31 include_dirs = [ "public_overrides" ] 32 visibility = [ ":*" ] 33} 34 35pw_build_assert("check_system_clock_backend") { 36 condition = 37 pw_chrono_SYSTEM_CLOCK_BACKEND == "" || 38 pw_chrono_SYSTEM_CLOCK_BACKEND == "$dir_pw_chrono_stl:system_clock" 39 message = "The STL pw_sync backends only work with the STL " + 40 "pw::chrono::SystemClock backend." 41 visibility = [ ":*" ] 42} 43 44# This target provides the backend for pw::sync::BinarySemaphore. 45pw_source_set("binary_semaphore_backend") { 46 public_configs = [ 47 ":public_include_path", 48 ":backend_config", 49 ] 50 public = [ 51 "public/pw_sync_stl/binary_semaphore_inline.h", 52 "public/pw_sync_stl/binary_semaphore_native.h", 53 "public_overrides/pw_sync_backend/binary_semaphore_inline.h", 54 "public_overrides/pw_sync_backend/binary_semaphore_native.h", 55 ] 56 sources = [ "binary_semaphore.cc" ] 57 deps = [ 58 ":check_system_clock_backend", 59 "$dir_pw_assert", 60 "$dir_pw_chrono:system_clock", 61 "$dir_pw_sync:binary_semaphore.facade", 62 ] 63} 64 65# This target provides the backend for pw::sync::CountingSemaphore. 66pw_source_set("counting_semaphore_backend") { 67 public_configs = [ 68 ":public_include_path", 69 ":backend_config", 70 ] 71 public = [ 72 "public/pw_sync_stl/counting_semaphore_inline.h", 73 "public/pw_sync_stl/counting_semaphore_native.h", 74 "public_overrides/pw_sync_backend/counting_semaphore_inline.h", 75 "public_overrides/pw_sync_backend/counting_semaphore_native.h", 76 ] 77 sources = [ "counting_semaphore.cc" ] 78 deps = [ 79 ":check_system_clock_backend", 80 "$dir_pw_assert", 81 "$dir_pw_chrono:system_clock", 82 "$dir_pw_sync:counting_semaphore.facade", 83 ] 84} 85 86# This target provides the backend for pw::sync::Mutex. 87pw_source_set("mutex_backend") { 88 public_configs = [ 89 ":public_include_path", 90 ":backend_config", 91 ] 92 public = [ 93 "public/pw_sync_stl/mutex_inline.h", 94 "public/pw_sync_stl/mutex_native.h", 95 "public_overrides/pw_sync_backend/mutex_inline.h", 96 "public_overrides/pw_sync_backend/mutex_native.h", 97 ] 98 public_deps = [ "$dir_pw_sync:mutex.facade" ] 99 deps = [ dir_pw_assert ] 100 101 sources = [ "mutex.cc" ] 102} 103 104# This target provides the backend for pw::sync::TimedMutex. 105pw_source_set("timed_mutex_backend") { 106 public_configs = [ 107 ":public_include_path", 108 ":backend_config", 109 ] 110 public = [ 111 "$dir_pw_sync:timed_mutex.facade", 112 "public/pw_sync_stl/timed_mutex_inline.h", 113 "public_overrides/pw_sync_backend/timed_mutex_inline.h", 114 ] 115 public_deps = [ "$dir_pw_chrono:system_clock" ] 116 deps = [ ":check_system_clock_backend" ] 117} 118 119# This target provides the backend for pw::sync::RecursiveMutex. 120pw_source_set("recursive_mutex_backend") { 121 public_configs = [ 122 ":public_include_path", 123 ":backend_config", 124 ] 125 public = [ 126 "public/pw_sync_stl/recursive_mutex_inline.h", 127 "public/pw_sync_stl/recursive_mutex_native.h", 128 "public_overrides/pw_sync_backend/recursive_mutex_inline.h", 129 "public_overrides/pw_sync_backend/recursive_mutex_native.h", 130 ] 131 public_deps = [ 132 "$dir_pw_sync:recursive_mutex.facade", 133 dir_pw_assert, 134 ] 135} 136 137# This target provides the backend for pw::sync::InterruptSpinLock. 138pw_source_set("interrupt_spin_lock") { 139 public_configs = [ 140 ":public_include_path", 141 ":backend_config", 142 ] 143 public = [ 144 "public/pw_sync_stl/interrupt_spin_lock_inline.h", 145 "public/pw_sync_stl/interrupt_spin_lock_native.h", 146 "public_overrides/pw_sync_backend/interrupt_spin_lock_inline.h", 147 "public_overrides/pw_sync_backend/interrupt_spin_lock_native.h", 148 ] 149 public_deps = [ 150 "$dir_pw_sync:interrupt_spin_lock.facade", 151 "$dir_pw_sync:yield_core", 152 ] 153} 154 155# This target provides the backend for pw::sync::ConditionVariable. 156pw_source_set("condition_variable_backend") { 157 allow_circular_includes_from = [ "$dir_pw_sync:condition_variable.facade" ] 158 public_configs = [ 159 ":public_include_path", 160 ":backend_config", 161 ] 162 public = [ 163 "public/pw_sync_stl/condition_variable_inline.h", 164 "public/pw_sync_stl/condition_variable_native.h", 165 "public_overrides/pw_sync_backend/condition_variable_inline.h", 166 "public_overrides/pw_sync_backend/condition_variable_native.h", 167 ] 168 public_deps = [ "$dir_pw_sync:condition_variable.facade" ] 169} 170 171pw_test("condition_variable_test") { 172 enable_if = pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" && 173 pw_sync_CONDITION_VARIABLE_BACKEND == 174 "$dir_pw_sync_stl:condition_variable" 175 deps = [ 176 "$dir_pw_sync:condition_variable_test", 177 "$dir_pw_thread_stl:non_portable_test_thread_options", 178 ] 179} 180 181pw_doc_group("docs") { 182 sources = [ "docs.rst" ] 183} 184 185pw_test_group("tests") { 186 tests = [ ":condition_variable_test" ] 187} 188