Change script for apply upstream code
[platform/upstream/connectedhomeip.git] / third_party / pigweed / repo / pw_hdlc_lite / BUILD.gn
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
15 import("//build_overrides/pigweed.gni")
16
17 import("$dir_pw_build/target_types.gni")
18 import("$dir_pw_docgen/docs.gni")
19 import("$dir_pw_unit_test/test.gni")
20
21 config("default_config") {
22   include_dirs = [ "public" ]
23 }
24
25 group("pw_hdlc_lite") {
26   public_deps = [
27     ":decoder",
28     ":encoder",
29   ]
30 }
31
32 pw_source_set("decoder") {
33   public_configs = [ ":default_config" ]
34   public = [ "public/pw_hdlc_lite/decoder.h" ]
35   sources = [
36     "decoder.cc",
37     "pw_hdlc_lite_private/protocol.h",
38   ]
39   public_deps = [
40     dir_pw_bytes,
41     dir_pw_result,
42     dir_pw_status,
43   ]
44   deps = [
45     dir_pw_checksum,
46     dir_pw_log,
47   ]
48   friend = [ ":*" ]
49 }
50
51 pw_source_set("encoder") {
52   public_configs = [ ":default_config" ]
53   public = [
54     "public/pw_hdlc_lite/encoder.h",
55     "public/pw_hdlc_lite/sys_io_stream.h",
56   ]
57   sources = [
58     "encoder.cc",
59     "pw_hdlc_lite_private/protocol.h",
60   ]
61   public_deps = [
62     dir_pw_bytes,
63     dir_pw_status,
64     dir_pw_stream,
65     dir_pw_sys_io,
66   ]
67   deps = [ dir_pw_checksum ]
68   friend = [ ":*" ]
69 }
70
71 pw_source_set("pw_rpc") {
72   public_configs = [ ":default_config" ]
73   public = [
74     "public/pw_hdlc_lite/rpc_channel.h",
75     "public/pw_hdlc_lite/rpc_packets.h",
76   ]
77   sources = [ "rpc_packets.cc" ]
78   public_deps = [
79     ":pw_hdlc_lite",
80     "$dir_pw_rpc:server",
81   ]
82 }
83
84 pw_test_group("tests") {
85   tests = [
86     ":encoder_test",
87     ":decoder_test",
88     ":rpc_channel_test",
89   ]
90   group_deps = [
91     "$dir_pw_preprocessor:tests",
92     "$dir_pw_span:tests",
93     "$dir_pw_status:tests",
94     "$dir_pw_stream:tests",
95   ]
96 }
97
98 pw_test("encoder_test") {
99   deps = [ ":pw_hdlc_lite" ]
100   sources = [ "encoder_test.cc" ]
101 }
102
103 action("generate_decoder_test") {
104   outputs = [ "$target_gen_dir/generated_decoder_test.cc" ]
105   script = "py/decode_test.py"
106   args = [ "--generate-cc-test" ] + rebase_path(outputs)
107   deps = [ "$dir_pw_build/py" ]
108 }
109
110 pw_test("decoder_test") {
111   deps = [
112     ":generate_decoder_test",
113     ":pw_hdlc_lite",
114   ]
115   sources = [ "decoder_test.cc" ] + get_target_outputs(":generate_decoder_test")
116 }
117
118 pw_test("rpc_channel_test") {
119   deps = [
120     ":pw_hdlc_lite",
121     ":pw_rpc",
122   ]
123   sources = [ "rpc_channel_test.cc" ]
124 }
125
126 pw_doc_group("docs") {
127   sources = [
128     "docs.rst",
129     "rpc_example/docs.rst",
130   ]
131   inputs = [
132     "py/pw_hdlc_lite/decode.py",
133     "py/pw_hdlc_lite/encode.py",
134   ]
135 }