xref: /aosp_15_r20/external/pigweed/pw_uart/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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")
16import("$dir_pw_chrono/backend.gni")
17import("$dir_pw_docgen/docs.gni")
18import("$dir_pw_sync/backend.gni")
19import("$dir_pw_thread/backend.gni")
20import("$dir_pw_unit_test/test.gni")
21
22config("public_include_path") {
23  include_dirs = [ "public" ]
24}
25
26pw_test_group("tests") {
27  tests = [
28    ":blocking_adapter_test",
29    ":stream_test",
30    ":uart_non_blocking_test",
31    ":uart_test",
32  ]
33}
34
35pw_source_set("uart_base") {
36  public_configs = [ ":public_include_path" ]
37  public = [ "public/pw_uart/uart_base.h" ]
38  public_deps = [ "$dir_pw_status" ]
39}
40
41pw_source_set("uart") {
42  public_configs = [ ":public_include_path" ]
43  public = [ "public/pw_uart/uart.h" ]
44  public_deps = [
45    ":uart_base",
46    "$dir_pw_assert",
47    "$dir_pw_bytes",
48    "$dir_pw_chrono:system_clock",
49    "$dir_pw_span",
50    "$dir_pw_status",
51  ]
52}
53
54pw_source_set("uart_non_blocking") {
55  public_configs = [ ":public_include_path" ]
56  public = [ "public/pw_uart/uart_non_blocking.h" ]
57  public_deps = [
58    ":uart_base",
59    "$dir_pw_assert",
60    "$dir_pw_bytes",
61    "$dir_pw_function",
62    "$dir_pw_span",
63    "$dir_pw_status",
64  ]
65}
66
67pw_source_set("blocking_adapter") {
68  public_configs = [ ":public_include_path" ]
69  sources = [ "blocking_adapter.cc" ]
70  public = [ "public/pw_uart/blocking_adapter.h" ]
71  public_deps = [
72    ":uart",
73    ":uart_non_blocking",
74    "$dir_pw_assert",
75    "$dir_pw_log",
76    "$dir_pw_status",
77    "$dir_pw_sync:timed_thread_notification",
78  ]
79}
80
81pw_source_set("stream") {
82  public_configs = [ ":public_include_path" ]
83  public = [ "public/pw_uart/stream.h" ]
84  public_deps = [
85    ":uart",
86    "$dir_pw_stream",
87  ]
88}
89
90pw_test("uart_test") {
91  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
92  sources = [ "uart_test.cc" ]
93  deps = [ ":uart" ]
94}
95
96pw_test("uart_non_blocking_test") {
97  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
98  sources = [ "uart_non_blocking_test.cc" ]
99  deps = [ ":uart_non_blocking" ]
100}
101
102pw_test("blocking_adapter_test") {
103  enable_if =
104      pw_sync_BINARY_SEMAPHORE_BACKEND != "" && pw_sync_MUTEX_BACKEND != "" &&
105      pw_chrono_SYSTEM_CLOCK_BACKEND != "" &&
106      pw_thread_TEST_THREAD_CONTEXT_BACKEND != ""
107  sources = [ "blocking_adapter_test.cc" ]
108  deps = [
109    ":blocking_adapter",
110    "$dir_pw_assert",
111    "$dir_pw_bytes",
112    "$dir_pw_log",
113    "$dir_pw_sync:lock_annotations",
114    "$dir_pw_sync:mutex",
115    "$dir_pw_sync:timed_thread_notification",
116    "$dir_pw_thread:test_thread_context",
117    "$dir_pw_thread:thread",
118    "$dir_pw_unit_test",
119    "$dir_pw_work_queue",
120  ]
121}
122
123pw_test("stream_test") {
124  enable_if = pw_chrono_SYSTEM_CLOCK_BACKEND != ""
125  sources = [ "stream_test.cc" ]
126  deps = [ ":stream" ]
127}
128
129pw_doc_group("docs") {
130  inputs = [
131    "public/pw_uart/uart.h",
132    "public/pw_uart/uart_non_blocking.h",
133  ]
134  sources = [
135    "backends.rst",
136    "docs.rst",
137  ]
138}
139