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