xref: /aosp_15_r20/external/pigweed/pw_protobuf_compiler/BUILD.gn (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2019 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_docgen/docs.gni")
19import("$dir_pw_protobuf_compiler/proto.gni")
20import("$dir_pw_third_party/nanopb/nanopb.gni")
21import("$dir_pw_unit_test/test.gni")
22
23pw_doc_group("docs") {
24  sources = [ "docs.rst" ]
25}
26
27pw_test_group("tests") {
28  tests = [
29    ":nanopb_test",
30    ":pwpb_test",
31    ":nested_packages_test",
32    ":pwpb_no_prefix_test",
33  ]
34}
35
36pw_test("nanopb_test") {
37  deps = [ ":nanopb_test_protos.nanopb" ]
38  sources = [ "nanopb_test.cc" ]
39  enable_if = dir_pw_third_party_nanopb != ""
40}
41
42pw_proto_library("nanopb_test_protos") {
43  sources = [ "nanopb_test_protos/nanopb_test.proto" ]
44  prefix = "pw_protobuf_compiler"
45
46  if (dir_pw_third_party_nanopb != "") {
47    deps = [ "$dir_pw_third_party/nanopb:proto" ]
48  }
49}
50
51pw_test("pwpb_test") {
52  deps = [ ":pwpb_test_protos.pwpb" ]
53  sources = [ "pwpb_test.cc" ]
54}
55
56pw_proto_library("pwpb_test_protos") {
57  sources = [ "pwpb_test_protos/pwpb_test.proto" ]
58  inputs = [ "pwpb_test_protos/pwpb_test.pwpb_options" ]
59  prefix = "pw_protobuf_compiler"
60  deps = [ "$dir_pw_protobuf:common_protos" ]
61}
62
63pw_proto_library("test_protos") {
64  sources = [
65    "pw_protobuf_compiler_protos/nested/more_nesting/test.proto",
66    "pw_protobuf_compiler_protos/test.proto",
67  ]
68}
69
70pw_test("nested_packages_test") {
71  deps = [ "pw_nested_packages:aggregate_wrapper.pwpb" ]
72  sources = [ "nested_packages_test.cc" ]
73}
74
75# This proto library intentionally strips the include path prefix for testing
76# purposes.
77pw_proto_library("pwpb_no_prefix_test_protos") {
78  sources = [ "pwpb_no_prefix_test_protos/pwpb_test_no_prefix.proto" ]
79  strip_prefix = "pwpb_no_prefix_test_protos/"
80  deps = [ "$dir_pw_protobuf:common_protos" ]
81}
82
83pw_test("pwpb_no_prefix_test") {
84  sources = [ "pwpb_test_no_prefix.cc" ]
85  deps = [ ":pwpb_no_prefix_test_protos.pwpb" ]
86}
87