blob: ceb9947b5f6f940a0b7b62eca2b5ce898f4bac72 [file] [log] [blame]
Alexei Frolovf9ae1892021-04-01 18:24:27 -07001# Copyright 2021 The Pigweed Authors
Alexei Frolovbbf164c2019-12-16 12:51:59 -08002#
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
Armando Montanezfb3d3fb2020-06-09 18:12:12 -070015import("//build_overrides/pigweed.gni")
16
Alexei Frolovbbf164c2019-12-16 12:51:59 -080017import("$dir_pw_build/input_group.gni")
Alexei Frolovf9ae1892021-04-01 18:24:27 -070018import("$dir_pw_build/module_config.gni")
Alexei Frolovedd2f142020-06-09 19:11:27 -070019import("$dir_pw_build/target_types.gni")
Alexei Frolov9c2ed462020-01-13 15:35:42 -080020import("$dir_pw_docgen/docs.gni")
Aaron Green0ce7f412020-04-06 13:39:40 -070021import("$dir_pw_fuzzer/fuzzer.gni")
Alexei Frolovbbf164c2019-12-16 12:51:59 -080022import("$dir_pw_protobuf_compiler/proto.gni")
Alexei Frolovf9ae1892021-04-01 18:24:27 -070023import("$dir_pw_unit_test/facade_test.gni")
Alexei Frolovbbf164c2019-12-16 12:51:59 -080024import("$dir_pw_unit_test/test.gni")
Wyatt Heplerd49f8fe2020-10-15 10:13:47 -070025
Alexei Frolovf9ae1892021-04-01 18:24:27 -070026declare_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") {
Alexei Frolovbbf164c2019-12-16 12:51:59 -080034 include_dirs = [ "public" ]
35}
36
Alexei Frolovf9ae1892021-04-01 18:24:27 -070037pw_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
Alexei Frolovedd2f142020-06-09 19:11:27 -070044pw_source_set("pw_protobuf") {
Alexei Frolovf9ae1892021-04-01 18:24:27 -070045 public_configs = [ ":public_include_path" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080046 public_deps = [
Alexei Frolovf9ae1892021-04-01 18:24:27 -070047 ":config",
Alexei Frolov13c7c4f2020-10-02 09:41:01 -070048 dir_pw_bytes,
49 dir_pw_result,
50 dir_pw_status,
51 dir_pw_varint,
Alexei Frolovbbf164c2019-12-16 12:51:59 -080052 ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080053 public = [
54 "public/pw_protobuf/codegen.h",
Alexei Frolovdea46f72020-01-07 13:28:24 -080055 "public/pw_protobuf/decoder.h",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080056 "public/pw_protobuf/encoder.h",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070057 "public/pw_protobuf/find.h",
Ewout van Bekkumc76aa402020-09-23 10:58:27 -070058 "public/pw_protobuf/serialized_size.h",
Alexei Frolovdea46f72020-01-07 13:28:24 -080059 "public/pw_protobuf/wire_format.h",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080060 ]
Alexei Frolovdea46f72020-01-07 13:28:24 -080061 sources = [
62 "decoder.cc",
63 "encoder.cc",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070064 "find.cc",
Alexei Frolovdea46f72020-01-07 13:28:24 -080065 ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080066}
67
Alexei Frolov9c2ed462020-01-13 15:35:42 -080068pw_doc_group("docs") {
69 sources = [
Alexei Frolov4a257c12020-03-02 14:09:42 -080070 "decoding.rst",
Alexei Frolov9c2ed462020-01-13 15:35:42 -080071 "docs.rst",
72 ]
73 report_deps = [
74 "size_report:decoder_full",
75 "size_report:decoder_incremental",
76 ]
77}
78
Alexei Frolovbbf164c2019-12-16 12:51:59 -080079pw_test_group("tests") {
80 tests = [
81 ":codegen_test",
Alexei Frolovdea46f72020-01-07 13:28:24 -080082 ":decoder_test",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080083 ":encoder_test",
Aaron Green0ce7f412020-04-06 13:39:40 -070084 ":encoder_fuzzer",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070085 ":find_test",
Alexei Frolovf9ae1892021-04-01 18:24:27 -070086 ":varint_size_test",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080087 ]
88}
89
Alexei Frolovdea46f72020-01-07 13:28:24 -080090pw_test("decoder_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -080091 deps = [ ":pw_protobuf" ]
92 sources = [ "decoder_test.cc" ]
Alexei Frolovdea46f72020-01-07 13:28:24 -080093}
94
Alexei Frolovbbf164c2019-12-16 12:51:59 -080095pw_test("encoder_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -080096 deps = [ ":pw_protobuf" ]
97 sources = [ "encoder_test.cc" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080098}
99
Alexei Frolovbbbedff2020-03-11 14:21:38 -0700100pw_test("find_test") {
101 deps = [ ":pw_protobuf" ]
102 sources = [ "find_test.cc" ]
103}
104
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800105pw_test("codegen_test") {
Alexei Frolov8e30d462020-10-22 13:54:36 -0700106 deps = [ ":codegen_test_protos.pwpb" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -0800107 sources = [ "codegen_test.cc" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800108}
109
Alexei Frolovf9ae1892021-04-01 18:24:27 -0700110config("one_byte_varint") {
111 defines = [ "PW_PROTOBUF_CFG_MAX_VARINT_SIZE=1" ]
112 visibility = [ ":*" ]
113}
114
115pw_source_set("varint_size_test_config") {
116 public_configs = [ ":one_byte_varint" ]
117 visibility = [ ":*" ]
118}
119
120pw_facade_test("varint_size_test") {
121 build_args = {
122 pw_protobuf_CONFIG = ":varint_size_test_config"
123 }
124 deps = [ ":pw_protobuf" ]
125 sources = [ "varint_size_test.cc" ]
126}
127
Wyatt Hepler7c61caf2020-11-24 11:29:05 -0800128pw_proto_library("common_protos") {
129 sources = [ "pw_protobuf_protos/common.proto" ]
130}
131
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800132pw_proto_library("codegen_test_protos") {
133 sources = [
Wyatt Hepler91741472021-02-03 08:45:10 -0800134 "pw_protobuf_test_protos/full_test.proto",
135 "pw_protobuf_test_protos/imported.proto",
136 "pw_protobuf_test_protos/importer.proto",
137 "pw_protobuf_test_protos/non_pw_package.proto",
138 "pw_protobuf_test_protos/proto2.proto",
139 "pw_protobuf_test_protos/repeated.proto",
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800140 ]
Wyatt Hepler7c61caf2020-11-24 11:29:05 -0800141 deps = [ ":common_protos" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800142}
Aaron Green0ce7f412020-04-06 13:39:40 -0700143
144pw_fuzzer("encoder_fuzzer") {
145 sources = [ "encoder_fuzzer.cc" ]
146 deps = [ ":pw_protobuf" ]
147}