• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
14load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
15load("@rules_python//python:proto.bzl", "py_proto_library")
16load("@rules_python//sphinxdocs:sphinx_docs_library.bzl", "sphinx_docs_library")
17load("//pw_build:compatibility.bzl", "incompatible_with_mcu")
18load("//pw_build:copy_to_bin.bzl", "copy_to_bin")
19load("//pw_protobuf_compiler:pw_proto_filegroup.bzl", "pw_proto_filegroup")
20load(
21    "//pw_protobuf_compiler:pw_proto_library.bzl",
22    "nanopb_proto_library",
23    "pwpb_proto_library",
24)
25load("//pw_unit_test:pw_cc_test.bzl", "pw_cc_test")
26
27package(
28    default_visibility = ["//visibility:public"],
29    features = ["-layering_check"],
30)
31
32licenses(["notice"])
33
34pw_cc_test(
35    name = "nanopb_test",
36    srcs = ["nanopb_test.cc"],
37    # TODO: https://pwbug.dev/328311416 - Fix this test.
38    tags = ["manual"],
39    deps = [":pw_protobuf_compiler_nanopb_protos_nanopb"],
40)
41
42pw_cc_test(
43    name = "pwpb_test",
44    srcs = ["pwpb_test.cc"],
45    deps = [
46        "//pw_protobuf_compiler/pwpb_test_protos:pwpb_test_pw_proto",
47        "//pw_string",
48    ],
49)
50
51proto_library(
52    name = "pwpb_test_proto_no_prefix",
53    srcs = ["pwpb_no_prefix_test_protos/pwpb_test_no_prefix.proto"],
54    strip_import_prefix = "/pw_protobuf_compiler/pwpb_no_prefix_test_protos",
55    deps = [
56        "//pw_protobuf:field_options_proto",
57    ],
58)
59
60pwpb_proto_library(
61    name = "pwpb_test_pw_proto_no_prefix",
62    deps = [
63        ":pwpb_test_proto_no_prefix",
64    ],
65)
66
67pw_cc_test(
68    name = "pwpb_test_no_prefix",
69    srcs = ["pwpb_test_no_prefix.cc"],
70    deps = [
71        ":pwpb_test_pw_proto_no_prefix",
72        "//pw_string",
73    ],
74)
75
76py_proto_library(
77    name = "pw_protobuf_compiler_protos_py_pb2",
78    deps = [":pw_protobuf_compiler_protos"],
79)
80
81proto_library(
82    name = "pw_protobuf_compiler_protos",
83    srcs = [
84        "pw_protobuf_compiler_protos/nested/more_nesting/test.proto",
85        "pw_protobuf_compiler_protos/test.proto",
86    ],
87    strip_import_prefix = "/pw_protobuf_compiler",
88)
89
90proto_library(
91    name = "pw_protobuf_compiler_nanopb_protos",
92    srcs = ["nanopb_test_protos/nanopb_test.proto"],
93    deps = ["@com_github_nanopb_nanopb//:nanopb_proto"],
94)
95
96nanopb_proto_library(
97    name = "pw_protobuf_compiler_nanopb_protos_nanopb",
98    deps = [":pw_protobuf_compiler_nanopb_protos"],
99)
100
101py_proto_library(
102    name = "pw_protobuf_compiler_nanopb_protos_py_pb2",
103    deps = [":pw_protobuf_compiler_nanopb_protos"],
104)
105
106pw_cc_test(
107    name = "nested_packages_test",
108    srcs = ["nested_packages_test.cc"],
109    deps = [
110        "//pw_protobuf_compiler/pw_nested_packages:aggregate_pwpb",
111        "//pw_protobuf_compiler/pw_nested_packages:aggregate_wrapper_pwpb",
112        "//pw_protobuf_compiler/pw_nested_packages/data_type/id:id_pwpb",
113        "//pw_protobuf_compiler/pw_nested_packages/data_type/thing:thing_pwpb",
114        "//pw_protobuf_compiler/pw_nested_packages/data_type/thing:type_of_thing_pwpb",
115    ],
116)
117
118sphinx_docs_library(
119    name = "docs",
120    srcs = [
121        "docs.rst",
122    ],
123    prefix = "pw_protobuf_compiler/",
124    target_compatible_with = incompatible_with_mcu(),
125)
126
127copy_to_bin(
128    name = "js_protos",
129    srcs = [
130        "pw_protobuf_compiler_protos/nested/more_nesting/test.proto",
131        "pw_protobuf_compiler_protos/test.proto",
132    ],
133)
134
135pw_proto_filegroup(
136    name = "prefix_tests_proto_with_options",
137    srcs = ["nanopb_test_protos/prefix_tests.proto"],
138    options_files = ["nanopb_test_protos/prefix_tests.options"],
139)
140
141proto_library(
142    name = "prefix_tests_default_proto",
143    srcs = [":prefix_tests_proto_with_options"],
144)
145
146nanopb_proto_library(
147    name = "prefix_tests_default_nanopb",
148    deps = [":prefix_tests_default_proto"],
149)
150
151pw_cc_test(
152    name = "prefix_default_test",
153    srcs = ["prefix_test.cc"],
154    local_defines = ["PW_PROTOBUF_COMPILER_IMPORT=DEFAULT"],
155    deps = [
156        ":prefix_tests_default_nanopb",
157        "//pw_status",
158        "//pw_string:util",
159    ],
160)
161
162proto_library(
163    name = "prefix_tests_strip_import_prefix_proto",
164    srcs = [":prefix_tests_proto_with_options"],
165    strip_import_prefix = "/pw_protobuf_compiler/nanopb_test_protos",
166)
167
168nanopb_proto_library(
169    name = "prefix_tests_strip_import_prefix_nanopb",
170    deps = [":prefix_tests_strip_import_prefix_proto"],
171)
172
173pw_cc_test(
174    name = "prefix_strip_import_prefix_test",
175    srcs = ["prefix_test.cc"],
176    local_defines = ["PW_PROTOBUF_COMPILER_IMPORT=STRIP_IMPORT_PREFIX"],
177    deps = [
178        ":prefix_tests_strip_import_prefix_nanopb",
179        "//pw_status",
180        "//pw_string:util",
181    ],
182)
183
184proto_library(
185    name = "prefix_tests_import_prefix_proto",
186    srcs = [":prefix_tests_proto_with_options"],
187    import_prefix = "some_prefix",
188    strip_import_prefix = "/pw_protobuf_compiler/nanopb_test_protos",
189)
190
191nanopb_proto_library(
192    name = "prefix_tests_import_prefix_nanopb",
193    deps = [":prefix_tests_import_prefix_proto"],
194)
195
196pw_cc_test(
197    name = "prefix_import_prefix_test",
198    srcs = ["prefix_test.cc"],
199    local_defines = ["PW_PROTOBUF_COMPILER_IMPORT=IMPORT_PREFIX"],
200    deps = [
201        ":prefix_tests_import_prefix_nanopb",
202        "//pw_status",
203        "//pw_string:util",
204    ],
205)
206