blob: 5a4e800c5a7886887f7f85ee83e87f5e9aee26e2 [file] [log] [blame]
Alexei Frolov9c2ed462020-01-13 15:35:42 -08001# Copyright 2020 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 -070015# gn-format disable
16import("//build_overrides/pigweed.gni")
17
Alexei Frolovbbf164c2019-12-16 12:51:59 -080018import("$dir_pw_build/input_group.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")
23import("$dir_pw_unit_test/test.gni")
Alexei Frolovbbf164c2019-12-16 12:51:59 -080024config("default_config") {
25 include_dirs = [ "public" ]
26}
27
Alexei Frolovedd2f142020-06-09 19:11:27 -070028pw_source_set("pw_protobuf") {
Wyatt Hepler21192402020-01-15 15:40:51 -080029 public_configs = [ ":default_config" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080030 public_deps = [
31 "$dir_pw_status",
32 "$dir_pw_varint",
33 ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080034 public = [
35 "public/pw_protobuf/codegen.h",
Alexei Frolovdea46f72020-01-07 13:28:24 -080036 "public/pw_protobuf/decoder.h",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080037 "public/pw_protobuf/encoder.h",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070038 "public/pw_protobuf/find.h",
Alexei Frolovdea46f72020-01-07 13:28:24 -080039 "public/pw_protobuf/wire_format.h",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080040 ]
Alexei Frolovdea46f72020-01-07 13:28:24 -080041 sources = [
42 "decoder.cc",
43 "encoder.cc",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070044 "find.cc",
Alexei Frolovdea46f72020-01-07 13:28:24 -080045 ]
46 sources += public
Alexei Frolovbbf164c2019-12-16 12:51:59 -080047}
48
Alexei Frolov9c2ed462020-01-13 15:35:42 -080049pw_doc_group("docs") {
50 sources = [
Alexei Frolov4a257c12020-03-02 14:09:42 -080051 "decoding.rst",
Alexei Frolov9c2ed462020-01-13 15:35:42 -080052 "docs.rst",
53 ]
54 report_deps = [
55 "size_report:decoder_full",
56 "size_report:decoder_incremental",
57 ]
58}
59
Alexei Frolovbbf164c2019-12-16 12:51:59 -080060# Source files for pw_protobuf's protoc plugin.
61pw_input_group("codegen_protoc_plugin") {
62 inputs = [
Alexei Frolov18d08bf2020-06-05 13:42:40 -070063 "py/pw_protobuf/codegen_pwpb.py",
64 "py/pw_protobuf/plugin.py",
65 "py/pw_protobuf/proto_tree.py",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080066 ]
67}
68
69pw_test_group("tests") {
70 tests = [
71 ":codegen_test",
Alexei Frolovdea46f72020-01-07 13:28:24 -080072 ":decoder_test",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080073 ":encoder_test",
Aaron Green0ce7f412020-04-06 13:39:40 -070074 ":encoder_fuzzer",
Alexei Frolovbbbedff2020-03-11 14:21:38 -070075 ":find_test",
Alexei Frolovbbf164c2019-12-16 12:51:59 -080076 ]
77}
78
Alexei Frolovdea46f72020-01-07 13:28:24 -080079pw_test("decoder_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -080080 deps = [ ":pw_protobuf" ]
81 sources = [ "decoder_test.cc" ]
Alexei Frolovdea46f72020-01-07 13:28:24 -080082}
83
Alexei Frolovbbf164c2019-12-16 12:51:59 -080084pw_test("encoder_test") {
Rob Mohra0ba54f2020-02-27 11:43:49 -080085 deps = [ ":pw_protobuf" ]
86 sources = [ "encoder_test.cc" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080087}
88
Alexei Frolovbbbedff2020-03-11 14:21:38 -070089pw_test("find_test") {
90 deps = [ ":pw_protobuf" ]
91 sources = [ "find_test.cc" ]
92}
93
Alexei Frolovbbf164c2019-12-16 12:51:59 -080094pw_test("codegen_test") {
Alexei Frolove19ebb82020-05-14 17:21:20 -070095 deps = [ ":codegen_test_protos_pwpb" ]
Rob Mohra0ba54f2020-02-27 11:43:49 -080096 sources = [ "codegen_test.cc" ]
Alexei Frolovbbf164c2019-12-16 12:51:59 -080097}
98
99pw_proto_library("codegen_test_protos") {
100 sources = [
101 "pw_protobuf_protos/test_protos/full_test.proto",
Alexei Frolove19ebb82020-05-14 17:21:20 -0700102 "pw_protobuf_protos/test_protos/imported.proto",
103 "pw_protobuf_protos/test_protos/importer.proto",
Nathaniel Brough06fe47b2020-06-19 17:40:49 +0800104 "pw_protobuf_protos/test_protos/non_pw_package.proto",
Alexei Frolovbbf164c2019-12-16 12:51:59 -0800105 "pw_protobuf_protos/test_protos/proto2.proto",
106 "pw_protobuf_protos/test_protos/repeated.proto",
107 ]
108}
Aaron Green0ce7f412020-04-06 13:39:40 -0700109
110pw_fuzzer("encoder_fuzzer") {
111 sources = [ "encoder_fuzzer.cc" ]
112 deps = [ ":pw_protobuf" ]
113}