1# Copyright 2023 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_async/async.gni") 18import("$dir_pw_async/fake_dispatcher_fixture.gni") 19import("$dir_pw_async/fake_dispatcher_test.gni") 20import("$dir_pw_async/heap_dispatcher.gni") 21import("$dir_pw_bloat/bloat.gni") 22import("$dir_pw_build/target_types.gni") 23import("$dir_pw_chrono/backend.gni") 24import("$dir_pw_docgen/docs.gni") 25import("$dir_pw_sync/backend.gni") 26import("$dir_pw_thread/backend.gni") 27import("$dir_pw_unit_test/test.gni") 28 29config("public_include_path") { 30 include_dirs = [ "public" ] 31} 32 33config("backend_config") { 34 include_dirs = [ "public_overrides" ] 35 visibility = [ ":*" ] 36} 37 38# Backend for //pw_async:task 39pw_source_set("task") { 40 public_configs = [ 41 ":public_include_path", 42 ":backend_config", 43 ] 44 public = [ 45 "public/pw_async_basic/task.h", 46 "public_overrides/pw_async_backend/task.h", 47 ] 48 49 public_deps = [ 50 "$dir_pw_async:task.facade", 51 "$dir_pw_containers:intrusive_list", 52 ] 53 visibility = [ 54 ":*", 55 "$dir_pw_async:*", 56 "size_report:*", 57 ] + pw_async_EXPERIMENTAL_MODULE_VISIBILITY 58} 59 60# Backend for //pw_async:fake_dispatcher 61pw_source_set("fake_dispatcher") { 62 public_configs = [ 63 ":public_include_path", 64 ":backend_config", 65 ] 66 sources = [ "fake_dispatcher.cc" ] 67 public = [ 68 "public/pw_async_basic/fake_dispatcher.h", 69 "public_overrides/pw_async_backend/fake_dispatcher.h", 70 ] 71 public_deps = [ 72 ":task", 73 "$dir_pw_async:fake_dispatcher.facade", 74 ] 75 deps = [ dir_pw_log ] 76 visibility = [ 77 ":*", 78 "$dir_pw_async:*", 79 ] + pw_async_EXPERIMENTAL_MODULE_VISIBILITY 80} 81 82fake_dispatcher_test("fake_dispatcher_test") { 83 backend = ":fake_dispatcher" 84} 85 86fake_dispatcher_fixture("fake_dispatcher_fixture") { 87 backend = ":fake_dispatcher" 88} 89 90pw_test("fake_dispatcher_fixture_test") { 91 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" 92 sources = [ "fake_dispatcher_fixture_test.cc" ] 93 deps = [ ":fake_dispatcher_fixture" ] 94} 95 96pw_source_set("dispatcher") { 97 public_configs = [ ":public_include_path" ] 98 public = [ "public/pw_async_basic/dispatcher.h" ] 99 sources = [ "dispatcher.cc" ] 100 public_deps = [ 101 ":task", 102 "$dir_pw_async:dispatcher", 103 "$dir_pw_containers:intrusive_list", 104 "$dir_pw_sync:interrupt_spin_lock", 105 "$dir_pw_sync:timed_thread_notification", 106 "$dir_pw_thread:thread_core", 107 ] 108 visibility = [ 109 ":*", 110 "$dir_pw_grpc/*", 111 "size_report:*", 112 ] + pw_async_EXPERIMENTAL_MODULE_VISIBILITY 113} 114 115pw_test("dispatcher_test") { 116 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" && 117 pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" 118 public_deps = [ 119 ":dispatcher", 120 "$dir_pw_thread:thread", 121 dir_pw_log, 122 ] 123 sources = [ "dispatcher_test.cc" ] 124} 125 126# This target cannot be labeled "heap_dispatcher" or else the outpath Ninja uses 127# for heap_dispatcher.cc will collide with $dir_pw_async:heap_dispatcher. 128pw_async_heap_dispatcher_source_set("heap_dispatcher_basic") { 129 task_backend = ":task" 130 visibility = [ ":*" ] 131} 132 133group("heap_dispatcher") { 134 public_deps = [ ":heap_dispatcher_basic" ] 135 visibility = [ ":*" ] + pw_async_EXPERIMENTAL_MODULE_VISIBILITY 136} 137 138pw_test("heap_dispatcher_test") { 139 enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != "" && 140 pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread" 141 sources = [ "heap_dispatcher_test.cc" ] 142 deps = [ 143 ":fake_dispatcher_fixture", 144 ":heap_dispatcher", 145 ] 146} 147 148pw_test_group("tests") { 149 tests = [ 150 ":dispatcher_test", 151 ":fake_dispatcher_test", 152 ":fake_dispatcher_fixture_test", 153 ":heap_dispatcher_test", 154 ] 155} 156 157pw_doc_group("docs") { 158 sources = [ "docs.rst" ] 159 report_deps = [ ":docs_size_report" ] 160} 161 162pw_size_diff("docs_size_report") { 163 title = "pw_async_basic Docs Size Report" 164 base = "$dir_pw_bloat:bloat_base" 165 166 binaries = [] 167 168 if (pw_chrono_SYSTEM_CLOCK_BACKEND != "") { 169 binaries += [ 170 { 171 target = "size_report:task" 172 label = "Construct a Task" 173 }, 174 ] 175 } 176 177 if (binaries == []) { 178 binaries += [ 179 { 180 target = "$dir_pw_bloat:bloat_base" 181 label = "No backend is selected." 182 }, 183 ] 184 } 185} 186 187# This size report can't be included in docs because the docs build target uses 188# the target-stm32f429i-disc1 toolchain, which does not support timed thread 189# notifications (mutex & condition_variable headers are not available). 190pw_size_diff("size_report") { 191 title = "pw_async_basic Size Report" 192 base = "$dir_pw_bloat:bloat_base" 193 194 binaries = [] 195 196 if (pw_chrono_SYSTEM_CLOCK_BACKEND != "" && 197 pw_sync_THREAD_NOTIFICATION_BACKEND != "" && 198 pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != "") { 199 binaries += [ 200 { 201 target = "size_report:post_1_task" 202 label = "Post 1 Task to BasicDispatcher" 203 }, 204 ] 205 } 206} 207