blob: df4217d50883603dc9c1623141e7b078af57e929 [file] [log] [blame]
# Copyright 2023 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
import("//build_overrides/pigweed.gni")
import("$dir_pw_async2/backend.gni")
import("$dir_pw_build/facade.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_chrono/backend.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_sync/backend.gni")
import("$dir_pw_thread/backend.gni")
import("$dir_pw_toolchain/traits.gni")
import("$dir_pw_unit_test/test.gni")
config("public_include_path") {
include_dirs = [ "public" ]
}
pw_source_set("poll") {
public_configs = [ ":public_include_path" ]
public = [
"public/pw_async2/internal/poll_internal.h",
"public/pw_async2/poll.h",
]
public_deps = [
"$dir_pw_string:to_string",
"$dir_pw_third_party/fuchsia:stdcompat",
dir_pw_polyfill,
]
}
pw_test("poll_test") {
deps = [
":poll",
"$dir_pw_result",
]
sources = [ "poll_test.cc" ]
}
# NOTE: this target should only be used directly by implementors of the
# `dispatcher` facade.
pw_source_set("dispatcher_base") {
public_configs = [ ":public_include_path" ]
public_deps = [
":poll",
"$dir_pw_assert",
"$dir_pw_chrono:system_clock",
"$dir_pw_sync:interrupt_spin_lock",
"$dir_pw_sync:lock_annotations",
"$dir_pw_toolchain:no_destructor",
]
deps = [ "$dir_pw_assert:check" ]
public = [ "public/pw_async2/dispatcher_base.h" ]
sources = [ "dispatcher_base.cc" ]
}
pw_facade("dispatcher") {
backend = pw_async2_DISPATCHER_BACKEND
public_configs = [ ":public_include_path" ]
public = [ "public/pw_async2/dispatcher.h" ]
public_deps = [ ":dispatcher_base" ]
}
pw_test("dispatcher_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != "" &&
pw_chrono_SYSTEM_CLOCK_BACKEND != "" &&
pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" &&
pw_sync_TIMED_THREAD_NOTIFICATION_BACKEND != ""
deps = [
":dispatcher",
"$dir_pw_containers:vector",
]
sources = [ "dispatcher_test.cc" ]
}
pw_test("dispatcher_thread_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != "" &&
pw_chrono_SYSTEM_CLOCK_BACKEND != "" &&
pw_sync_INTERRUPT_SPIN_LOCK_BACKEND != "" &&
pw_thread_THREAD_BACKEND == "$dir_pw_thread_stl:thread"
deps = [
":dispatcher",
"$dir_pw_thread:sleep",
"$dir_pw_thread:thread",
dir_pw_function,
]
sources = [ "dispatcher_thread_test.cc" ]
}
pw_source_set("pend_func_task") {
public_configs = [ ":public_include_path" ]
public = [ "public/pw_async2/pend_func_task.h" ]
public_deps = [ ":dispatcher" ]
}
pw_test("pend_func_task_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != ""
deps = [
":dispatcher",
":pend_func_task",
]
sources = [ "pend_func_task_test.cc" ]
}
pw_source_set("pendable_as_task") {
public_configs = [ ":public_include_path" ]
public = [ "public/pw_async2/pendable_as_task.h" ]
public_deps = [ ":dispatcher" ]
}
pw_test("pendable_as_task_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != ""
deps = [
":dispatcher",
":pendable_as_task",
]
sources = [ "pendable_as_task_test.cc" ]
}
pw_source_set("allocate_task") {
public_configs = [ ":public_include_path" ]
public = [ "public/pw_async2/allocate_task.h" ]
public_deps = [
":dispatcher",
"$dir_pw_allocator:allocator",
]
}
pw_test("allocate_task_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != ""
deps = [
":allocate_task",
"$dir_pw_allocator:testing",
]
sources = [ "allocate_task_test.cc" ]
}
if (pw_toolchain_CXX_STANDARD >= pw_toolchain_STANDARD.CXX20) {
pw_source_set("coro") {
public_configs = [ ":public_include_path" ]
public = [ "public/pw_async2/coro.h" ]
public_deps = [
":dispatcher",
"$dir_pw_allocator:allocator",
]
}
pw_test("coro_test") {
enable_if = pw_async2_DISPATCHER_BACKEND != ""
deps = [
":coro",
":dispatcher",
"$dir_pw_allocator:null_allocator",
"$dir_pw_allocator:testing",
]
sources = [ "coro_test.cc" ]
}
}
pw_test_group("tests") {
tests = [
":allocate_task_test",
":dispatcher_test",
":dispatcher_thread_test",
":poll_test",
":pend_func_task_test",
":pendable_as_task_test",
]
if (pw_toolchain_CXX_STANDARD >= pw_toolchain_STANDARD.CXX20) {
tests += [ ":coro_test" ]
}
group_deps = [ "examples" ]
}
pw_doc_group("docs") {
inputs = [ "examples/coro.cc" ]
sources = [
"backends.rst",
"docs.rst",
]
}