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 15load("@rules_cc//cc:cc_library.bzl", "cc_library") 16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library") 17load("//pw_build:compatibility.bzl", "incompatible_with_mcu") 18load("//pw_build:pw_facade.bzl", "pw_facade") 19load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test") 20 21package( 22 default_visibility = ["//visibility:public"], 23) 24 25licenses(["notice"]) 26 27cc_library( 28 name = "dispatcher", 29 hdrs = [ 30 "public/pw_async/dispatcher.h", 31 "public/pw_async/function_dispatcher.h", 32 ], 33 strip_include_prefix = "public", 34 deps = [ 35 ":types", 36 "//pw_chrono:system_clock", 37 "//pw_function", 38 "//pw_status", 39 ], 40) 41 42pw_facade( 43 name = "task", 44 hdrs = ["public/pw_async/task.h"], 45 backend = ":task_backend", 46 strip_include_prefix = "public", 47 deps = [ 48 ":types", 49 "//pw_chrono:system_clock", 50 "//pw_function", 51 "//pw_status", 52 ], 53) 54 55label_flag( 56 name = "task_backend", 57 build_setting_default = "//pw_async_basic:task", 58) 59 60cc_library( 61 name = "types", 62 hdrs = [ 63 "public/pw_async/context.h", 64 "public/pw_async/task_function.h", 65 ], 66 strip_include_prefix = "public", 67 deps = [ 68 "//pw_function", 69 "//pw_status", 70 ], 71) 72 73pw_facade( 74 name = "fake_dispatcher", 75 testonly = True, 76 hdrs = ["public/pw_async/fake_dispatcher.h"], 77 backend = ":fake_dispatcher_backend", 78 strip_include_prefix = "public", 79 deps = [":dispatcher"], 80) 81 82label_flag( 83 name = "fake_dispatcher_backend", 84 build_setting_default = "//pw_async_basic:fake_dispatcher", 85) 86 87pw_cc_test( 88 name = "fake_dispatcher_test", 89 srcs = ["fake_dispatcher_test.cc"], 90 deps = [ 91 ":fake_dispatcher", 92 "//pw_chrono:system_clock", 93 "//pw_containers:vector", 94 "//pw_log", 95 "//pw_string:to_string", 96 "//pw_sync:timed_thread_notification", 97 "//pw_thread:thread", 98 ], 99) 100 101cc_library( 102 name = "fake_dispatcher_fixture", 103 testonly = True, 104 hdrs = ["public/pw_async/fake_dispatcher_fixture.h"], 105 strip_include_prefix = "public", 106 deps = [ 107 ":fake_dispatcher", 108 "//pw_unit_test", 109 ], 110) 111 112cc_library( 113 name = "heap_dispatcher", 114 srcs = ["heap_dispatcher.cc"], 115 hdrs = ["public/pw_async/heap_dispatcher.h"], 116 strip_include_prefix = "public", 117 deps = [ 118 ":dispatcher", 119 ":task", 120 ":types", 121 "//pw_result", 122 ], 123) 124 125filegroup( 126 name = "doxygen", 127 srcs = [ 128 "public/pw_async/context.h", 129 "public/pw_async/dispatcher.h", 130 "public/pw_async/fake_dispatcher_fixture.h", 131 "public/pw_async/function_dispatcher.h", 132 "public/pw_async/heap_dispatcher.h", 133 "public/pw_async/task.h", 134 "public/pw_async/task_function.h", 135 ], 136) 137 138sphinx_docs_library( 139 name = "docs", 140 srcs = [ 141 "backends.rst", 142 "docs.rst", 143 ], 144 prefix = "pw_async/", 145 target_compatible_with = incompatible_with_mcu(), 146) 147