• 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/input_group.gni")
18import("$dir_pw_build/module_config.gni")
19import("$dir_pw_build/target_types.gni")
20import("$dir_pw_docgen/docs.gni")
21import("$dir_pw_fuzzer/fuzzer.gni")
22import("$dir_pw_protobuf_compiler/proto.gni")
23import("$dir_pw_unit_test/facade_test.gni")
24import("$dir_pw_unit_test/test.gni")
25
26declare_args() {
27  # The build target that overrides the default configuration options for this
28  # module. This should point to a source set that provides defines through a
29  # public config (which may -include a file or add defines directly).
30  pw_protobuf_CONFIG = pw_build_DEFAULT_MODULE_CONFIG
31}
32
33config("public_include_path") {
34  include_dirs = [ "public" ]
35}
36
37pw_source_set("config") {
38  public = [ "public/pw_protobuf/config.h" ]
39  public_configs = [ ":public_include_path" ]
40  public_deps = [ pw_protobuf_CONFIG ]
41  visibility = [ ":*" ]
42}
43
44pw_source_set("pw_protobuf") {
45  public_configs = [ ":public_include_path" ]
46  public_deps = [
47    ":config",
48    "$dir_pw_containers:vector",
49    "$dir_pw_stream:interval_reader",
50    "$dir_pw_varint:stream",
51    dir_pw_assert,
52    dir_pw_bytes,
53    dir_pw_log,
54    dir_pw_result,
55    dir_pw_status,
56    dir_pw_stream,
57    dir_pw_varint,
58  ]
59  public = [
60    "public/pw_protobuf/decoder.h",
61    "public/pw_protobuf/encoder.h",
62    "public/pw_protobuf/find.h",
63    "public/pw_protobuf/internal/proto_integer_base.h",
64    "public/pw_protobuf/map_utils.h",
65    "public/pw_protobuf/message.h",
66    "public/pw_protobuf/serialized_size.h",
67    "public/pw_protobuf/stream_decoder.h",
68    "public/pw_protobuf/wire_format.h",
69  ]
70  sources = [
71    "decoder.cc",
72    "encoder.cc",
73    "find.cc",
74    "map_utils.cc",
75    "message.cc",
76    "stream_decoder.cc",
77  ]
78}
79
80pw_source_set("bytes_utils") {
81  public_configs = [ ":public_include_path" ]
82  public = [ "public/pw_protobuf/bytes_utils.h" ]
83  public_deps = [
84    ":pw_protobuf",
85    dir_pw_bytes,
86    dir_pw_result,
87    dir_pw_status,
88  ]
89}
90
91pw_doc_group("docs") {
92  sources = [ "docs.rst" ]
93  report_deps = [
94    "size_report:decoder_full",
95    "size_report:decoder_incremental",
96  ]
97}
98
99pw_test_group("tests") {
100  tests = [
101    ":codegen_decoder_test",
102    ":codegen_encoder_test",
103    ":decoder_test",
104    ":encoder_test",
105    ":encoder_fuzzer",
106    ":find_test",
107    ":map_utils_test",
108    ":message_test",
109    ":serialized_size_test",
110    ":stream_decoder_test",
111    ":varint_size_test",
112  ]
113}
114
115pw_test("decoder_test") {
116  deps = [ ":pw_protobuf" ]
117  sources = [ "decoder_test.cc" ]
118}
119
120pw_test("encoder_test") {
121  deps = [ ":pw_protobuf" ]
122  sources = [ "encoder_test.cc" ]
123}
124
125pw_test("find_test") {
126  deps = [ ":pw_protobuf" ]
127  sources = [ "find_test.cc" ]
128}
129
130pw_test("codegen_decoder_test") {
131  deps = [ ":codegen_test_protos.pwpb" ]
132  sources = [ "codegen_decoder_test.cc" ]
133}
134
135pw_test("codegen_encoder_test") {
136  deps = [ ":codegen_test_protos.pwpb" ]
137  sources = [ "codegen_encoder_test.cc" ]
138}
139
140pw_test("serialized_size_test") {
141  deps = [ ":pw_protobuf" ]
142  sources = [ "serialized_size_test.cc" ]
143}
144
145pw_test("stream_decoder_test") {
146  deps = [ ":pw_protobuf" ]
147  sources = [ "stream_decoder_test.cc" ]
148}
149
150pw_test("map_utils_test") {
151  deps = [ ":pw_protobuf" ]
152  sources = [ "map_utils_test.cc" ]
153}
154
155pw_test("message_test") {
156  deps = [ ":pw_protobuf" ]
157  sources = [ "message_test.cc" ]
158}
159
160config("one_byte_varint") {
161  defines = [ "PW_PROTOBUF_CFG_MAX_VARINT_SIZE=1" ]
162  visibility = [ ":*" ]
163}
164
165pw_source_set("varint_size_test_config") {
166  public_configs = [ ":one_byte_varint" ]
167  visibility = [ ":*" ]
168}
169
170pw_facade_test("varint_size_test") {
171  build_args = {
172    pw_protobuf_CONFIG = ":varint_size_test_config"
173  }
174  deps = [ ":pw_protobuf" ]
175  sources = [ "varint_size_test.cc" ]
176}
177
178pw_proto_library("common_protos") {
179  sources = [
180    "pw_protobuf_protos/common.proto",
181    "pw_protobuf_protos/status.proto",
182  ]
183}
184
185pw_proto_library("codegen_test_protos") {
186  sources = [
187    "pw_protobuf_test_protos/full_test.proto",
188    "pw_protobuf_test_protos/imported.proto",
189    "pw_protobuf_test_protos/importer.proto",
190    "pw_protobuf_test_protos/non_pw_package.proto",
191    "pw_protobuf_test_protos/proto2.proto",
192    "pw_protobuf_test_protos/repeated.proto",
193  ]
194  deps = [ ":common_protos" ]
195}
196
197pw_fuzzer("encoder_fuzzer") {
198  sources = [ "encoder_fuzzer.cc" ]
199  deps = [ ":pw_protobuf" ]
200}
201