• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 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")
16
17import("$dir_pw_build/python.gni")
18import("$dir_pw_build/target_types.gni")
19import("$dir_pw_docgen/docs.gni")
20import("$dir_pw_unit_test/test.gni")
21
22config("default_config") {
23  include_dirs = [ "public" ]
24}
25
26group("pw_hdlc") {
27  public_deps = [
28    ":decoder",
29    ":encoder",
30  ]
31}
32
33pw_source_set("common") {
34  public_configs = [ ":default_config" ]
35  public = [ "public/pw_hdlc/internal/protocol.h" ]
36  public_deps = [ dir_pw_varint ]
37  visibility = [ ":*" ]
38}
39
40pw_source_set("decoder") {
41  public_configs = [ ":default_config" ]
42  public = [ "public/pw_hdlc/decoder.h" ]
43  sources = [ "decoder.cc" ]
44  public_deps = [
45    ":common",
46    dir_pw_bytes,
47    dir_pw_checksum,
48    dir_pw_result,
49    dir_pw_status,
50  ]
51  deps = [ dir_pw_log ]
52  friend = [ ":*" ]
53}
54
55pw_source_set("encoder") {
56  public_configs = [ ":default_config" ]
57  public = [ "public/pw_hdlc/encoder.h" ]
58  sources = [
59    "encoder.cc",
60    "public/pw_hdlc/internal/encoder.h",
61  ]
62  public_deps = [
63    ":common",
64    dir_pw_bytes,
65    dir_pw_checksum,
66    dir_pw_status,
67    dir_pw_stream,
68  ]
69  friend = [ ":*" ]
70}
71
72pw_source_set("rpc_channel_output") {
73  public_configs = [ ":default_config" ]
74  public = [ "public/pw_hdlc/rpc_channel.h" ]
75  public_deps = [
76    ":pw_hdlc",
77    "$dir_pw_rpc:server",
78  ]
79}
80
81pw_source_set("pw_rpc") {
82  public_configs = [ ":default_config" ]
83  public = [ "public/pw_hdlc/rpc_packets.h" ]
84  sources = [ "rpc_packets.cc" ]
85  public_deps = [
86    ":pw_hdlc",
87    "$dir_pw_rpc:server",
88    dir_pw_sys_io,
89  ]
90}
91
92pw_source_set("packet_parser") {
93  public_configs = [ ":default_config" ]
94  public = [ "public/pw_hdlc/wire_packet_parser.h" ]
95  sources = [ "wire_packet_parser.cc" ]
96  public_deps = [
97    ":pw_hdlc",
98    "$dir_pw_router:packet_parser",
99  ]
100  deps = [
101    dir_pw_bytes,
102    dir_pw_checksum,
103  ]
104}
105
106pw_test_group("tests") {
107  tests = [
108    ":encoder_test",
109    ":decoder_test",
110    ":rpc_channel_test",
111    ":wire_packet_parser_test",
112  ]
113  group_deps = [
114    "$dir_pw_preprocessor:tests",
115    "$dir_pw_status:tests",
116    "$dir_pw_stream:tests",
117  ]
118}
119
120pw_test("encoder_test") {
121  deps = [ ":pw_hdlc" ]
122  sources = [ "encoder_test.cc" ]
123}
124
125pw_python_action("generate_decoder_test") {
126  outputs = [ "$target_gen_dir/generated_decoder_test.cc" ]
127  script = "py/decode_test.py"
128  args = [ "--generate-cc-test" ] + rebase_path(outputs, root_build_dir)
129  python_deps = [
130    "$dir_pw_build/py",
131    "py",
132  ]
133}
134
135pw_test("decoder_test") {
136  deps = [
137    ":generate_decoder_test",
138    ":pw_hdlc",
139  ]
140  sources = [ "decoder_test.cc" ] + get_target_outputs(":generate_decoder_test")
141}
142
143pw_test("rpc_channel_test") {
144  deps = [
145    ":pw_hdlc",
146    ":rpc_channel_output",
147  ]
148  sources = [ "rpc_channel_test.cc" ]
149}
150
151pw_test("wire_packet_parser_test") {
152  deps = [
153    ":packet_parser",
154    dir_pw_bytes,
155  ]
156  sources = [ "wire_packet_parser_test.cc" ]
157}
158
159pw_doc_group("docs") {
160  sources = [
161    "docs.rst",
162    "rpc_example/docs.rst",
163  ]
164  inputs = [
165    "py/pw_hdlc/decode.py",
166    "py/pw_hdlc/encode.py",
167  ]
168}
169