xref: /aosp_15_r20/external/pigweed/pw_hdlc/BUILD.bazel (revision 61c4878ac05f98d0ceed94b57d316916de578985)
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
15load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
16
17package(default_visibility = ["//visibility:public"])
18
19licenses(["notice"])
20
21cc_library(
22    name = "pw_hdlc",
23    srcs = [
24        "decoder.cc",
25        "encoder.cc",
26    ],
27    hdrs = [
28        "public/pw_hdlc/decoder.h",
29        "public/pw_hdlc/encoded_size.h",
30        "public/pw_hdlc/encoder.h",
31        "public/pw_hdlc/internal/protocol.h",
32    ],
33    strip_include_prefix = "public",
34    deps = [
35        "//pw_bytes",
36        "//pw_checksum",
37        "//pw_log",
38        "//pw_result",
39        "//pw_span",
40        "//pw_status",
41        "//pw_stream",
42        "//pw_varint",
43    ],
44)
45
46cc_library(
47    name = "rpc_channel_output",
48    hdrs = ["public/pw_hdlc/rpc_channel.h"],
49    strip_include_prefix = "public",
50    deps = [
51        ":pw_hdlc",
52        "//pw_rpc",
53        "//pw_span",
54    ],
55)
56
57cc_library(
58    name = "default_addresses",
59    hdrs = ["public/pw_hdlc/default_addresses.h"],
60    strip_include_prefix = "public",
61)
62
63cc_library(
64    name = "packet_parser",
65    srcs = ["wire_packet_parser.cc"],
66    hdrs = ["public/pw_hdlc/wire_packet_parser.h"],
67    strip_include_prefix = "public",
68    deps = [
69        ":pw_hdlc",
70        "//pw_assert",
71        "//pw_bytes",
72        "//pw_checksum",
73        "//pw_router:packet_parser",
74    ],
75)
76
77# A backend for pw_rpc's `system_server` that sends and receives HDLC-framed RPC
78# packets over pw_sys_io.
79#
80# Warning: This system server is polling and blocking, so it's not
81# production-ready. This exists for simplifying initial bringup/testing, and
82# should not be used in any performance-sensitive application.
83cc_library(
84    name = "hdlc_sys_io_system_server",
85    srcs = [
86        "hdlc_sys_io_system_server.cc",
87    ],
88    deps = [
89        ":default_addresses",
90        ":pw_hdlc",
91        ":rpc_channel_output",
92        "//pw_assert",
93        "//pw_log",
94        "//pw_log_basic:headers",
95        "//pw_rpc/system_server:facade",
96        "//pw_status",
97        "//pw_stream:sys_io_stream",
98    ],
99)
100
101pw_cc_test(
102    name = "encoder_test",
103    srcs = ["encoder_test.cc"],
104    deps = [
105        ":pw_hdlc",
106        "//pw_stream",
107        "//pw_unit_test",
108    ],
109)
110
111pw_cc_test(
112    name = "decoder_test",
113    srcs = ["decoder_test.cc"],
114    deps = [
115        ":pw_hdlc",
116        "//pw_fuzzer:fuzztest",
117        "//pw_result",
118        "//pw_stream",
119    ],
120)
121
122pw_cc_test(
123    name = "encoded_size_test",
124    srcs = ["encoded_size_test.cc"],
125    deps = [
126        ":pw_hdlc",
127        "//pw_bytes",
128        "//pw_result",
129        "//pw_stream",
130        "//pw_unit_test",
131        "//pw_varint",
132    ],
133)
134
135pw_cc_test(
136    name = "wire_packet_parser_test",
137    srcs = ["wire_packet_parser_test.cc"],
138    deps = [
139        ":packet_parser",
140        "//pw_bytes",
141    ],
142)
143
144pw_cc_test(
145    name = "rpc_channel_test",
146    srcs = ["rpc_channel_test.cc"],
147    deps = [
148        ":pw_hdlc",
149        ":rpc_channel_output",
150        "//pw_stream",
151        "//pw_unit_test",
152    ],
153)
154
155cc_library(
156    name = "router",
157    srcs = ["router.cc"],
158    hdrs = ["public/pw_hdlc/router.h"],
159    strip_include_prefix = "public",
160    deps = [
161        ":pw_hdlc",
162        "//pw_async2:dispatcher",
163        "//pw_async2:poll",
164        "//pw_bytes",
165        "//pw_channel",
166        "//pw_containers:inline_queue",
167        "//pw_containers:vector",
168        "//pw_log",
169        "//pw_multibuf",
170        "//pw_multibuf:allocator",
171        "//pw_multibuf:stream",
172        "//pw_result",
173        "//pw_status",
174        "//pw_stream",
175    ],
176)
177
178pw_cc_test(
179    name = "router_test",
180    srcs = ["router_test.cc"],
181    deps = [
182        ":router",
183        "//pw_allocator:testing",
184        "//pw_async2:pend_func_task",
185        "//pw_channel:forwarding_channel",
186        "//pw_channel:loopback_channel",
187        "//pw_multibuf:simple_allocator",
188        "//pw_unit_test",
189    ],
190)
191
192filegroup(
193    name = "doxygen",
194    srcs = [
195        "public/pw_hdlc/decoder.h",
196        "public/pw_hdlc/encoder.h",
197        "public/pw_hdlc/router.h",
198    ],
199)
200